Skip to content

Instantly share code, notes, and snippets.

@alexgenco
Created June 15, 2011 04:39
Show Gist options
  • Select an option

  • Save alexgenco/1026493 to your computer and use it in GitHub Desktop.

Select an option

Save alexgenco/1026493 to your computer and use it in GitHub Desktop.
Project Euler #8 in Python
# the problem asks for the largest product of 5 consecutive numbers in a 1000 digit number.
# something tells me this could be even more succinct, maybe with just one list comprehension
number = [ int(x) for x in list("73167 ... 63450") ]
print max([ number[i] * number[i+1] * number[i+2] * number[i+3] * number[i+4] for i in range(len(number)-4) ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment