Actual solution for day 16!
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package sixteen
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_hex(t *testing.T) {
|
||||
original := "8A004A801A8002F478"
|
||||
@@ -50,7 +53,7 @@ func Test_hex4(t *testing.T) {
|
||||
|
||||
if vSum != expected {
|
||||
t.Logf("Expected %d, found %d", expected, vSum)
|
||||
// t.Fail()
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +129,7 @@ func Test_operator2(t *testing.T) {
|
||||
}
|
||||
|
||||
if b.subpackets[1].content != 2 {
|
||||
t.Logf("Expected second packet to be 2, found %d", b.subpackets[2].content)
|
||||
t.Logf("Expected second packet to be 2, found %d", b.subpackets[2].content)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
@@ -135,3 +138,121 @@ func Test_operator2(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_sum(t *testing.T) {
|
||||
original := "C200B40A82"
|
||||
expected := 3
|
||||
|
||||
p := parseHex(original)
|
||||
fmt.Println(p)
|
||||
v := p.value()
|
||||
|
||||
if v != expected {
|
||||
t.Logf("Expected %d, found %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_product(t *testing.T) {
|
||||
original := "04005AC33890"
|
||||
expected := 54
|
||||
|
||||
p := parseHex(original)
|
||||
v := p.value()
|
||||
|
||||
if v != expected {
|
||||
t.Logf("Expected %d, found %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_min(t *testing.T) {
|
||||
original := "880086C3E88112"
|
||||
expected := 7
|
||||
|
||||
p := parseHex(original)
|
||||
v := p.value()
|
||||
|
||||
if v != expected {
|
||||
t.Logf("Expected %d, found %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_max(t *testing.T) {
|
||||
original := "CE00C43D881120"
|
||||
expected := 9
|
||||
|
||||
p := parseHex(original)
|
||||
v := p.value()
|
||||
|
||||
if v != expected {
|
||||
t.Logf("Expected %d, found %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_less(t *testing.T) {
|
||||
original := "D8005AC2A8F0"
|
||||
expected := 1
|
||||
|
||||
p := parseHex(original)
|
||||
v := p.value()
|
||||
|
||||
if v != expected {
|
||||
t.Logf("Expected %d, found %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_more(t *testing.T) {
|
||||
original := "F600BC2D8F"
|
||||
expected := 0
|
||||
|
||||
p := parseHex(original)
|
||||
v := p.value()
|
||||
|
||||
if v != expected {
|
||||
t.Logf("Expected %d, found %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_equal(t *testing.T) {
|
||||
original := "9C005AC2F8F0"
|
||||
expected := 0
|
||||
|
||||
p := parseHex(original)
|
||||
v := p.value()
|
||||
|
||||
if v != expected {
|
||||
t.Logf("Expected %d, found %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_combo(t *testing.T) {
|
||||
original := "9C0141080250320F1802104A08"
|
||||
expected := 1
|
||||
|
||||
p := parseHex(original)
|
||||
v := p.value()
|
||||
|
||||
if v != expected {
|
||||
t.Logf("Expected %d, found %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_input(t *testing.T) {
|
||||
expected := 531986792411
|
||||
|
||||
p := load("input.txt")
|
||||
|
||||
v := p.value()
|
||||
|
||||
if v == expected {
|
||||
t.Logf("Expected to not get %d, got %d", expected, v)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user