program AnagramCheck;
function AreAnagram(s1, s2: string): boolean;
var
freq1, freq2: array[Char] of Integer;
ch: Char;
begin
FillChar(freq1, SizeOf(freq1), 0);
FillChar(freq2, SizeOf(freq2), 0);
for ch in s1 do
Inc(freq1[ch]);
for ch in s2 do
Inc(freq2[ch]);
for ch := Low(Char) to High(Char) do
if freq1[ch] <> freq2[ch] then
begin
AreAnagram := False;
Exit;
end;
AreAnagram := True;
end;
begin
if AreAnagram('pascal', 'calpas') then
WriteLn('yes')
else
WriteLn('no');
if AreAnagram('pascal', 'capasl') then
WriteLn('yes')
else
WriteLn('no');
if AreAnagram('pascal', 'pasKal') then
WriteLn('yes')
else
WriteLn('no');
end.
(*
run:
yes
yes
no
*)