Created
September 2, 2012 11:38
-
-
Save ffbit/3597429 to your computer and use it in GitHub Desktop.
100 dwarfs and candles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n = 100 | |
| candles = [False] * n | |
| offset = 1 | |
| for dwarf in xrange(n): | |
| dwarf_num = dwarf + offset | |
| for candle in xrange(n): | |
| candle_num = candle + offset | |
| if not candle_num % dwarf_num: | |
| candles[candle] = not candles[candle] | |
| for idx, value in enumerate(candles): | |
| if value: | |
| print idx + offset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment