1. cvicenie
Created: 2009-09-30 - 17:48
Caesarova sifra v maple...
with (StringTools);
str2int := proc (text)
local konvertovane;
local z;
konvertovane := UpperCase(Select(IsAlpha,text));
z := convert (konvertovane,bytes);
return map(x->x-65,z);
end proc;
caesar:=proc(num)
return map(x->(x+3) mod 26,num);
end proc;
int2str := proc (vstup)
return convert(map(x->x+65,vstup),bytes);
end proc;
sifruj:=proc(vstup)
str2int(vstup);
caesar(%);
int2str(%);
end proc;
desifruj := proc(sifrovane)
local z,tmp;
z := str2int(sifrovane);
tmp := map(x->x+23 mod 26,z);
return int2str(tmp);
end proc;