Exactly three adjacent 3 in lists: Difference between revisions
Content added Content deleted
(→{{header|Wren}}: Code is in fact correct - always returns false if there are more than 3 threes, adjacent or not. Added more examples to demonstrate this is so.) |
|||
Line 199: | Line 199: | ||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{incorrect|Wren|Will incorrectly pass for a list with '''more''' than 3 consecutive '3's}} |
|||
<lang ecmascript>var lists = [ |
<lang ecmascript>var lists = [ |
||
[9,3,3,3,2,1,7,8,5], |
[9,3,3,3,2,1,7,8,5], |
||
Line 205: | Line 204: | ||
[1,4,3,6,7,3,8,3,2], |
[1,4,3,6,7,3,8,3,2], |
||
[1,2,3,4,5,6,7,8,9], |
[1,2,3,4,5,6,7,8,9], |
||
[4,6,8,7,2,3,3,3,1] |
[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] |
|||
] |
] |
||
System.print("Exactly three adjacent 3's:") |
System.print("Exactly three adjacent 3's:") |
||
Line 226: | Line 228: | ||
[1, 2, 3, 4, 5, 6, 7, 8, 9] -> false |
[1, 2, 3, 4, 5, 6, 7, 8, 9] -> false |
||
[4, 6, 8, 7, 2, 3, 3, 3, 1] -> 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 |
|||
</pre> |
</pre> |