Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
F circle_sort_backend(&A, Int l, r)
|
||||
V n = r - l
|
||||
I n < 2
|
||||
R 0
|
||||
V swaps = 0
|
||||
V m = n I/ 2
|
||||
L(i) 0 .< m
|
||||
I A[r - (i + 1)] < A[l + i]
|
||||
swap(&A[r - (i + 1)], &A[l + i])
|
||||
swaps++
|
||||
I (n [&] 1) != 0 & (A[l + m] < A[l + m - 1])
|
||||
swap(&A[l + m - 1], &A[l + m])
|
||||
swaps++
|
||||
R swaps + circle_sort_backend(&A, l, l + m) + circle_sort_backend(&A, l + m, r)
|
||||
|
||||
F circle_sort(&l)
|
||||
V swaps = 0
|
||||
V s = 1
|
||||
L s != 0
|
||||
s = circle_sort_backend(&l, 0, l.len)
|
||||
swaps += s
|
||||
R swaps
|
||||
|
||||
L(i) 309
|
||||
V l = Array(0 .< i)
|
||||
V m = copy(l)
|
||||
random:shuffle(&l)
|
||||
V n = copy(l)
|
||||
circle_sort(&l)
|
||||
I l != m
|
||||
print(l.len)
|
||||
print(n)
|
||||
print(l)
|
||||
Loading…
Add table
Add a link
Reference in a new issue