Exactly three adjacent 3 in lists: Difference between revisions

→‎{{header|Factor}}: Further simplify the solution and format the output according to the task description
(→‎{{header|Factor}}: Add a simpler solution)
(→‎{{header|Factor}}: Further simplify the solution and format the output according to the task description)
Line 1,022:
</pre>
A somewhat simpler implementation without the fancy statistics and generalizations vocabs.
<syntaxhighlight lang=factor>USING: formattingio kernel sequences ;
{
{ 9 3 3 3 2 1 7 8 5 }
Line 1,029:
{ 1 2 3 4 5 6 7 8 9 }
{ 4 6 8 7 2 3 3 3 1 }
}
} [ dup { 3 3 3 } subseq-of? "%utrue" -> %u\n"false" ? printfprint ] each</syntaxhighlight>
{{out}}
<pre>
true
{ 9 3 3 3 2 1 7 8 5 } -> t
false
{ 5 2 9 3 3 7 8 4 1 } -> f
false
{ 1 4 3 6 7 3 8 3 2 } -> f
false
{ 1 2 3 4 5 6 7 8 9 } -> f
true
{ 4 6 8 7 2 3 3 3 1 } -> t
</pre>
 
8

edits