Rep-string: Difference between revisions

Added Snobol4 implementation
(Added Snobol4 implementation)
Line 3,127:
0𝟘
1 (no repeat)</pre>
 
=={{header|Snobol4}}==
<lang Snobol4>* Rep-string
strings = "1001110011 1110111011 0010010010 1010101010 1111111111 0100101101 0100100 101 11 00 1 "
pat1 = (len(1) $ fc breakx(*fc)) $ x *x (arbno(*x) (rpos(0) | rem $ y *?(x ? y)))
getstring
strings ? (break(" ") . rs len(1)) = :f(end)
rs ? pat1 :s(yes)
output = rs " is not a rep-string -> n/a" :(getstring)
yes
output = rs " has shortest rep-string value of -> " x
:(getstring)
end
</lang>
{{out}}
<pre>1001110011 has shortest rep-string value of -> 10011
1110111011 has shortest rep-string value of -> 1110
0010010010 has shortest rep-string value of -> 001
1010101010 has shortest rep-string value of -> 10
1111111111 has shortest rep-string value of -> 1
0100101101 is not a rep-string -> n/a
0100100 has shortest rep-string value of -> 010
101 is not a rep-string -> n/a
11 has shortest rep-string value of -> 1
00 has shortest rep-string value of -> 0
1 is not a rep-string -> n/a
</pre>
 
=={{header|Swift}}==
Anonymous user