mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-06-07 04:33:31 +02:00
2017-day19: simple following a 2D path
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
|
||||
// easier to look at this input in the format, but need to remove leading/trailing newlines
|
||||
var example = strings.Trim(`
|
||||
|
|
||||
| +--+
|
||||
A | C
|
||||
F---|----E|--+
|
||||
| | | D
|
||||
+B-+ +--+
|
||||
`, "\n")
|
||||
|
||||
func Test_movePacket(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
wantVisitedChars string
|
||||
wantSteps int
|
||||
}{
|
||||
{"example", example, "ABCDEF", 38},
|
||||
{"actual", util.ReadFile("input.txt"), "EPYDUXANIT", 17544},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotVisitedChars, gotSteps := movePacket(tt.input)
|
||||
if gotVisitedChars != tt.wantVisitedChars {
|
||||
t.Errorf("movePacket() gotVisitedChars = %v, want %v", gotVisitedChars, tt.wantVisitedChars)
|
||||
}
|
||||
if gotSteps != tt.wantSteps {
|
||||
t.Errorf("movePacket() gotSteps = %v, want %v", gotSteps, tt.wantSteps)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user