Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
CheckUnique:=proc(s)
|
||||
local i, index;
|
||||
printf("input: \"%s\", length: %a\n", s, StringTools:-Length(s));
|
||||
for i from 1 to StringTools:-Length(s) do
|
||||
index := StringTools:-SearchAll(s[i], s);
|
||||
if (numelems([index]) > 1) then
|
||||
printf("The given string has duplicated characters.\n");
|
||||
printf("The first duplicated character is %a (0x%x) which appears at index %a.\n\n",
|
||||
s[i], convert(s[i], 'bytes')[1], {index});
|
||||
return;
|
||||
end if;
|
||||
end do;
|
||||
# if no repeated found
|
||||
printf("The given string has all unique characters.\n\n");
|
||||
end proc:
|
||||
|
||||
# Test
|
||||
CheckUnique("");
|
||||
CheckUnique(".");
|
||||
CheckUnique("abcABC");
|
||||
CheckUnique("XYZ ZYX");
|
||||
CheckUnique("1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ");
|
||||
Loading…
Add table
Add a link
Reference in a new issue