Hacker News new | past | comments | ask | show | jobs | submit login

The base conversion insight is annoying; they mandate the form of the input in detail down to individual characters and mandate that you can't use numeric methods, except that in this one situation you can completely control the input and do so in a numeric way. You can't change programming language after starting, but you can change the input format on-demand? If you can choose an arbitrary input pre-processor, just choose that the input is the desired output and your program can echo it.

By rule 7: "Numeric types, number literals and their associated methods and operations are forbidden. The input array must contain a string representations of the numbers. The programmer can use whatever representation they see fit with the only restriction being that it could only contain letters, numbers and symbols that could be typed with a single stroke (they didn’t specify which keyboard layout, in mine, ñ and ç can be typed with a single stroke but I assumed it was an US keyboard). The max length of a string representing a number is 6 characters."

The numbers they care about are 1 - 1000 and the max length is 6 that leaves two spare digits, so decide that the input format is "tf0000" where the first two characters indicate if the number is a multiple of three, or five, respectively.






Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: