mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-06-05 19:59:25 +02:00
49 lines
1015 B
Go
49 lines
1015 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/alexchao26/advent-of-code-go/util"
|
|
)
|
|
|
|
var example = `Begin in state A.
|
|
Perform a diagnostic checksum after 6 steps.
|
|
|
|
In state A:
|
|
If the current value is 0:
|
|
- Write the value 1.
|
|
- Move one slot to the right.
|
|
- Continue with state B.
|
|
If the current value is 1:
|
|
- Write the value 0.
|
|
- Move one slot to the left.
|
|
- Continue with state B.
|
|
|
|
In state B:
|
|
If the current value is 0:
|
|
- Write the value 1.
|
|
- Move one slot to the left.
|
|
- Continue with state A.
|
|
If the current value is 1:
|
|
- Write the value 1.
|
|
- Move one slot to the right.
|
|
- Continue with state A.`
|
|
|
|
func Test_part1(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
want int
|
|
}{
|
|
{"example", example, 3},
|
|
{"actual", util.ReadFile("input.txt"), 5744},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := part1(tt.input); got != tt.want {
|
|
t.Errorf("part1() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|