Skip to content

Commit

Permalink
add input3 for day 17
Browse files Browse the repository at this point in the history
  • Loading branch information
metalim committed Dec 17, 2024
1 parent f30c64f commit 979c89f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 17/input3.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions 17/input3_assembly.txt
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions 17/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"math"
"testing"

// "github.com/zeebo/assert"
Expand Down Expand Up @@ -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)
}
}
2 changes: 2 additions & 0 deletions 17/task.txt
Original file line number Diff line number Diff line change
@@ -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.

Expand Down

0 comments on commit 979c89f

Please sign in to comment.