Piotr Czajkowski před 1 týdnem
rodič
revize
e52d9b2609
1 změnil soubory, kde provedl 6 přidání a 3 odebrání
  1. 6 3
      13/code.go

+ 6 - 3
13/code.go

@@ -66,9 +66,12 @@ func calculate(machine Machine, button int) [2]int {
 	otherButton := (button + 1) % 2
 
 	if machine.x%machine.buttons[button].x == 0 && machine.y%machine.buttons[button].y == 0 {
-		results[button] = machine.x / machine.buttons[button].x
-		results[otherButton] = 0
-		return results
+		pushes := machine.x / machine.buttons[button].x
+		if pushes*machine.buttons[button].y == machine.y {
+			results[button] = pushes
+			results[otherButton] = 0
+			return results
+		}
 	}
 
 	start := min(machine.x/machine.buttons[button].x, machine.y/machine.buttons[button].y)