Unique characters: Difference between revisions
Content added Content deleted
(Created page with "{{Draft task}} ;Task: Given a list of strings find characters appearing only one string and once only. <br>The result give in alphabetical order. <br> Let list = ["133252abcd...") |
(Add Factor) |
||
Line 6: | Line 6: | ||
<br> Let list = ["133252abcdeeffd", "a6789798st","yxcdfgxcyz"] |
<br> Let list = ["133252abcdeeffd", "a6789798st","yxcdfgxcyz"] |
||
<br><br> |
<br><br> |
||
=={{header|Factor}}== |
|||
{{works with|Factor|0.99 build 2074}} |
|||
<lang factor>USING: io sequences sets.extras ; |
|||
{ "133252abcdeeffd" "a6789798st" "yxcdfgxcyz" } concat non-repeating print</lang> |
|||
{{out}} |
|||
<pre> |
|||
15b6stgz |
|||
</pre> |
|||
=={{header|Ring}}== |
=={{header|Ring}}== |
Revision as of 06:39, 5 May 2021
Unique characters is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
- Task
Given a list of strings find characters appearing only one string and once only.
The result give in alphabetical order.
Let list = ["133252abcdeeffd", "a6789798st","yxcdfgxcyz"]
Factor
<lang factor>USING: io sequences sets.extras ;
{ "133252abcdeeffd" "a6789798st" "yxcdfgxcyz" } concat non-repeating print</lang>
- Output:
15b6stgz
Ring
<lang ring> see "working..." + nl see "Unique characters are:" + nl row = 0 str = "" cList = [] uniqueChars = ["133252abcdeeffd", "a6789798st","yxcdfgxcyz"] for n = 1 to len(uniqueChars)
str = str + uniqueChars[n]
next for n = 1 to len(str)
ind = count(str,str[n]) if ind = 1 row = row + 1 add(cList,str[n]) ok
next cList = sort(cList) for n = 1 to len(cList)
see "" + cList[n] + " "
next see nl
see "Found " + row + " unique characters" + nl see "done..." + nl
func count(cString,dString)
sum = 0 while substr(cString,dString) > 0 sum++ cString = substr(cString,substr(cString,dString)+len(string(sum))) end return sum
</lang>
- Output:
working... Unique characters are: 1 5 6 b g s t z Found 8 unique characters done...