Exactly three adjacent 3 in lists: Difference between revisions

m
m (→‎{{header|Ring}}: incorrect. again...)
m (→‎{{header|Raku}}: Generalized)
Line 63:
 
=={{header|Raku}}==
Generalized
Explicitly test for ''more'' than 3 consecutive 3s as well.
<lang perl6>say $_, ' ', lc (for 1..Bag{3} ==4 3 ) && ( so .rotor(3=->-2).grep: *.all$n == 3 ) for{
say "\nExactly $n {$n}s, and they are consecutive:";
 
say .gist, ' ', lc (.Bag{$n} == $n) && ( so .rotor($n=>-($n - 1)).grep: *.all == $n ) for
[9,3,3,3,2,1,7,8,5],
[5,2,9,3,3,3,2,1,7,8,4,15],
[15,42,9,3,63,7,3,8,34,21],
[1,24,3,4,5,6,7,3,8,93,2],
[41,62,83,74,25,36,37,38,19],
[34,36,38,17,2,43,53,63,31],
[0,3,3,3,31,72,4,5,21,63],
[30,3,3,3,3,37,32,32,36]</lang>,
[93,3,3,3,23,14,74,84,54],
}</lang>
{{out}}
<pre>[9Exactly 31 3 3 2 11s, 7and 8they 5]are trueconsecutive:
[9 3 3 3 2 1 7 8 5] true
[5 2 9 3 3 7 8 4 1] true
[1 4 3 6 7 3 8 3 2] true
[1 2 3 4 5 6 7 8 9] true
[4 6 8 7 2 3 3 3 1] true
[3 3 3 1 2 4 5 1 3] false
[0 3 3 3 3 7 2 2 6] false
[3 3 3 3 3 4 4 4 4] false
 
Exactly 2 2s, and they are consecutive:
[9 3 3 3 2 1 7 8 5] false
[5 2 9 3 3 7 8 4 1] false
[1 4 3 6 7 3 8 3 2] false
[1 2 3 4 5 6 7 8 9] false
[4 6 8 7 2 3 3 3 1] false
[3 3 3 1 2 4 5 1 3] false
[0 3 3 3 3 7 2 2 6] true
[3 3 3 3 3 4 4 4 4] false
 
Exactly 3 3s, and they are consecutive:
[9 3 3 3 2 1 7 8 5] true
[5 2 9 3 3 7 8 4 1] false
[1 4 3 6 7 3 8 3 2] false
[1 2 3 4 5 6 7 8 9] false
[4 6 8 7 2 3 3 3 1] true
[3 3 3 1 2 4 5 61 3] false
[0 3 3 3 3 7 52 2 6] false
[3 3 3 3 3 34 34 34 34] false</pre>
 
Exactly 4 4s, and they are consecutive:
[9 3 3 3 2 1 7 8 5] false
[5 2 9 3 3 7 8 4 1] false
[1 4 3 6 7 3 8 3 2] false
[1 2 3 4 5 6 7 8 9] false
[4 6 8 7 2 3 3 3 1] false
[3 3 3 1 2 4 5 1 3] false
[0 3 3 3 3 7 2 2 6] false
[3 3 3 3 3 4 4 4 4] true</pre>
 
=={{header|Ring}}==
10,339

edits