Skip to content

Instantly share code, notes, and snippets.

@ga-wolf
Created July 1, 2015 22:59
Show Gist options
  • Save ga-wolf/84b8b172e7fe6e3abce9 to your computer and use it in GitHub Desktop.
Save ga-wolf/84b8b172e7fe6e3abce9 to your computer and use it in GitHub Desktop.
Final Word Calculator

Wordy Arithmetic Chains

Write a program that takes word problems in the format:

What is 5 plus 13?

What is 7 minus 5?

What is 6 times 4?

What is 25 divided by 5?

What is 78 plus 5 minus 3?

What is 18 times 3 plus 16?

What is 4 times 3 divided by 6?

What is 4 plus 3 times 2?

and returns the answer as an integer.

It should be able to handle any combination of all four basic arithmetic operations.

Use the tests to drive your solution by deleting the skip in one test at a time.

Extensions

Implement questions of the type:

What is 2 raised to the 5th power?

Remember to write failing tests for this code.

Source

Inspired by one of the generated questions in the Extreme Startup game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment