summaryrefslogtreecommitdiff
path: root/test/solitaire.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-10-25 22:20:02 -0700
committerRuss Cox <rsc@golang.org>2011-10-25 22:20:02 -0700
commita2a0c70a8b83096f346908dc85e6f269def667ac (patch)
tree207ee021c6dfa6c3609b708430436d756b19d96a /test/solitaire.go
parentc6744aa6cd448c43c487dc9f6ecd7c9a5d4eb9f4 (diff)
downloadgo-a2a0c70a8b83096f346908dc85e6f269def667ac.tar.gz
cgo, goyacc, go/build, html, http, path, path/filepath, testing/quick, test: use rune
Nothing terribly interesting here. R=golang-dev, bradfitz, gri, r CC=golang-dev http://codereview.appspot.com/5300043
Diffstat (limited to 'test/solitaire.go')
-rw-r--r--test/solitaire.go7
1 files changed, 1 insertions, 6 deletions
diff --git a/test/solitaire.go b/test/solitaire.go
index c789bf24a..473a1d12d 100644
--- a/test/solitaire.go
+++ b/test/solitaire.go
@@ -14,7 +14,7 @@ const N = 11 + 1 // length of a board row (+1 for newline)
// The board must be surrounded by 2 illegal fields in each direction
// so that move() doesn't need to check the board boundaries. Periods
// represent illegal fields, ● are pegs, and ○ are holes.
-var board = []int(
+var board = []rune(
`...........
...........
....●●●....
@@ -28,7 +28,6 @@ var board = []int(
...........
`)
-
// center is the position of the center hole if there is a single one;
// otherwise it is -1.
var center int
@@ -46,7 +45,6 @@ func init() {
}
}
-
var moves int // number of times move is called
// move tests if there is a peg at position pos that can jump over another peg
@@ -63,7 +61,6 @@ func move(pos, dir int) bool {
return false
}
-
// unmove reverts a previously executed valid move.
func unmove(pos, dir int) {
board[pos] = '●'
@@ -71,7 +68,6 @@ func unmove(pos, dir int) {
board[pos+2*dir] = '○'
}
-
// solve tries to find a sequence of moves such that there is only one peg left
// at the end; if center is >= 0, that last peg must be in the center position.
// If a solution is found, solve prints the board after each move in a backward
@@ -110,7 +106,6 @@ func solve() bool {
return false
}
-
func main() {
if !solve() {
println("no solution found")