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>PS C:\Documents and Settings\Ben\RosettaCode> perl FlippingBitsGame.pl 5
<pre>$ perl FlippingBitsGame.pl 3
Starting board Ending board
Starting board Ending board
a b c d e a b c d e
a b c a b c
1 0 0 1 0 1 1 1 0 1 1 0
1 0 0 1 1 1 1 1
2 1 1 1 0 0 2 0 1 1 1 1
2 0 1 1 2 1 0 1
3 1 1 1 0 1 3 1 0 0 0 1
3 0 0 0 3 0 0 1
Move #1: Type one or more row numbers and/or column letters: 12
4 1 0 1 1 0 4 0 0 1 0 1
5 0 1 0 0 0 5 0 0 1 0 0
Move #1: Type one or more row numbers and/or column letters: ad
Starting board Ending board
Starting board Ending board
a b c d e a b c d e
a b c a b c
1 1 0 1 1 1 1 1 0 1 1 0
1 1 1 0 1 1 1 1
2 0 1 1 1 0 2 0 1 1 1 1
2 1 0 0 2 1 0 1
3 0 1 1 1 1 3 1 0 0 0 1
3 0 0 0 3 0 0 1
Move #3: Type one or more row numbers and/or column letters: c
4 0 0 1 0 0 4 0 0 1 0 1
5 1 1 0 1 0 5 0 0 1 0 0
Move #3: Type one or more row numbers and/or column letters: e35
Starting board Ending board
Starting board Ending board
a b c d e a b c d e
a b c a b c
1 1 0 1 1 0 1 1 0 1 1 0
1 1 1 1 1 1 1 1
2 0 1 1 1 1 2 0 1 1 1 1
2 1 0 1 2 1 0 1
3 1 0 0 0 1 3 1 0 0 0 1
3 0 0 1 3 0 0 1
You won after 3 moves.</pre>
4 0 0 1 0 1 4 0 0 1 0 1
5 0 0 1 0 0 5 0 0 1 0 0
You won after 5 moves.</pre>


The same game could have been won after typing a d e 3 5 in any order, even on one line.
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}}==