Flipping bits game: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added a programming note to the section header.) |
m (→{{header|Perl}}: Changed output to a 3x3 game. Program was untouched.) |
||
Line 1,148: | Line 1,148: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{incomplete|Perl|Output shown should be for a 3 by 3 case.}} |
|||
Pass the size of the puzzle on the command line. It defaults to 4. You can play any |
Pass the size of the puzzle on the command line. It defaults to 4. You can play any |
||
size game between 2 and 26. While playing, the game accepts anything which looks like |
size game between 2 and 26. While playing, the game accepts anything which looks like |
||
Line 1,228: | Line 1,227: | ||
} |
} |
||
} |
} |
||
print "You won after $moves_so_far moves.\n"; |
print "You won after $moves_so_far moves.\n";</lang> |
||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre>$ perl FlippingBitsGame.pl 3 |
||
Starting board Ending board |
Starting board Ending board |
||
a b c |
a b c a b c |
||
1 0 0 1 |
1 0 0 1 1 1 1 1 |
||
2 |
2 0 1 1 2 1 0 1 |
||
3 0 0 0 3 0 0 1 |
|||
⚫ | |||
4 1 0 1 1 0 4 0 0 1 0 1 |
|||
5 0 1 0 0 0 5 0 0 1 0 0 |
|||
⚫ | |||
Starting board Ending board |
Starting board Ending board |
||
a b c |
a b c a b c |
||
1 1 1 0 1 1 1 1 |
|||
2 1 0 0 2 1 0 1 |
|||
3 0 |
3 0 0 0 3 0 0 1 |
||
⚫ | |||
4 0 0 1 0 0 4 0 0 1 0 1 |
|||
5 1 1 0 1 0 5 0 0 1 0 0 |
|||
⚫ | |||
Starting board Ending board |
Starting board Ending board |
||
a b c |
a b c a b c |
||
1 1 |
1 1 1 1 1 1 1 1 |
||
2 1 0 1 2 1 0 1 |
|||
3 0 0 1 3 0 0 1 |
|||
⚫ | |||
4 0 0 1 0 1 4 0 0 1 0 1 |
|||
5 0 0 1 0 0 5 0 0 1 0 0 |
|||
⚫ | |||
The same game could have been won after typing |
The same game could have been won after typing 1 2 c in any order, with multiple lines or even "12c" on a single line. |
||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |