31
\$\begingroup\$

A lot of PPCG users helped with the creation of this challenge, both in chat and the Sandbox, specifically Martin Ender, AdmBorkBork, Emigna and user202729

Our community has found it necessary to create a set of languages designed specifically for golfing, "golfing languages" as we call them. Such languages have evolved from the once brilliant, now clunky GolfScript to the sleek concise languages such as Jelly and Husk. As we can see, these languages are continually getting shorter and shorter for a set of tasks. So, as the obvious experts around here regarding golfing languages, we should design a language together to beat every other language that dares to compete. Introducing Bugle!

Bugle: From the acronym BuGoL: Built Golfing Language.

How this challenge will work

In case you didn't get what I'm alluding to in the introduction, this challenge is an challenge where we each contribute something to the interpreter of a new golfing language, improving its ability to compete on PPCG with each answer.

I will post the first answer consisting of the basis of the language spec/interpreter, and all other answers will continue from that. New submissions will provide the following things:

  • A change to the language's spec
  • An up-to-date interpreter, meeting exactly what is laid out in the changes
  • The language's updated score (more details in a bit)

You may change the spec in one of three ways:

  • You may add a single command
  • You may add two new commands
  • You may edit the behaviour of one existing command

Regarding the new interpreter, you must use the latest version, written in Python. It does not have to be golfed. Every previously added command must be testable with the latest interpreter, as well as the newest command(s) (the one you add). You must also not use offensive language at any point when updating the interpreter, such as in comments or string literals etc.

The added command(s) may do anything you wish. The only requirements are:

  • It doesn't produce offensive output
  • It isn't the same as another command
  • It doesn't prevent one of the sample challenges from being completed

Aside from these, it can be as specific or as general as you want. It can also be any character you want. If you aren't sure if your addition constitutes a 'new command', feel free to ask in the comments.

The language's score

You may have noticed that you have to include the language's score in all new submissions. Its score is what prevents this challenge going forever, and is defined as follows:

The current score is the sum of the byte counts it takes for the language to complete the below 20 tasks

For each of the tasks, Standard I/O rules apply, as do the standard loopholes.

The 20 tasks:

  1. "Hello, World!" – Output the string Hello, World!
  2. 1, 2, Fizz, 4, Buzz – Output each integer from 1 to 100 (inclusive) on a separate line, with multiples of 3 being replaced by Fizz, multiples of 5 being replaced by Buzz and multiples of both by FizzBuzz
  3. Produce the number 2014 without any numbers in your source code – Output the number 2014 without using any of the characters 0123456789 in the source code, without accessing external variables or random seeds
  4. Obfuscated Hello World – Output the string Hello, World!, without using any of characters in at least two of the following sets: hlwd, eor01 and 27 (case-insensitive)
  5. Sing Happy Birthday to your favourite programming language – In a language of your choice, output the following:

    Happy Birthday to You
    Happy Birthday to You
    Happy Birthday Dear [the name of your favourite programming language]
    Happy Birthday to You
    
  6. We're no strangers to code golf, you know the rules, and so do I – Output the full lyrics of "Never Gonna Give You Up"

  7. Output the sign – Given a number, print -1 if it is negative, 0 if it is 0 or 1 if it is positive
  8. Collatz Conjecture (OEIS A006577) – Starting from an integer, divide it by 2 if it's even, or multiply it by 3 and add 1 if it's odd, and repeat the process until you reach 1. The output should be the number of iterations it takes you to reach 1.
  9. An Array of Challenges #1: Alternating Arrays – Given an array of integers, check whether all even-indexed items are equal, and all odd-indexed items are equal, and output a truthy or falsy value accordingly
  10. Am I an insignificant array? – Given an array of integers, check whether the absolute differences between consecutive elements are all smaller than or equal to 1, and output a truthy or falsy value accordingly
  11. Is this number a prime? – Given a positive integer, write a full program to check whether it is prime, and output a truthy or falsy value accordingly
  12. I'm a palindrome. Are you? – Given a string, check whether it is palindrome, while your program / function is palindrome too, and output two distinct and consistent values accordingly
  13. Sum the numbers on standard in - Take a series of numbers in from STDIN and output their sum.
  14. Find the Factorial - Given an integer n, output the product of all integers between 1 and n inclusive.
  15. Shortest code to produce infinite output - Without any input, produce infinite output, that will, theoretically, never stop outputting.
  16. Bake a slice of Pi - Output this exact text:
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|
  1. Find the smallest number that doesn't divide N - Given a positive integer N, output the smallest positive integer that does not divide N.
  2. Is this even or odd? - Given an integer N, output its parity as truthy/falsy values.
  3. Output with the same length as the code - Write the shortest code whose output has the same length as the code, where the output is not the same as the code.
  4. Golf you a quine for great good! - Write the shortest quine in your language.

In order to be valid, a new submission must have golfed submissions for at least 2 of the problems, by at least 1 byte for each. You may increase the lengths of other submissions, but the total score must decrease by at least 2 per answer. Also, please consider including a link to the updated programs. The updated solutions must not work when run with a previous version of the interpreter.

How to get cookies

I have a list of 5 challenges, which aren't compulsory to attempt, and have no bearing on your score, but are simply additional challenges to test if Bugle is capable enough. Feel free to include a solution to any number of these in your answer:

  1. Create a Self interpreter
  2. Create a payload capable quine
  3. Covfefify a string
  4. Hyperprogramming: N+N, N×N, N^N all in one
  5. "KNOT" or "NOT"?

Descriptions not included as they aren't required for everyone to be able to compete in the challenge.

How to win

Once the minimum score (we believe to be 16, although any attempts to golf that down are much welcomed) has been reached, obviously the chain has ended as solutions cannot get a better score. Once 16 has been reached, the challenge stays alive for 1 month afterwards, to give anyone a chance to golf the solutions any more. After this month has passed, the challenge is over.

Once the challenge is over, I will be migrating the interpreter onto a GitHub repository, and going through the usual machinations of releasing a stable language. You may also begin to post solutions to challenges on PPCG at this time, using the said language, but please try not to flood the front page with answers. Instead, spread them out over a period of time.

Formatting

In order to make information easier to find in your answer, please format it as follows:

# [N]. [Score]

[New command + description]

[Interpreter/link to interpreter]

[Link to programs]

Where [N] is your answer number (1 for the first, 2 for the second etc.)

Rules

  • You must wait 3 hours between posting answers
  • You may not post twice in a row, unless no answer has been posted for 10 days (exactly 240 hours)
  • You may not remove previous commands.
  • Your interpreter doesn't have to be golfed, and its byte count is completely irrelevant here.
  • If someone suggests a golf to the programs while your answer is the latest, you must edit in the golfs, and update your score.
    • You may also do this when your answer is in the middle of the chain, so long as your score doesn't become lower than any later answers.
  • Please refrain from answering any existing PPCG challenges using this language, at least until the challenge is over
  • The interpreter is written in Python 3, and should continue that way throughout the entire chain. Changing the language is forbidden.
  • Again, in order to be valid, a new submission must have golfed submissions for at least 2 of the problems, by at least 1 byte for each.

Let's get started!

\$\endgroup\$
  • 1
    \$\begingroup\$ Sandbox \$\endgroup\$ – caird coinheringaahing Apr 13 '18 at 9:22
  • 1
    \$\begingroup\$ Might as well ask: Anyone like to explain the downvote? I'd value any and all feedback you'd like to give. \$\endgroup\$ – caird coinheringaahing Apr 13 '18 at 9:40
  • 2
    \$\begingroup\$ @Kaldo We're not quite sure. The quine has to be two bytes minimum, but if the empty program outputs Hello, World!, then it's 19 bytes. But if the behaviour of the empty program changes, dependant on the input, it may be able to be reduced \$\endgroup\$ – caird coinheringaahing Apr 13 '18 at 9:48
  • 1
    \$\begingroup\$ @WeijunZhou "Please refrain from answering any existing PPCG challenges using this language, at least until the challenge is over" \$\endgroup\$ – caird coinheringaahing Apr 14 '18 at 10:10
  • 1
    \$\begingroup\$ @LyricLy Syntax constructs (such as for loops) are allowed, and encouraged to be added \$\endgroup\$ – caird coinheringaahing Apr 14 '18 at 12:00
3
\$\begingroup\$

3. Score: 2938 2583 2532 (-51)

The new interpreter is here.

Mainly for the purposes of golfing the quine and making output easier, I've added the ability to duplicate the stack/deque and also to output the entire model in rendered text form instead of as integers.

Solutions

1. "Hello, World!" - 17 bytes (-3)

#"Hello, World!"a

5. Sing Happy Birthday to your favourite programming language - 95 bytes (-3)

#"Happy Birthday to You
Happy Birthday to You
Happy Birthday Dear Bugle
Happy Birthday to You"a

6. We're no strangers to code golf, you know the rules, and so do I - 1884 bytes (-3)

#"We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
I just wanna tell you how I'm feeling
Gotta make you understand

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

We've known each other for so long
Your heart's been aching but
You're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it
And if you ask me how I'm feeling
Don't tell me you're too blind to see

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

(Ooh, give you up)
(Ooh, give you up)
(Ooh)
Never gonna give, never gonna give
(Give you up)
(Ooh)
Never gonna give, never gonna give
(Give you up)

We've know each other for so long
Your heart's been aching but
You're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it

I just wanna tell you how I'm feeling
Gotta make you understand

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you"a

16. Bake a slice of Pi - 149 bytes (-3)

#"()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|"a

20. Golf you a quine for great good! - 23 bytes (-39)

$"R34RdR36Ra"R34RdR36Ra

Added Language Features

  • a

    • All: Print the entire model as text, e.g. #"Hello, World!"a prints Hello, World!
  • d

    • Stack/Deque: Push the stack on top of itself.
\$\endgroup\$
8
\$\begingroup\$

2. Score: 2938 2583

The modified interpreter is here on TIO.

String literal is the most obvious addition to the language, mainly to combat challenges.

Solutions

1. "Hello, World!" - 20 bytes (-28)

#"Hello, World!"[o>]

Any challenge can be completed using the structure #"<string>"[o>] which outputs the given string until the 0 after the string is reached.

2. 1, 2, Fizz, 4, Buzz - 419 64 bytes (-1332)

$1[1+1s:3s%{}"zziF"oooos;0s]:5s%{}"zzuB"oooos;0s]s{:O}]10o:100-]

Thanks to @user202729 for awesome golfing on this.

3. Produce the number 2014 without any numbers in your source code - 9 bytes (-4)

#"ĒĎ"[O>]

Uses the two chars 20 and 14 in Bugle codepoints.

4. Obfuscated Hello World - 19 bytes (-153)

#"Ifmmp!Xpsme"[-o>]

Meets rules #1 (no HLWDhlwd) and #3 (no 27).

5. Sing Happy Birthday to your favourite programming language - 98 bytes (-230)

#"Happy Birthday to You
Happy Birthday to You
Happy Birthday Dear Bugle
Happy Birthday to You"[o>]

6. We're no strangers to code golf, you know the rules, and so do I - 1887 bytes (-5006)

#"We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
I just wanna tell you how I'm feeling
Gotta make you understand

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

We've known each other for so long
Your heart's been aching but
You're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it
And if you ask me how I'm feeling
Don't tell me you're too blind to see

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

(Ooh, give you up)
(Ooh, give you up)
(Ooh)
Never gonna give, never gonna give
(Give you up)
(Ooh)
Never gonna give, never gonna give
(Give you up)

We've know each other for so long
Your heart's been aching but
You're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it

I just wanna tell you how I'm feeling
Gotta make you understand

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you"[o>]

16. Bake a slice of Pi - 149 bytes (-290)

#"()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|"[o>]

20. Golf you a quine for great good! - 62 bytes (-12)

#"[>]<o-o+[<]>[o>]<-o;<[<]>[o>]#"[>]<o-o+[<]>[o>]<-o;<[<]>[o>]

Added Language Feature

  • "...": String literal.
    • Stack / Deque: Push the Bugle codepoints of each char to the top / front of the stack / deque.
    • Tape / Grid: Write the Bugle codepoints of each char onto the tape / grid to the right, starting from the current cell. Does not move the cursor.
    • \n is handled just like other chars.
    • There is no escaped character for now, so you can't write " (34) to the memory using this command. It's not too big of a problem, at least for now, since all of the challenges listed here don't have " in the output.

Any further golfing is always welcome, especially for "Never gonna give you up" and the quine. Specifically, the above quine is very first nontrivial quine I ever made, so I strongly believe someone can come up with a shorter one.

\$\endgroup\$
  • \$\begingroup\$ There are the kinds of additions I hope everyone else does, rather than just adding builtins for the specific challenges. +1 \$\endgroup\$ – caird coinheringaahing Apr 14 '18 at 10:31
  • \$\begingroup\$ @user202729 It's probably me who introduced the bug; thanks for fixing it and the FizzBuzz solution. \$\endgroup\$ – Bubbler Apr 14 '18 at 14:39
3
\$\begingroup\$

1. Score: 9638

