Unique characters: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: Simplification.)
Line 184: Line 184:
<pre>
<pre>
156bgstz
156bgstz
</pre>

=={{header|jq}}==
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<lang jq>
# bag of words
def bow(stream):
reduce stream as $word ({}; .[($word|tostring)] += 1);

# Input: an array of strings
# Output: an array of the characters that appear just once
def in_one_just_once:
bow( .[] | explode[] | [.] | implode) | with_entries(select(.value==1)) | keys;
</lang>
'''The task'''
<lang jq>["133252abcdeeffd", "a6789798st", "yxcdfgxcyz"]
| in_one_just_once</lang>
{{out}}
<pre>
["1","5","6","b","g","s","t","z"]
</pre>
</pre>