Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
42
Task/Topswops/11l/topswops.11l
Normal file
42
Task/Topswops/11l/topswops.11l
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
V best = [0] * 16
|
||||
|
||||
F try_swaps(&deck, f, =s, d, n)
|
||||
I d > :best[n]
|
||||
:best[n] = d
|
||||
|
||||
V i = 0
|
||||
V k = 1 << s
|
||||
L s != 0
|
||||
k >>= 1
|
||||
s--
|
||||
I deck[s] == -1 | deck[s] == s
|
||||
L.break
|
||||
i [|]= k
|
||||
I (i [&] f) == i & d + :best[s] <= :best[n]
|
||||
R d
|
||||
s++
|
||||
|
||||
V deck2 = copy(deck)
|
||||
k = 1
|
||||
L(i2) 1 .< s
|
||||
k <<= 1
|
||||
I deck2[i2] == -1
|
||||
I (f [&] k) != 0
|
||||
L.continue
|
||||
E I deck2[i2] != i2
|
||||
L.continue
|
||||
|
||||
deck[i2] = i2
|
||||
L(j) 0 .. i2
|
||||
deck2[j] = deck[i2 - j]
|
||||
try_swaps(&deck2, f [|] k, s, 1 + d, n)
|
||||
|
||||
F topswops(n)
|
||||
:best[n] = 0
|
||||
V deck0 = [-1] * 16
|
||||
deck0[0] = 0
|
||||
try_swaps(&deck0, 1, n, 0, n)
|
||||
R :best[n]
|
||||
|
||||
L(i) 1..12
|
||||
print(‘#2: #.’.format(i, topswops(i)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue