Skip to content

Instantly share code, notes, and snippets.

@jakedobkin
Created January 4, 2012 20:51
Show Gist options
  • Save jakedobkin/1562076 to your computer and use it in GitHub Desktop.
Save jakedobkin/1562076 to your computer and use it in GitHub Desktop.
Euler 100
# http://projecteuler.net/problem=100
# algabraic rearrangement to 2b**2-2b-t**2+t = 0 (where b is blue balls, t is total balls)
# this is a diophantine equation, which can be solved recursively- to get formulas for next b,t:
# http://www.alpertron.com.ar/QUAD.HTM, put in coeeficients above - got that from Dreamshire
b = 85
t = 120
while t < 10**12:
# i learned that this allows you to set both at once so you don't have to use an intermediate variable
b,t = 3*b + 2*t - 2,4*b + 3*t - 3
print b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment