Browse Source

Solved part1

Piotr Czajkowski 5 days ago
parent
commit
3da574a000
2 changed files with 7 additions and 3 deletions
  1. 2 3
      17/code.go
  2. 5 0
      17/input

+ 2 - 3
17/code.go

@@ -103,10 +103,9 @@ func process(registers []Register, program []int) []int {
 		case 5:
 			results = append(results, getCombo(program[instructionPointer+1], registers)%8)
 		case 6:
-			registers[1].value = registers[0].value / (getCombo(program[instructionPointer+1], registers) * getCombo(program[instructionPointer+1], registers))
+			registers[1].value = registers[0].value / (powerOfTwo(getCombo(program[instructionPointer+1], registers)))
 		case 7:
-			registers[3].value = registers[0].value / (getCombo(program[instructionPointer+1], registers) * getCombo(program[instructionPointer+1], registers))
-
+			registers[2].value = registers[0].value / (powerOfTwo(getCombo(program[instructionPointer+1], registers)))
 		}
 
 		instructionPointer += 2

+ 5 - 0
17/input

@@ -0,0 +1,5 @@
+Register A: 22817223
+Register B: 0
+Register C: 0
+
+Program: 2,4,1,2,7,5,4,5,0,3,1,7,5,5,3,0