Determine if a string has all unique characters: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 2,171: | Line 2,171: | ||
if (numelems([index]) > 1) then |
if (numelems([index]) > 1) then |
||
printf("The given string has duplicated characters.\n"); |
printf("The given string has duplicated characters.\n"); |
||
printf("The first duplicated character is %a (0x%x) which appears at index %a.\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}); |
s[i], convert(s[i], 'bytes')[1], {index}); |
||
return; |
return; |
||
Line 2,177: | Line 2,177: | ||
end do; |
end do; |
||
# if no repeated found |
# if no repeated found |
||
printf("The given string has all unique characters.\n"); |
printf("The given string has all unique characters.\n\n"); |
||
end proc: |
end proc: |
||
Line 2,190: | Line 2,190: | ||
input: "", length: 0 |
input: "", length: 0 |
||
The given string has all unique characters. |
The given string has all unique characters. |
||
input: ".", length: 1 |
input: ".", length: 1 |
||
The given string has all unique characters. |
The given string has all unique characters. |
||
input: "abcABC", length: 6 |
input: "abcABC", length: 6 |
||
The given string has all unique characters. |
The given string has all unique characters. |
||
input: "XYZ ZYX", length: 7 |
input: "XYZ ZYX", length: 7 |
||
The given string has duplicated characters. |
The given string has duplicated characters. |
||
The first duplicated character is "X" (0x58) which appears at index {1, 7}. |
The first duplicated character is "X" (0x58) which appears at index {1, 7}. |
||
input: "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ", length: 36 |
input: "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ", length: 36 |
||
The given string has duplicated characters. |
The given string has duplicated characters. |