diff --git a/17/input3.txt b/17/input3.txt new file mode 100644 index 0000000..cbd9ed7 --- /dev/null +++ b/17/input3.txt @@ -0,0 +1,5 @@ +Register A: 59397658 +Register B: 0 +Register C: 0 + +Program: 2,4,1,1,7,5,4,6,1,4,0,3,5,5,3,0 diff --git a/17/input3_assembly.txt b/17/input3_assembly.txt new file mode 100644 index 0000000..9ed019b --- /dev/null +++ b/17/input3_assembly.txt @@ -0,0 +1,10 @@ +2,4,1,1,7,5,4,6,1,4,0,3,5,5,3,0 + +2,4 bst A B = A & 7 +1,1 bxl 1 B = B ^ 1 = A&7^1 +7,5 cdv B C = A >> B = A>>(A&7^1) +4,6 bxc - B = B ^ C = A&7^1 ^ (A>>(A&7^1)) +1,4 bxl 4 B = B ^ 4 = A&7^1 ^ (A>>(A&7^1)) ^ 4 = A&7^5 ^ (A>>(A&7^1)) +0,3 adv 3 A = A >> 3 +5,5 out B output A&7^5 ^ (A>>(A&7^2)) & 7 +3,0 jnz 0 if A != 0 goto 0 diff --git a/17/main_test.go b/17/main_test.go index 3657c31..444e165 100644 --- a/17/main_test.go +++ b/17/main_test.go @@ -1,6 +1,7 @@ package main import ( + "math" "testing" // "github.com/zeebo/assert" @@ -31,3 +32,14 @@ func TestCPU(t *testing.T) { reg, _ = run([]int{4, 0}, [3]int{0, 2024, 43690}) assert.Equal(t, 44354, reg[1]) } + +var testProgram = []int{2, 4, 1, 1, 7, 5, 0, 3, 1, 4, 4, 5, 5, 5, 3, 0} + +func TestOutput(t *testing.T) { + for i := 1; i < math.MaxInt64; i = i<<1 + 1 { + _, output := run(testProgram, [3]int{i, 0, 0}) + t.Logf("%d: %v\n", i, output) + _, output = run(testProgram, [3]int{i + 1, 0, 0}) + t.Logf("%d: %v\n", i+1, output) + } +} diff --git a/17/task.txt b/17/task.txt index c99e2f3..3ad4f93 100644 --- a/17/task.txt +++ b/17/task.txt @@ -1,3 +1,5 @@ +https://adventofcode.com/2024/day/17 + --- Day 17: Chronospatial Computer --- The Historians push the button on their strange device, but this time, you all just feel like you're falling.