Skip to content

Commit 4ee8d89

Browse files
committed
2017: catch up with lib.
1 parent 0dd892d commit 4ee8d89

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

19_walk_path.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,18 @@ func main() {
3535
start := field.Pos{startX, 0}
3636

3737
canStepOn := func(p field.Pos) bool { return f.Get(p) != ' ' }
38-
step := func(p field.Pos) bool {
38+
stepOn := func(p field.Pos, d field.Dir8) int {
3939
c := byte(f.Get(p))
4040
if strings.IndexByte("|-+", c) == -1 {
4141
out = append(out, byte(c))
4242
}
43-
return true
44-
}
45-
getDirections := func(p field.Pos, d field.Dir8) int {
43+
4644
if f.Get(p) == '+' {
4745
return 1<<((d+2)&7) + 1<<((d-2)&7) // turn right or left
4846
}
4947
return 1 << d // continue in same direction
5048
}
51-
_, steps := field.Walk(start, field.Dir80P, canStepOn, step, getDirections)
49+
_, steps := field.Walk(start, field.Dir80P, canStepOn, stepOn)
5250

5351
if par.Part(1) {
5452
par.Submit(1, string(out))

0 commit comments

Comments
 (0)