all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,26 @@
>>> from itertools import permutations
>>> def f1(p):
i, p0 = 0, p[0]
while p0:
i += 1
p0 += 1
p[:p0] = p[:p0][::-1]
p0 = p[0]
return i
>>> def fannkuch(n):
return max(f1(list(p)) for p in permutations(range(n)))
>>> for n in range(1, 11): print(n,fannkuch(n))
1 0
2 1
3 2
4 4
5 7
6 10
7 16
8 22
9 30
10 38
>>>