Exactly three adjacent 3 in lists: Difference between revisions
Content added Content deleted
(Realize in F#) |
|||
Line 235: | Line 235: | ||
// Exactly three adjacent 3 in lists. Nigel Galloway: December 8th., 2021 |
// Exactly three adjacent 3 in lists. Nigel Galloway: December 8th., 2021 |
||
let n=[[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]] |
let n=[[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]] |
||
n|>List.iter(fun n->printfn "%A" (n |
n|>List.iter(fun n->printfn "%A" (n|>List.windowed 3|>List.exists(fun(n::g::l::_)->n=3 && g=3 && l=3))) |
||
</lang> |
</lang> |
||
{{out}} |
{{out}} |
||
Line 245: | Line 245: | ||
true |
true |
||
</pre> |
</pre> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
<lang freebasic>dim as integer list(1 to 5, 1 to 9) = {_ |
<lang freebasic>dim as integer list(1 to 5, 1 to 9) = {_ |