Skip to content

Instantly share code, notes, and snippets.

@mrklein
Created May 18, 2012 23:56
Show Gist options
  • Save mrklein/2728230 to your computer and use it in GitHub Desktop.
Save mrklein/2728230 to your computer and use it in GitHub Desktop.
Project Euler #43
#!/usr/bin/env python
from libeuler import str_permutations
if __name__ == '__main__':
nums = str_permutations('0123456789')
r = []
for n in nums:
n1 = int(n[1:4])
n2 = int(n[2:5])
n3 = int(n[3:6])
n4 = int(n[4:7])
n5 = int(n[5:8])
n6 = int(n[6:9])
n7 = int(n[7:10])
if n1 % 2 == 0 and \
n2 % 3 == 0 and \
n3 % 5 == 0 and \
n4 % 7 == 0 and \
n5 % 11 == 0 and \
n6 % 13 == 0 and \
n7 % 17 == 0:
print n
r += [int(n)]
print sum(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment