8 kyu

8kyu interpreters: HQ9+

3,624 of 11,882Voile

Description:

You task is to implement an simple interpreter for the notorious esoteric language HQ9+ that will work for a single character input:

  • If the input is 'H', return 'Hello World!'
  • If the input is 'Q', return the input
  • If the input is '9', return the full lyrics of 99 Bottles of Beer. It should be formatted like this:
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.
...
...
...
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
  • For everything else, don't return anything (return null in C#, None in Rust, and "" in Haskell).

(+ has no visible effects so we can safely ignore it.)

Fundamentals

Stats:

CreatedMay 12, 2017
PublishedMay 12, 2017
Warriors Trained21619
Total Skips1057
Total Code Submissions42400
Total Times Completed11882
JavaScript Completions3845
Python Completions3624
Ruby Completions317
Crystal Completions22
C# Completions1029
PHP Completions687
Rust Completions558
Java Completions2007
Haskell Completions178
R Completions102
Lua Completions16
Total Stars184
% of votes with a positive feedback rating66% of 2123
Total "Very Satisfied" Votes1173
Total "Somewhat Satisfied" Votes442
Total "Not Satisfied" Votes508
Total Rank Assessments69
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Voile Avatar
  • GiacomoSorbi Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • SandQueen Avatar
  • Souzooka Avatar
  • AndyT94 Avatar
  • hobovsky Avatar
  • rodriguini Avatar
  • user8436785 Avatar
  • BobtheLantern Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
  • PetitLu117 Avatar
Ad