2015-day22: memoized battle simulator, lots of states to sift through

This commit is contained in:
alexchao26
2020-12-27 20:09:01 -05:00
parent c6c4131c4e
commit 37c74e2adb
2 changed files with 89 additions and 55 deletions
+5 -5
View File
@@ -6,7 +6,7 @@ import (
"github.com/alexchao26/advent-of-code-go/util"
)
func Test_part1(t *testing.T) {
func Test_wizardSimulator(t *testing.T) {
type args struct {
input string
myHP int
@@ -23,13 +23,13 @@ func Test_part1(t *testing.T) {
args: args{"Hit Points: 13\nDamage: 8", 10, 250, 1},
want: spellsMap["Poison"].cost + spellsMap["Magic Missile"].cost,
},
{"actual", args{util.ReadFile("input.txt"), 50, 500, 1}, 953},
{"actual", args{util.ReadFile("input.txt"), 50, 500, 2}, 1289},
{"part1 actual", args{util.ReadFile("input.txt"), 50, 500, 1}, 953},
{"part2 actual", args{util.ReadFile("input.txt"), 50, 500, 2}, 1289},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := part1(tt.args.input, tt.args.myHP, tt.args.myMana, tt.args.part); got != tt.want {
t.Errorf("part1() = %v, want %v", got, tt.want)
if got := wizardSimulator(tt.args.input, tt.args.myHP, tt.args.myMana, tt.args.part); got != tt.want {
t.Errorf("wizardSimulator() = %v, want %v", got, tt.want)
}
})
}