Browse Source

Able to read input

Piotr Czajkowski 3 weeks ago
parent
commit
a3e6756286
1 changed files with 5 additions and 1 deletions
  1. 5 1
      13/code.go

+ 5 - 1
13/code.go

@@ -41,8 +41,12 @@ func readInput(file *os.File) []Machine {
 
 			machine.buttons = append(machine.buttons, button)
 			buttonsRead++
+		} else {
+			n, err := fmt.Sscanf(line, "Prize: X=%d, Y=%d", &machine.x, &machine.y)
+			if n != 2 || err != nil {
+				log.Fatalf("Not able to parse machine '%s': %s", line, err)
+			}
 		}
-
 	}
 
 	machines = append(machines, machine)