Skip to content

Instantly share code, notes, and snippets.

@epoch
Created June 16, 2014 23:06
Show Gist options
  • Save epoch/d9119d53b877f60ec955 to your computer and use it in GitHub Desktop.
Save epoch/d9119d53b877f60ec955 to your computer and use it in GitHub Desktop.

Say

Write a program that will take a number from 0 to 99 and spell out that number in English.

In other words, if the input to the program is 22, then the output should be 'twenty-two'

e.g.

Say.new(22).in_english
Say.new(-1).in_english
# say.rb:7:in 'in_english': Number must be between 0 and 99, inclusive. (ArgumentError)

The program must also report any values that are out of range.

Some good test cases for this program are:

  • 0
  • 14
  • 50
  • 98
  • -1
  • 100

Extensions

Shell out to Mac OS X's program to talk out loud.

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