Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,31 @@
program move_to_front;
tests := ["broood", "bananaaa", "hiphophiphop"];
alph := "abcdefghijklmnopqrstuvwxyz";
loop for test in tests do
e := encode(test, alph);
d := decode(e, alph);
v := if test = d then "(ok)" else "(fail)" end;
print(test,"->",e,"->",d,v);
end loop;
proc encode(s, alph);
enc := [];
loop for c in s do
[i, j] := mark(alph, c);
alph := c + alph(..i-1) + alph(j+1..);
enc with:= i-1;
end loop;
return enc;
end proc;
proc decode(ls, alph);
s := "";
loop for i in ls do
c := alph(i + 1);
s +:= c;
alph := c + alph(..i) + alph(i+2..);
end loop;
return s;
end proc;
end program;