The base interpreter can be found here, and the submissions here. It's rather long, so I've included it on GitHub, rather than take up most of the post.

Solutions

All of these solutions are the Unicode programs, run with the -u command line flag, but the scores are counted as though encoded with Bugle's code page.

1. "Hello, World!" - 48 bytes

$72o101o108o108o111o44o32o87o111o114o108o100o33o

Simply push then output the character code of each character in the string.

2. 1, 2, Fizz, 4, Buzz - 1396 bytes

$49o10o50o10o70o105o122o122o10o52o10o66o117o122o122o10o70o105o122o122o10o55o10o56o10o70o105o122o122o10o66o117o122o122o10o49o49o10o70o105o122o122o10o49o51o10o49o52o10o70o105o122o122o66o117o122o122o10o49o54o10o49o55o10o70o105o122o122o10o49o57o10o66o117o122o122o10o70o105o122o122o10o50o50o10o50o51o10o70o105o122o122o10o66o117o122o122o10o50o54o10o70o105o122o122o10o50o56o10o50o57o10o70o105o122o122o66o117o122o122o10o51o49o10o51o50o10o70o105o122o122o10o51o52o10o66o117o122o122o10o70o105o122o122o10o51o55o10o51o56o10o70o105o122o122o10o66o117o122o122o10o52o49o10o70o105o122o122o10o52o51o10o52o52o10o70o105o122o122o66o117o122o122o10o52o54o10o52o55o10o70o105o122o122o10o52o57o10o66o117o122o122o10o70o105o122o122o10o53o50o10o53o51o10o70o105o122o122o10o66o117o122o122o10o53o54o10o70o105o122o122o10o53o56o10o53o57o10o70o105o122o122o66o117o122o122o10o54o49o10o54o50o10o70o105o122o122o10o54o52o10o66o117o122o122o10o70o105o122o122o10o54o55o10o54o56o10o70o105o122o122o10o66o117o122o122o10o55o49o10o70o105o122o122o10o55o51o10o55o52o10o70o105o122o122o66o117o122o122o10o55o54o10o55o55o10o70o105o122o122o10o55o57o10o66o117o122o122o10o70o105o122o122o10o56o50o10o56o51o10o70o105o122o122o10o66o117o122o122o10o56o54o10o70o105o122o122o10o56o56o10o56o57o10o70o105o122o122o66o117o122o122o10o57o49o10o57o50o10o70o105o122o122o10o57o52o10o66o117o122o122o10o70o105o122o122o10o57o55o10o57o56o10o70o105o122o122o10o66o117o122o122o

Same technique as the Hello, World! example

3. Produce the number 2014 without any numbers in your source code - 13 bytes

#++O--O+O+++O

# uses the tape, + increments the cell, O outputs as an integer and - decrements

4. Obfuscated Hello World - 172 bytes

#+++++++++[>++++++++<-]>o<++++[>+++++++<-]>+o+++++++oo+++o>++++[>+++++++++++<-]>o------------o[-]++++++++[>+++++++++++<-]>-o<<<o+++o------o--------o[-]+++[>+++++++++++<-]>o

Uses its inherent similarity to brainfuck. Meets rules #1 and #3

5. Sing Happy Birthday to your favourite programming language - 328 bytes

$72o97o112o112o121o32o66o105o114o116o104o100o97o121o32o116o111o32o89o111o117o10o72o97o112o112o121o32o66o105o114o116o104o100o97o121o32o116o111o32o89o111o117o10o72o97o112o112o121o32o66o105o114o116o104o100o97o121o32o68o101o97o114o32o66o117o103o108o101o10o72o97o112o112o121o32o66o105o114o116o104o100o97o121o32o116o111o32o89o111o117o

All the challenges have this kind of structure, at the moment.

6. We're no strangers to code golf, you know the rules, and so do I - 6893 bytes

