Piotr Czajkowski 3 小时之前
父节点
当前提交
63fdaf7e4c
共有 1 个文件被更改,包括 4 次插入 和 4 次删除
  1. 4 4
      02/code.go

+ 4 - 4
02/code.go

@@ -49,9 +49,9 @@ func part2(program []byte, distances map[byte]map[byte]int) int {
 		moves[program[i]]++
 	}
 
-	for current != 0 {
+	for {
 		var next byte
-		var max int
+		var maximum int
 
 		distancesFromCurrent := distances[current]
 		for j := range path {
@@ -59,8 +59,8 @@ func part2(program []byte, distances map[byte]map[byte]int) int {
 				continue
 			}
 
-			if distancesFromCurrent[path[j]] > max {
-				max = distancesFromCurrent[path[j]]
+			if distancesFromCurrent[path[j]] > maximum {
+				maximum = distancesFromCurrent[path[j]]
 				next = path[j]
 			}
 		}