Unique characters: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: Added a solution in Python)
Line 789: Line 789:
{{out}}
{{out}}
<pre>156BGSTZ</pre>
<pre>156BGSTZ</pre>

=={{header|Python}}==
<lang python>'''Unique characters'''

from itertools import chain, groupby


# uniques :: [String] -> [Char]
def uniques(ks):
'''Characters which occur only once
across the given strings.
'''
return [
k for k, g in
groupby(sorted(chain(*ks)))
if 1 == len(list(g))
]


# ------------------------- TEST -------------------------
# main :: IO ()
def main():
'''Characters occurring only once
across a list of 3 given strings.
'''
print(
uniques([
"133252abcdeeffd",
"a6789798st",
"yxcdfgxcyz"
])
)


# MAIN ---
if __name__ == '__main__':
main()</lang>
{{Out}}
<pre>['1', '5', '6', 'b', 'g', 's', 't', 'z']</pre>


=={{header|Raku}}==
=={{header|Raku}}==