$87o101o39o114o101o32o110o111o32o115o116o114o97o110o103o101o114o115o32o116o111o32o108o111o118o101o10o89o111o117o32o107o110o111o119o32o116o104o101o32o114o117o108o101o115o32o97o110o100o32o115o111o32o100o111o32o73o10o65o32o102o117o108o108o32o99o111o109o109o105o116o109o101o110o116o39o115o32o119o104o97o116o32o73o39o109o32o116o104o105o110o107o105o110o103o32o111o102o10o89o111o117o32o119o111o117o108o100o110o39o116o32o103o101o116o32o116o104o105o115o32o102o114o111o109o32o97o110o121o32o111o116o104o101o114o32o103o117o121o10o73o32o106o117o115o116o32o119o97o110o110o97o32o116o101o108o108o32o121o111o117o32o104o111o119o32o73o39o109o32o102o101o101o108o105o110o103o10o71o111o116o116o97o32o109o97o107o101o32o121o111o117o32o117o110o100o101o114o115o116o97o110o100o10o32o10o78o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o32o121o111o117o32o117o112o10o78o101o118o101o114o32o103o111o110o110o97o32o108o101o116o32o121o111o117o32o100o111o119o110o10o78o101o118o101o114o32o103o111o110o110o97o32o114o117o110o32o97o114o111o117o110o100o32o97o110o100o32o100o101o115o101o114o116o32o121o111o117o10o78o101o118o101o114o32o103o111o110o110o97o32o109o97o107o101o32o121o111o117o32o99o114o121o10o78o101o118o101o114o32o103o111o110o110o97o32o115o97o121o32o103o111o111o100o98o121o101o10o78o101o118o101o114o32o103o111o110o110o97o32o116o101o108o108o32o97o32o108o105o101o32o97o110o100o32o104o117o114o116o32o121o111o117o10o32o10o87o101o39o118o101o32o107o110o111o119o110o32o101o97o99o104o32o111o116o104o101o114o32o102o111o114o32o115o111o32o108o111o110o103o10o89o111o117o114o32o104o101o97o114o116o39o115o32o98o101o101o110o32o97o99o104o105o110o103o32o98o117o116o10o89o111o117o39o114o101o32o116o111o111o32o115o104o121o32o116o111o32o115o97o121o32o105o116o10o73o110o115o105o100o101o32o119o101o32o98o111o116o104o32o107o110o111o119o32o119o104o97o116o39o115o32o98o101o101o110o32o103o111o105o110o103o32o111o110o10o87o101o32o107o110o111o119o32o116o104o101o32o103o97o109o101o32o97o110o100o32o119o101o39o114o101o32o103o111o110o110o97o32o112o108o97o121o32o105o116o10o65o110o100o32o105o102o32o121o111o117o32o97o115o107o32o109o101o32o104o111o119o32o73o39o109o32o102o101o101o108o105o110o103o10o68o111o110o39o116o32o116o101o108o108o32o109o101o32o121o111o117o39o114o101o32o116o111o111o32o98o108o105o110o100o32o116o111o32o115o101o101o10o32o10o78o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o32o121o111o117o32o117o112o10o78o101o118o101o114o32o103o111o110o110o97o32o108o101o116o32o121o111o117o32o100o111o119o110o10o78o101o118o101o114o32o103o111o110o110o97o32o114o117o110o32o97o114o111o117o110o100o32o97o110o100o32o100o101o115o101o114o116o32o121o111o117o10o78o101o118o101o114o32o103o111o110o110o97o32o109o97o107o101o32o121o111o117o32o99o114o121o10o78o101o118o101o114o32o103o111o110o110o97o32o115o97o121o32o103o111o111o100o98o121o101o10o78o101o118o101o114o32o103o111o110o110o97o32o116o101o108o108o32o97o32o108o105o101o32o97o110o100o32o104o117o114o116o32o121o111o117o10o32o10o78o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o32o121o111o117o32o117o112o10o78o101o118o101o114o32o103o111o110o110o97o32o108o101o116o32o121o111o117o32o100o111o119o110o10o78o101o118o101o114o32o103o111o110o110o97o32o114o117o110o32o97o114o111o117o110o100o32o97o110o100o32o100o101o115o101o114o116o32o121o111o117o10o78o101o118o101o114o32o103o111o110o110o97o32o109o97o107o101o32o121o111o117o32o99o114o121o10o78o101o118o101o114o32o103o111o110o110o97o32o115o97o121o32o103o111o111o100o98o121o101o10o78o101o118o101o114o32o103o111o110o110o97o32o116o101o108o108o32o97o32o108o105o101o32o97o110o100o32o104o117o114o116o32o121o111o117o10o32o10o40o79o111o104o44o32o103o105o118o101o32o121o111o117o32o117o112o41o10o40o79o111o104o44o32o103o105o118o101o32o121o111o117o32o117o112o41o10o40o79o111o104o41o10o78o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o44o32o110o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o10o40o71o105o118o101o32o121o111o117o32o117o112o41o10o40o79o111o104o41o10o78o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o44o32o110o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o10o40o71o105o118o101o32o121o111o117o32o117o112o41o10o32o10o87o101o39o118o101o32o107o110o111o119o32o101o97o99o104o32o111o116o104o101o114o32o102o111o114o32o115o111o32o108o111o110o103o10o89o111o117o114o32o104o101o97o114o116o39o115o32o98o101o101o110o32o97o99o104o105o110o103o32o98o117o116o10o89o111o117o39o114o101o32o116o111o111o32o115o104o121o32o116o111o32o115o97o121o32o105o116o10o73o110o115o105o100o101o32o119o101o32o98o111o116o104o32o107o110o111o119o32o119o104o97o116o39o115o32o98o101o101o110o32o103o111o105o110o103o32o111o110o10o87o101o32o107o110o111o119o32o116o104o101o32o103o97o109o101o32o97o110o100o32o119o101o39o114o101o32o103o111o110o110o97o32o112o108o97o121o32o105o116o10o32o10o73o32o106o117o115o116o32o119o97o110o110o97o32o116o101o108o108o32o121o111o117o32o104o111o119o32o73o39o109o32o102o101o101o108o105o110o103o10o71o111o116o116o97o32o109o97o107o101o32o121o111o117o32o117o110o100o101o114o115o116o97o110o100o10o32o10o78o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o32o121o111o117o32o117o112o10o78o101o118o101o114o32o103o111o110o110o97o32o108o101o116o32o121o111o117o32o100o111o119o110o10o78o101o118o101o114o32o103o111o110o110o97o32o114o117o110o32o97o114o111o117o110o100o32o97o110o100o32o100o101o115o101o114o116o32o121o111o117o10o78o101o118o101o114o32o103o111o110o110o97o32o109o97o107o101o32o121o111o117o32o99o114o121o10o78o101o118o101o114o32o103o111o110o110o97o32o115o97o121o32o103o111o111o100o98o121o101o10o78o101o118o101o114o32o103o111o110o110o97o32o116o101o108o108o32o97o32o108o105o101o32o97o110o100o32o104o117o114o116o32o121o111o117o10o32o10o78o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o32o121o111o117o32o117o112o10o78o101o118o101o114o32o103o111o110o110o97o32o108o101o116o32o121o111o117o32o100o111o119o110o10o78o101o118o101o114o32o103o111o110o110o97o32o114o117o110o32o97o114o111o117o110o100o32o97o110o100o32o100o101o115o101o114o116o32o121o111o117o10o78o101o118o101o114o32o103o111o110o110o97o32o109o97o107o101o32o121o111o117o32o99o114o121o10o78o101o118o101o114o32o103o111o110o110o97o32o115o97o121o32o103o111o111o100o98o121o101o10o78o101o118o101o114o32o103o111o110o110o97o32o116o101o108o108o32o97o32o108o105o101o32o97o110o100o32o104o117o114o116o32o121o111o117o10o32o10o78o101o118o101o114o32o103o111o110o110o97o32o103o105o118o101o32o121o111o117o32o117o112o10o78o101o118o101o114o32o103o111o110o110o97o32o108o101o116o32o121o111o117o32o100o111o119o110o10o78o101o118o101o114o32o103o111o110o110o97o32o114o117o110o32o97o114o111o117o110o100o32o97o110o100o32o100o101o115o101o114o116o32o121o111o117o10o78o101o118o101o114o32o103o111o110o110o97o32o109o97o107o101o32o121o111o117o32o99o114o121o10o78o101o118o101o114o32o103o111o110o110o97o32o115o97o121o32o103o111o111o100o98o121o101o10o78o101o118o101o114o32o103o111o110o110o97o32o116o101o108o108o32o97o32o108o105o101o32o97o110o100o32o104o117o114o116o32o121o111o117o

