BUU has asked for the wisdom of the Perl Monks concerning the following question:
Or whatever the VB equivalent happened to be. Naturally, as a Perl programmer who strives to be as concise as possible (while still being clear and understandable of course), I was horrified by all the repeated code. But then when I stopped to think how I would do it, I had problems coming up with a way that was substantially better. So I pose the question to you: Given a datastructure, how do you check for a tic-tac-toe win condition?if( $board[0][0] eq 'x' and $board[0][1] eq 'x' and $board[0][2] eq 'x +' ) { #win! }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checking Tic-Tac-Toe Win conditions?
by ambrus (Abbot) on Sep 25, 2004 at 10:51 UTC | |
|
Re: Checking Tic-Tac-Toe Win conditions?
by Chady (Priest) on Sep 25, 2004 at 11:06 UTC | |
|
Re: Checking Tic-Tac-Toe Win conditions?
by davido (Cardinal) on Sep 25, 2004 at 16:57 UTC | |
|
Re: Checking Tic-Tac-Toe Win conditions?
by TedPride (Priest) on Sep 26, 2004 at 05:16 UTC | |
|
Re: Checking Tic-Tac-Toe Win conditions?
by TedPride (Priest) on Sep 26, 2004 at 05:48 UTC | |
|
Re: Checking Tic-Tac-Toe Win conditions?
by dragonchild (Archbishop) on Sep 26, 2004 at 16:53 UTC |