Unique characters in each string: Difference between revisions

Content added Content deleted
(Unique characters in each string en Yabasic)
Line 846: Line 846:
1 2 3 a b c
1 2 3 a b c
</pre>
</pre>

=={{header|Yabasic}}==
{{trans|FreeBASIC}}
<lang yabasic>sub count_char(s$, c$)
local i, r
r = 0
for i = 1 to len(s$)
if mid$(s$,i,1) = c$ then r = r + 1 : fi
next i
return r
end sub
dim dat$(2)
dat$(0) = "1a3c52debeffd"
dat$(1) = "2b6178c97a938stf"
dat$(2) = "3ycxdb1fgxa2yz"
for i = 1 to len(dat$(1))
c$ = mid$(dat$(1), i, 1)
for j = 0 to 2
if count_char(dat$(j), c$) <> 1 then goto nexti : fi
next j
for j = 0 to len(uniq$)-1
if mid$(uniq$, j+1, 1) > c$ then break : fi
next j
uniq$ = left$(uniq$, j) + c$ + right$(uniq$, len(uniq$)-j)
label nexti
next i
print uniq$
end</lang>
{{out}}
<pre>123abc</pre>