Exactly three adjacent 3 in lists: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: white space)
Line 120: Line 120:


=={{header|Ring}}==
=={{header|Ring}}==

{{incorrect|Ring|Will incorrectly pass if there are ''more'' than 3 3s in the list and any three happen to be consecutive. Test with [3,3,3,1,2,4,5,1,3]}}
<lang ring>
<lang ring>
see "working..." + nl
see "working..." + nl
Line 129: Line 129:
list[3] = [1,4,3,6,7,3,8,3,2]
list[3] = [1,4,3,6,7,3,8,3,2]
list[4] = [1,2,3,4,5,6,7,8,9]
list[4] = [1,2,3,4,5,6,7,8,9]
list[5] = [4,6,8,7,2,3,3,3,1]
list[5] = [3,3,3,1,2,4,5,1,3]


for n = 1 to 5
for n = 1 to 5
strn = list2str(list[n])
strn = list2str(list[n])
cnt = count(strn,"3")
cnt = count(strn,"3")
if cnt = 3
if cnt > 2
for m = 1 to len(list[n])-3
for m = 1 to len(list[n])-2
if list[n][m] = 3 and list[n][m+1] = 3 and list[n][m+2] = 3 and list[n][m+3] != 3
if list[n][m] = 3 and list[n][m+1] = 3 and list[n][m+2] = 3
flag = 1
flag = 1
exit
exit