Skip to content

Instantly share code, notes, and snippets.

@epoch
Created July 7, 2014 23:16
Show Gist options
  • Select an option

  • Save epoch/c4dbb929688cac02099d to your computer and use it in GitHub Desktop.

Select an option

Save epoch/c4dbb929688cac02099d to your computer and use it in GitHub Desktop.
Say Magnitudes

Say Magnitudes

Write a program that will take a number from 0 to 999,999,999,999 and break it into chunks, adding the magnitude.

In other words, if the input to the program is 1234567890 then the output should be '1 billion 234 million 567 thousand 890'

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

Extensions

If you solved the chunking using math, solve it again using strings.

If you solved it using strings, solve it using math.

If you solved it using strings by reversing it, solve it again by padding the string. And the inverse.

Refactor!

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