Exactly three adjacent 3 in lists: Difference between revisions

(Added AutoHotkey)
Line 1,017:
</pre>
 
=={{header|Ruby}}==
Using the Raku/Wren testset:
<lang ruby>tests = [[9,3,3,3,2,1,7,8,5],
[5,2,9,3,3,7,8,4,1],
[1,4,3,6,7,3,8,3,2],
[1,2,3,4,5,6,7,8,9],
[4,6,8,7,2,3,3,3,1],
[3,3,3,1,2,4,5,1,3],
[0,3,3,3,3,7,2,2,6],
[3,3,3,3,3,4,4,4,4]]
 
(1..4).each do |n|
c = [n]*n
puts "Contains exactly #{n} #{n}s, consecutive:"
tests.each { |t| puts "#{t.inspect} : #{t.count(n)==n && t.each_cons(n).any?{|chunk| chunk == c }}" }
end
</lang>
{{out}}
<pre>Contains exactly 1 1s, consecutive:
[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
Contains exactly 2 2s, 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
Contains exactly 3 3s, 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, 1, 3] : false
[0, 3, 3, 3, 3, 7, 2, 2, 6] : false
[3, 3, 3, 3, 3, 4, 4, 4, 4] : false
Contains exactly 4 4s, 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|Wren}}==
{{libheader|Wren-seq}}
1,149

edits