The task is simple. Write an interpreter for the language *.

Here's a bigger link to the wiki.

There are only three valid * programs:

  • * Prints "Hello World"
  •  *  Prints a random number between 0 and 2,147,483,647
  • *+* Runs forever.

The third case must be an infinite loop according to the specifications in this question


  • The input can be taken via any acceptable input method by our standard I/O rules
  • It will always be one of the above programs


  • The first case should print exactly Hello World, with or without a trailing line break.
  • For the second case, if your language's integer maximum is smaller than 2,147,483,647, use your language's integer maximum
  • The first and second cases can print to any acceptable output by our standard I/O rules.
  • The third case should not give any output.


As this is , the shortest answer, in bytes, wins.

  • 7
    \$\begingroup\$ When you say 'between 0 and 2,147,483,647', is that inclusive or exclusive? (E.g., is 0 a valid output?) \$\endgroup\$
    – Chas Brown
    Commented Aug 9, 2019 at 21:46
  • 7
    \$\begingroup\$ Changing the spec after posting a challenge and invalidating existing solutions is an automatic -1 from me. \$\endgroup\$
    – Shaggy
    Commented Aug 10, 2019 at 7:00
  • 2
    \$\begingroup\$ For languages that don't have a built-in way of generating a random number, is there an acceptable way to satisfy the "print a random number" requirement? \$\endgroup\$ Commented Aug 10, 2019 at 22:44
  • 2
    \$\begingroup\$ If our language's integers have no, or a higher, maximum may we use a higher upper bound? \$\endgroup\$ Commented Aug 10, 2019 at 23:43
  • 8
    \$\begingroup\$ @Shaggy I'm not seeing any rule changes in the wiki for the question, only a space to a non-breaking space (check the markdown tab), because the SE markdown renderer wasn't rendering it, but looking at the original revisision, it's clear it should be normal spaces, and the "hack' is only done for SE markdown renderer issues \$\endgroup\$
    – Ferrybig
    Commented Aug 11, 2019 at 20:49

35 Answers 35


Wren, 143 135 bytes

I am not a good golfer... The RNG generates the same value each time because it is a pseudo-random number generator.

import"random"for Random
}else System.write(a[0]==" "?Random.new(9).int((1<<31)-1):"Hello World")

Try it online!


Kotlin, 78 bytes

"Hello World"})}

Try it online!


VBScript, 147 bytes

Sub m(s)
if s="*" then msgbox "Hello World"
if s=" * " then msgbox int(2147483647*Rnd)
if s="*+*" then
loop while 1
end if
end sub

Crystal, 75 bytes

puts case gets;when"*";"Hello World"when/\+/;loop{}else;rand 2147483647;end

Try it online!


05AB1E, 21 bytes


Try it online! * times out on TIO as the code generates the list [1, 2, 3, ..., 2147483648], subtracts 1 from each element, and picks a random element from the list. This is required as the only sources of randomness in 05AB1E are Ω/.R (random pick) and .r (random shuffle), but no pure RNGs.

['*›_#}gi„Ÿ™‚ï™ëžIL<Ω  # full program
     #                 # break out of...
[                      # infinite loop...
     #                 # if...
                       # implicit input...
   ›                   # does...
    _                  # not...
   ›                   # come after...
 '*                    # literal...
   ›                   # in lexicographical order
      }                # end infinite loop
        i              # if...
       g               # length of...
                       # implicit input...
        i              # is 1...
         „Ÿ™‚ï         # then push "hello world"...
              ™        # in title case
               ë       # else...
                    Ω  # pick a random element from...
                  L    # [1, 2, 3, ...,
                žI     # ..., 2147483648]...
                       # (implicit) with each element...
                   <   # decremented
                       # implicit output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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