Determine if a string has all unique characters: Difference between revisions

Added Arturo implementation
(Added Arturo implementation)
Line 536:
'XYZ ZYX' (7) -> 'X' at 1, 7
'1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ' (36) -> '0' at 10, 25</pre>
 
=={{header|Arturo}}==
 
<lang rebol>strings: [
"", ".", "abcABC", "XYZ ZYX",
"1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ",
"01234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ0X",
"hétérogénéité",
"🎆🎃🎇🎈", "😍😀🙌💃😍🙌", "🐠🐟🐡🦈🐬🐳🐋🐡"
]
 
loop strings 'str [
chars: split str
prints [as.code str ~"(size |size str|):"]
if? chars = unique chars ->
print "has no duplicates."
else [
seen: #[]
done: false
 
i: 0
while [and? i<size chars
not? done][
ch: chars \ i
if? not? key? seen ch [
set seen ch i
]
else [
print ~"has duplicate char `|ch|` on |get seen ch| and |i|"
done: true
]
i: i+1
]
]
]</lang>
 
{{out}}
 
<pre>"" (size 0): has no duplicates.
"." (size 1): has no duplicates.
"abcABC" (size 6): has no duplicates.
"XYZ ZYX" (size 7): has duplicate char `Z` on 2 and 4
"1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" (size 36): has duplicate char `0` on 9 and 24
"01234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ0X" (size 39): has duplicate char `0` on 0 and 10
"hétérogénéité" (size 13): has duplicate char `é` on 1 and 3
"🎆🎃🎇🎈" (size 4): has no duplicates.
"😍😀🙌💃😍🙌" (size 6): has duplicate char `😍` on 0 and 4
"🐠🐟🐡🦈🐬🐳🐋🐡" (size 8): has duplicate char `🐡` on 2 and 7</pre>
 
=={{header|AutoHotkey}}==
1,532

edits