Thursday, December 12, 2013

Google Code Jam: Old Magician

Disclaimer: I'm not a computer scientist, neither a mathematician, so the code I'm going to post here is probably quite ugly and not optimized. Any suggestion for improvements is welcome!
Just for fun I have decided to try solving some algorithmic puzzles from the Google Code Jam competition. I'm solving them in Python and I'm not setting any time limit for writing the solution (However I'll try to keep the execution time limit at 4 minutes for a small set and 8 minutes for the large one).

The first puzzle I solved is the Old Magician. This is a quite simple one and here is my code:
The "core" part of the program reads the number of the Black balls and if it's odd it means that the remaining ball must be Black. That's all :)
Next up, my solution for the Square Fields problem.

No comments: