Unique characters

From Rosetta Code
Revision as of 05:48, 5 May 2021 by CalmoSoft (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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"]

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...