Day 14: Part 1 and 2

Signed-off-by: James Griffin <james@unsupervised.ca>
This commit is contained in:
2020-12-14 21:21:39 -04:00
parent 6972ec84a1
commit 740bf24df6
7 changed files with 850 additions and 3 deletions

View File

@@ -0,0 +1,46 @@
package fourteen
import "testing"
func Test_computer_load(t *testing.T) {
c := newComputer("sample.txt")
if c == nil {
t.Logf("Unable to load input")
t.FailNow()
}
if len(c.input) != 4 {
t.Logf("Expected 4 instructions, got %d", len(c.input))
t.Fail()
}
}
func Test_computer_exec(t *testing.T) {
c := newComputer("sample.txt")
sum := c.sum(1)
if sum != 165 {
t.Logf("Expected memory sum of 165, got %d", sum)
t.Fail()
}
}
func Test_computer_mask(t *testing.T) {
c := newComputer("sample2.txt")
c.execute()
if c.ones != 20691600039 || c.zeros != 8833416264 {
t.Logf("Expected mask parse of 20691600039 ons and 8833416264 zeros, got %d and %d", c.ones, c.zeros)
t.Fail()
}
}
func Test_computer_version2(t *testing.T) {
c := newComputer("sample3.txt")
sum := c.sum(2)
if sum != 208 {
t.Logf("Expected memory sum of 208, got %d", sum)
t.Fail()
}
}