Write a function that, given a dollar amount, would output a textual representation (i.e. $123.43 -> "One hundred twenty three dollars and forty three cents").
Anonymous
I broke the problem down into its constituents. First extracting the ones place, then the tens place, then the hundreds place. Anything beyond that eventually fed into the same algorithm, since the thousands, ten-thousands, and hundred-thousands required the same algorithm but with a different suffix (thousand, instead of hundreds, or no suffix). It boiled down to being sets of three numbers, each with a particular algorithm that defines how to represent the number in a given place. That set of 3 numbers repeated for hundreds, thousands, millions, billions, etc. The same applied to the cents, although it only takes into account the ones and tens places in the algorithm. From that point on it's simple to feed the data into the algorithm, along with the suffix to append, and have it output the appropriate textual representation.
Check out your Company Bowl for anonymous work chats.