Mosaic matrix: Difference between revisions
Content added Content deleted
(→{{header|RPL}}: one-liner) |
(Created Nim solution.) |
||
Line 897: | Line 897: | ||
1 0 1 0 1 |
1 0 1 0 1 |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|Nim}}== |
|||
<syntaxhighlight lang="Nim">proc drawMosaicMatrix(side: Positive) = |
|||
var start = 1 |
|||
for i in 0..<side: |
|||
var c = start |
|||
for j in 0..<side: |
|||
stdout.write c |
|||
c = 1 - c |
|||
echo() |
|||
start = 1 - start |
|||
echo "6x6 matrix:\n" |
|||
drawMosaicMatrix(6) |
|||
echo "\n7x7 matrix:\n" |
|||
drawMosaicMatrix(7) |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre>6x6 matrix: |
|||
101010 |
|||
010101 |
|||
101010 |
|||
010101 |
|||
101010 |
|||
010101 |
|||
7x7 matrix: |
|||
1010101 |
|||
0101010 |
|||
1010101 |
|||
0101010 |
|||
1010101 |
|||
0101010 |
|||
1010101 |
|||
</pre> |
|||
=={{header|Pascal}}== |
=={{header|Pascal}}== |