7. Output the sign - 18 bytes

$?:Zs0=0s-s:1s-++O

Checks if the input is greater than zero, less than zero (changed to yield -1 instead of 1) and equal to zero, before taking their sum.

8. Collatz Conjecture (OEIS A006577) - 36 bytes

#$?:1-[:2s%{3×1+}2s÷]:1s-₀+₁]₀O

This performs the looping on the stack, but switches over to the tape to increment the count each iteration.

9. An Array of Challenges #1: Alternating Arrays - 35 bytes

#?>?>+>?[[<+<<->>>-]+<[-<<]>[>]?]<O

This is a slight modification of Mitch Schwartz's answer to the existing challenge, go upvote that!

10. Am I an insignificant array? - 46 bytes

$1 0-?…1[s:sr-:Z1s-2×1+×1s-Z1-L2s-×]1+Z1-O

All credit goes to Emigna for making this

11. Is this number a prime? - 31 bytes

$?:1s-:[:1s-:];L1s[×L2s-]:×%O

Uses Wilson's Theorem and calculates (n-1)!² % n

12. I'm a palindrome. Are you? - 13 bytes

$?:R=:O:=R:?$

The first half of the program, up to O, sets the stack up as [x, x] where x is either True or False. O pops the top value and outputs it. The rest of the program just makes sure that no errors are produced. Luckily, when ? encounters the end of the file, it just pushes '' (the empty string).

13. Sum the numbers on standard in - 19 bytes

$?:[?:];L0s[+L1s-]O

This can be split into two parts: ?:[?:]; and L0s[+L1s-]. The first part collects all input to the stack. The second part pushes the sum of the top two elements, while the length is greater than 1.

14. Find the Factorial - 25 bytes

$?:[:1s-:];L1s-Z[×L1s-]O

This has a similar structure to the sum program, but instead of pushing ltiple inputs, the [:1s-:]; pushes the range from 1 .. n to the stack, and [×L1s-] takes the product.

15. Shortest code to produce infinite output - 5 bytes

#+[O]

Use a while loop, with the 1 continually under the pointer. Outputs 1 forever.

16. Bake a slice of Pi - 439 bytes

$40o41o40o41o40o41o40o41o40o41o40o41o10o124o92o51o46o49o52o49o53o57o50o54o124o10o124o58o92o53o51o53o56o57o55o57o51o124o10o92o58o58o92o50o51o56o52o54o50o54o124o10o32o92o58o58o92o52o51o51o56o51o50o124o10o32o32o92o58o58o92o55o57o53o48o50o124o10o32o32o32o92o58o58o92o56o56o52o49o124o10o32o32o32o32o92o58o58o92o57o55o49o124o10o32o32o32o32o32o92o58o58o92o54o57o124o10o32o32o32o32o32o32o92o58o58o92o51o124o10o32o32o32o32o32o32o32o92o95o95o92o124o

17. Find the smallest number that doesn't divide N

$?:1:[:rs%0=s1+srr:Rs]1s-O

This uses trial division, terminating when the result of the modulo does not equal 0.

18. Is this even or odd? - 5 bytes

$2?%O

Simple modulo by 2

19. Output with the same length as the code - 16 bytes

$16:[32+:o33s-:]

