Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created January 13, 2015 11:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trikitrok/6d9f0219f9f3d84476d8 to your computer and use it in GitHub Desktop.
Save trikitrok/6d9f0219f9f3d84476d8 to your computer and use it in GitHub Desktop.

Reverse Polish Notation calculator kata

Useful info:

Reverse Polish Notation algorithm explanation

Online Reverse Polish Notation Calculator to check your results.

Examples:

"0" => 0
"1" => 1
"0 1 +" => 1
"1 2 5 + +" => 8
"0 1 -" => -1
"1 2 5 - -" => 4
"0 1 *" => 0
"1 2 5 * *" => 10
"4 2 /" => 2
"10 5 5 / /" => 10
"4 2 / 5 + 10 * 5 6 - +" => 69
"3 2 1 + *" => 9
"1 2 + 4 * 5 + 3 -" => 14
"5 1 2 + 4 * + 3 -" => 14
"0 1 - 4 5 * *" => -20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment