HQ9+


HQ9+ is an esoteric programming language with 4 instructions:

  • H: Prints “Hello World”
  • Q: Prints the program’s source code (quine)
  • 9: Prints the lyrics to “99 Bottles of Beer”
  • +: Increments the accumulator (define the accumulator as 0 at the start of the program)

Any character that is not ‘H’, ‘Q’, ‘9’ or ‘+’ is treated as a comment by HQ9+. Those instructions can be written like so: ‘H9/Q’ (which would print “Hello World”, then the lyrics to “99 Bottles of Beer”, ignore the ‘/’ as it is a comment, and then print the program’s source code – H9/Q).

A interpreter is a program that executes a programming language. Write an interpreter for HQ9+ and show what “H+9JQ29H39+Q” produces when used as input to the interpreter.

Remember, to solve this puzzle and appear on the leaderboard, email both your solution and your source code (in any language) to lewiscornwall13@gmail.com. Good luck!!

View all puzzles »

Advertisements