Moderators: jestingrabbit, Prelates, Moderators General
f,m,a,g,h=lambda n:int(n<2)or m.get(n)or m.update({n:f(n-1)+f(n-2)})or m.get(n),{},input(),lambda a,l:filter(lambda i:h(a,i,l),l),lambda a,i,l:a==f(i)and i or g(a-f(i),l-set([i,i-1,i+1]))
print g(a,set(filter(lambda x:f(x)<=a,range(1,a))))
Traceback (most recent call last):
File "<pyshell#37>", line 1, in <module>
f,m,a,g,h=lambda n:int(n<2)or m.get(n)or m.update({n:f(n-1)+f(n-2)})or m.get(n),{},input(),lambda a,l:filter(lambda i:h(a,i,l),l),lambda a,i,l:a==f(i)and i or g(a-f(i),l-set([i,i-1,i+1]))
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
def zeck(n):
n=int(n)
#Create reverse Fibonacci sequence of more than what we need...
a=range(2*len(bin(n)),0,-1)
for i in range(len(a)-3,-1,-1):
a[i]=a[i+1]+a[i+2]
#Find the starting point
for i in range(len(a)):
if a[i]<=n:
break
#Initiate total as a "counter" of sorts and retval as a return string
total = 0
retval = ''
while i < len(a):
if(total+a[i]<=n):
total += a[i]
if(i == len(a)-1):
retval += '1'
else:
retval += '10'
#add one to skip the next number in the sequence
i+=1
else:
retval+='0'
i+=1
return retval
def reverse_zeck(n):
n=str(n)
a=range(len(n),0,-1)
for i in range(len(a)-3,-1,-1):
a[i]=a[i+1]+a[i+2]
total=0
for i in range(len(n)):
if(n[i]=='1'):
total += a[i]
elif(n[i] != '0'):
raise Exception("Invalid String")
return total
a=range(2*len(bin(n)),0,-1)
Users browsing this forum: Neil_Boekend and 3 guests