2023-20 phew part 2 was scary at first

This commit is contained in:
alexchao26
2024-08-13 13:53:28 -04:00
parent c06369e6ff
commit c7f2581dc7
2 changed files with 273 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
package main
import (
"testing"
)
var example = `broadcaster -> a, b, c
%a -> b
%b -> c
%c -> inv
&inv -> a`
var example2 = `broadcaster -> a
%a -> inv, con
&inv -> b
%b -> con
&con -> output`
func Test_pulsePropagation(t *testing.T) {
tests := []struct {
name string
input string
part int
want int
}{
{
name: "example",
input: example,
part: 1,
want: 32000000,
},
{
name: "example2",
input: example2,
part: 1,
want: 11687500,
},
{
name: "actual",
input: input,
part: 1,
want: 817896682,
},
{
name: "actual",
input: input,
part: 2,
want: 250924073918341,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := pulsePropagation(tt.input, tt.part); got != tt.want {
t.Errorf("pulsePropagation() = %v, want %v", got, tt.want)
}
})
}
}