String Halving by uru

type T=string(9999);function f(s:T;l:word):T;begin
l:=length(s)+1;if l=2then f:=s else
f:='{'+f(s[1..l div 2],0)+'}{'+f(s[l div 2+1..l-1],0)+'}'end;var s:T;begin
read(s);write('{',f(s,0),'}')end.

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page