Outputs the first 16 printable ASCII characters in reverse: 0/.-,+*)('&%$#"!

20. Golf you a quine for great good!

$1[93, 76, 111, 91, 49, 59, 104, 48, 79, 49, 111, 54, 51, 0]
36o1O0h;1[oL]

Credit goes to user202729 for making this


Language specification

Calling

bugle.py currently takes a series of flags, then the file name / code to be executed. As of yet, it has 4 command line flags:

  • -f/--file specifies that code is to be read from a file
  • -c/--cmd/--cmdline specifies that code is supplied via the command line.

    -c and -f cannot be used in the same call

  • -u/--unicode tells the interpreter to read the code with the Unicode encoding. The default is to use Bugle's encoding below

  • -l/--length outputs the length of the file, in bytes, to STDERR after execution

The following call was used to test the above submissions

$ python bugle.py -f -u [file]

Code page

Bugle uses 512 characters in its code page. The 0xFF character is not to be used for a command, as its used to indicate that the next hex value in to index into the second half of the code page. The characters used are:

ÀÁÂÄÆÃÅĀĄ\t\nĆČÇĎÐ
ÈÉÊËĒĖĚĘÌÍÎÏĪĮĹĽ
 !"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~¶
ŁŃŇÑŊÒÓÔÖŒÕØŌŔŘŚ
ŠŤŦÙÚÛÜŮŪŴÝŶŸŹŽŻ
àáâäæãåāąćčçďðèé
êëēėěęìíîïīįĺľłń
ňñŋòóôöœøōõŕřßśš
ťŧùúûüůūŵýŷÿźžż◊
ΑΆΒΓΔΕΈΖΗΉΘΙΊΚΛΜ
ΝΞΟΌΠΡΣΤΥΎΦΧΨΩΏ
αάβγδεέζηήθιίΐκλ
μνξοόπσςτυύΰφχψω
ώǴḰḾṔẂǵḱḿṕẃḂḞĠḢṀ
ȮṖṠṪẊḃḟġḣṁȯṗṡṫẋ§
ĂĞĬŎŬĴăğĭŏŭĵªº‹›
ƁƇƊƑƓƘⱮƝƤƬƲȤɓƈɗƒ
ɠɦƙɱɲƥʠɼʂƭʋȥ©®ıȷ
ЉЊЕРТЗУИОПШАСДФГ
ХЈКЛЧЋЅЏЦВБНМЂЖљ
њертзуиопшасдфгх
јклчћѕџцвбнмђжÞþ
†∂∆≈≠√∈∉∌∋∩∪¬∧∨⊕
¤₽¥£¢€₩‰¿¡⁇⁈‼⁉‽⸘
…°•”“„’‘≤«·»≥ᴇ∞¦
×⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾
÷₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎

Or see it in table format. Note that \t and \n represent tab and newline respectively. Also take note that the 16th line ends with an unprintable character: , and may not be displayed on all browsers.

Memory

The interpreter currently has 5 memory models built in to it. Each memory model requires a character to tell the interpreter to begin using that model:

  • Stack ($): a standard stack, which supports values being pushed, popped etc.
  • Infinite tape (#): A tape, à la brainfuck, which initially is only 0s.
  • Infinite grid (G): A 2d grid, infinite in both directions, containing only 0s
  • Deque (D): A deque, as implemented by the collections module.
  • Register (S): A single value, which can be used to store one value.

The grid also has a single value saved in its pointer that can be written to, or write to cells.

In addition, tape and grid sizes and wrapping behaviour can be modified, by using a different invoke command. These different commands take a given number of values from the current memory model as customisation parameters:

  • Tape (À): Takes two values - size (int) and wrapping (bool)
  • Tape (Á): Takes one value - size (int). Wraps at end of the tape
  • Tape (Â): Takes one value - size (int). Doesn't wrap at the end
  • Grid (Ǵ): Takes 4 values - x size (int), y size (int), x wrap (bool) and y wrap (bool)

The memory type being used can change during a program by the use of ₀₁₂₃₄₅₆₇₈₉, which access the 0-indexed nth used memory type ( is the first, is the second etc.), but, currently, values cannot be swapped between different memory types.

Branching

So far Bugle has two branching commands, both terminated with a ] character:

  • While ([): brainfuck-style while loops. These pop a value from the stack/deque if being used, or access the cell under the pointer in tape/grid.

    Example: #?[-O] counts from the input down to 0

  • If/else ({ and }). Single execution while loops. If the value popped is false, then the if clause is skipped, going to the else clause, separated by }. They behave the same way as while loops regarding memory access.

    Example: {0}1] is a logical NOT gate

Builtin functions

Runs of digits are interpreted as integers, and are just pushed/written to the current memory model as is.

Obviously, I've equipped Bugle with some basic builtin functions, as few as I could, to allow others to add more as the chain progresses. The base commands are as follows:

  • +

    • Stack/Deque: Add the top two values
    • Tape/Grid: Increment the current cell
  • -

    • Stack/Deque: Subtract the top two values
    • Tape/Grid: Decrement the current cell
  • %

    • Stack/Deque: Modulo the top two values
  • :

    • Stack/Deque: Duplicate the top value
  • ;

    • Stack/Deque: Pop the top value
    • Tape/Grid: Zero the current cell
  • <

    • Tape/Grid: Move left one cell
  • =

    • Stack: Are the top two values equal?
    • Grid: Move down one cell
  • >

    • Tape/Grid: Move right one cell
  • ?

    • Stack/Deque: Evaluate a line of input
    • Tape/Grid: Take a character of input
  • L

    • Stack/Deque: Push the length of the stack/deque
  • O

    • All: Output the current value
  • R

    • Stack: Reverse the top element if possible, else reverse the stack
  • Z

    • Stack: Top element is positive?
  • ^

    • Grid: Move up one cell
  • h

    • All: Print the full memory model
  • o

    • All: Print the current value as a character
  • r

    • Stack: Rotate the top 3 values
    • Deque: Rotate the deque n times, where n is the top value
  • s

    • Stack/Deque: Swap the top two values
    • Stack: Splat the top value
  • ×

    • Stack: Multiply the top two values
    • Grid: Write the pointer value to the current cell
  • ÷

    • Stack: Divide the top two values
    • Grid: Write the current cell to the pointer value
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.