Skip to content

Commit d6266c3

Browse files
committed
chore
1 parent d1353bf commit d6266c3

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

Sources/Day17.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ struct Day17: AdventDay {
104104
}
105105

106106
func part2() -> Int {
107+
// 2,4 -> assign to B modulo 8
108+
// 1,7 -> xor B with 7 -> inverts bits in B
109+
// 7,5 -> div register A with content of 2 pow B and put in C
110+
// 1,7 -> again
111+
// 4,6 -> B = B xor C
112+
// 0, 3 -> register A = A div (2 pow 3)
113+
// 5,5 -> out reg B
114+
// 3,0 -> start over if A is not 0
115+
//
116+
117+
// B needs to be 2
118+
// 000 -> 010 (2)
119+
// we start with B = 4 -> 100
120+
// invert bits on B -> 011
121+
// C needs to be result in X % 8 = 5
122+
// a / 2^4
123+
// requirements
124+
// A needs to be 14 digits
125+
// 266 gives the first right digit
126+
107127
0
108128
}
109129
}

Tests/Day17.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,20 @@ struct Day17Tests {
6363
#expect(challenge.part1() == "4,6,3,5,6,3,5,2,1,0")
6464
}
6565

66-
@Test("part2")
66+
@Test(.disabled("part2"))
6767
func testPart2() async throws {
68-
let challenge = Day17(data: testData)
69-
#expect(challenge.part2() == 0)
68+
// 66245665785645
69+
let challenge = Day17(
70+
data: """
71+
Register A: 35048
72+
Register B: 0
73+
Register C: 0
74+
75+
Program: 2,4,1,7,7,5,1,7,4,6,0,3,5,5,3,0
76+
""")
77+
let res = challenge.part1()
78+
let expectedRes = "2,4,1,7,7,5,1,7,4,6,0,3,5,5,3,0"
79+
#expect(res.count == expectedRes.count)
80+
#expect(res == expectedRes)
7081
}
7182
}

0 commit comments

Comments
 (0)