Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
39
Task/Best-shuffle/EasyLang/best-shuffle.easy
Normal file
39
Task/Best-shuffle/EasyLang/best-shuffle.easy
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
proc best_shuffle s$ . r$ diff .
|
||||
l = len s$
|
||||
for c$ in strchars s$
|
||||
s[] &= strcode c$
|
||||
.
|
||||
len cnt[] 128
|
||||
for i to l
|
||||
cnt[s[i]] += 1
|
||||
max = higher max cnt[s[i]]
|
||||
.
|
||||
for i to 128
|
||||
while cnt[i] > 0
|
||||
cnt[i] -= 1
|
||||
buf[] &= i
|
||||
.
|
||||
.
|
||||
r[] = s[]
|
||||
for i to l
|
||||
for j to l
|
||||
if r[i] = buf[j]
|
||||
r[i] = buf[(j + max) mod1 l] mod 128
|
||||
if buf[j] <= 128
|
||||
buf[j] += 128
|
||||
.
|
||||
break 1
|
||||
.
|
||||
.
|
||||
.
|
||||
diff = 0
|
||||
r$ = ""
|
||||
for i to l
|
||||
diff += if r[i] = s[i]
|
||||
r$ &= strchar r[i]
|
||||
.
|
||||
.
|
||||
for s$ in [ "abracadabra" "seesaw" "elk" "grrrrrr" "up" "a" ]
|
||||
best_shuffle s$ r$ d
|
||||
print s$ & " " & r$ & " " & d
|
||||
.
|
||||
Loading…
Add table
Add a link
Reference in a new issue