Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -1,15 +1,15 @@
|
|||
>>> from itertools import permutations
|
||||
>>> def f1(p):
|
||||
i, p0 = 0, p[0]
|
||||
while p0:
|
||||
i += 1
|
||||
p0 += 1
|
||||
p[:p0] = p[:p0][::-1]
|
||||
i = 0
|
||||
while True:
|
||||
p0 = p[0]
|
||||
if p0 == 1: break
|
||||
p[:p0] = p[:p0][::-1]
|
||||
i += 1
|
||||
return i
|
||||
|
||||
>>> def fannkuch(n):
|
||||
return max(f1(list(p)) for p in permutations(range(n)))
|
||||
return max(f1(list(p)) for p in permutations(range(1, n+1)))
|
||||
|
||||
>>> for n in range(1, 11): print(n,fannkuch(n))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue