Kaynağa Gözat

Solved part1

Piotr Czajkowski 4 gün önce
ebeveyn
işleme
3da574a000
2 değiştirilmiş dosya ile 7 ekleme ve 3 silme
  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