Skip to content

Instantly share code, notes, and snippets.

@ffbit
Created September 2, 2012 11:38
Show Gist options
  • Select an option

  • Save ffbit/3597429 to your computer and use it in GitHub Desktop.

Select an option

Save ffbit/3597429 to your computer and use it in GitHub Desktop.
100 dwarfs and candles
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