Saturday, March 16, 2002

Nine 9's Puzzle

On ITASoftware's website they put up a little puzzle called Nine 9's. I spent the evening solving it and have put up the results

You can download the source here.

The puzzle:
Combining nine 9s with any number of the operators +, -, *, /, (, ) , what is the smallest positive integer that cannot be expressed?
Hints:

1) The answer isn't zero. You can express zero like this: (9 - 9)(9 + 9 + 9 + 9 + 9 + 9 + 9)
Also, zero isn't a positive integer.

2) The answer isn't one. You can express one like this: 9 - (99 - 9)/9 + 9 - 9 + 9 - 9

3) It's not a trick question.

4) Be sure to handle parentheses correctly.

Notes:
You cannot exponentiate.
You cannot concatenate (for example, put two 9s together to make 99).
The - operator can be used in either its binary or unary form.
Assume base 10.

Popular Posts