Skip to content

Instantly share code, notes, and snippets.

@jhickner
Created June 14, 2011 22:37
Show Gist options
  • Save jhickner/1026110 to your computer and use it in GitHub Desktop.
Save jhickner/1026110 to your computer and use it in GitHub Desktop.
a = "2298163507642079319714044011236386616537514556458624876361063538594523631728704374833046762730571781372667347996722877761242458964516235987144911867899093570411259125272325950690385718016406645948728247900092493610635939061585125579278248678382561153927262068997135688096479833275438059003000577156030985752302737572142995389102392941277376055589936729467932043612276625158946842268530893693249010877756556663809256430403075836704397788157103267683082146557414910592210694688897583745853279150372366550265606245942901619641524394840947123797093291647952437507481770581519782926025000309975240809176732086412721877283182868239907386563436552684713604652833551208756316179487399401951895977814655415305700855625446129108900687384799001387951671104621436799720362491054813946856845126233235524710982837568591533011593761372364447069814628293634127437282262501219295880363659562599465416237996647317561877859528573985271179776400465798163016446475504146022123819119158936569549701762530276146646914630937941723419963811828693735274888334852800116766879328915880099767105948195091109555590581643322251908783026670007080972249010100892419108486345305849353679974424946961324819560021379840782224833262895740825258961195814695840112138347952831118547888120194142040782810626793593"
iSize = 1
def find_sums(idx, p):
count = 1
tmp = 0
while True:
if idx > len(a)-1:
return -1
c = tmp + int(a[idx])
if c > p:
return -1
elif c == p:
count += 1
if idx == len(a)-1:
return count
tmp = 0
else:
tmp = c
idx += 1
while iSize <= len(a):
p = sum([int(i) for i in a[0:iSize]])
res = find_sums(iSize, p)
if res != -1:
print p, res
break
else:
iSize += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment