Piotr Czajkowski 3 miesięcy temu
rodzic
commit
ab0538500b
2 zmienionych plików z 14 dodań i 3 usunięć
  1. 10 3
      11/code.go
  2. 4 0
      11/description.txt

+ 10 - 3
11/code.go

@@ -63,11 +63,15 @@ func processStones(stones map[int]int) map[int]int {
 	return newStones
 }
 
-func part1(stones map[int]int) int {
-	for i := 0; i < 25; i++ {
+func blink(stones map[int]int, blinks int) map[int]int {
+	for i := 0; i < blinks; i++ {
 		stones = processStones(stones)
 	}
 
+	return stones
+}
+
+func countStones(stones map[int]int) int {
 	var result int
 	for _, value := range stones {
 		result += value
@@ -82,5 +86,8 @@ func main() {
 	}
 
 	stones := readInput(os.Args[1])
-	fmt.Println("Part1:", part1(stones))
+	part1Stones := blink(stones, 25)
+	fmt.Println("Part1:", countStones(part1Stones))
+	part2Stones := blink(part1Stones, 50)
+	fmt.Println("Part2:", countStones(part2Stones))
 }

+ 4 - 0
11/description.txt

@@ -63,3 +63,7 @@ The first half of this puzzle is complete! It provides one gold star: *
 The Historians sure are taking a long time. To be fair, the infinite corridors are very large.
 
 How many stones would you have after blinking a total of 75 times?
+
+Your puzzle answer was 274229228071551.
+
+Both parts of this puzzle are complete! They provide two gold stars: **