Jump to content

Unique characters in each string: Difference between revisions

Added XPL0 example.
(Added Algol 68)
(Added XPL0 example.)
Line 705:
Found 6 unique character(s) common to each string, namely:
1 2 3 a b c
</pre>
 
=={{header|XPL0}}==
<lang XPL0>char List, Counter(128), Unique(3, 128);
int Char, I, J;
string 0; \use null-terminated string convention
[List:= ["1a3c52debeffd", "2b6178c97a938stf", "3ycxdb1fgxa2yz"];
for I:= 0 to 2 do \each string in List
[for J:= 0 to 127 do Counter(J):= 0;
J:= 0; \count each character in string
repeat Char:= List(I, J);
J:= J+1;
Counter(Char):= Counter(Char)+1;
until Char = 0; \terminator
for J:= 0 to 127 do
Unique(I, J):= Counter(J) = 1;
];
for Char:= 1 to 127 do \skip 0 terminator
if Unique(0, Char) & Unique(1, Char) & Unique(2, Char) then
[ChOut(0, Char); ChOut(0, ^ )];
]</lang>
 
{{out}}
<pre>
1 2 3 a b c
</pre>
295

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.