2015-day19: some chemistry... silly solution of shuffling the order of reactions

This commit is contained in:
alexchao26
2020-12-27 15:30:57 -05:00
parent cb4ef93653
commit 9693aec1a9
2 changed files with 201 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
package main
import (
"testing"
"github.com/alexchao26/advent-of-code-go/util"
)
var example = `H => HO
H => OH
O => HH
HOH`
func Test_part1(t *testing.T) {
tests := []struct {
name string
input string
want int
}{
{"example", example, 4},
{"example", example + "OHO", 7},
{"actual", util.ReadFile("input.txt"), 576},
}
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)
}
})
}
}
var part2Example = `e => H
e => O
H => HO
H => OH
O => HH
HOH`
func Test_part2(t *testing.T) {
tests := []struct {
name string
input string
want int
}{
{"example", part2Example, 3},
{"example", part2Example + "OHO", 6},
{"actual", util.ReadFile("input.txt"), 207},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := part2(tt.input); got != tt.want {
t.Errorf("part2() = %v, want %v", got, tt.want)
}
})
}
}