浏览代码

Solved part1

Piotr Czajkowski 4 天之前
父节点
当前提交
3da574a000
共有 2 个文件被更改,包括 7 次插入3 次删除
  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