Start translating to ysh.
This commit is contained in:
1000
2023/1/1/input.txt
1000
2023/1/1/input.txt
File diff suppressed because it is too large
Load Diff
@ -1,42 +0,0 @@
|
||||
--- Day 1: Trebuchet?! ---
|
||||
|
||||
Something is wrong with global snow production, and you've been selected to take
|
||||
a look. The Elves have even given you a map; on it, they've used stars to mark
|
||||
the top fifty locations that are likely to be having problems.
|
||||
|
||||
You've been doing this long enough to know that to restore snow operations, you
|
||||
need to check all fifty stars by December 25th.
|
||||
|
||||
Collect stars by solving puzzles. Two puzzles will be made available on each day
|
||||
in the Advent calendar; the second puzzle is unlocked when you complete the
|
||||
first. Each puzzle grants one star. Good luck!
|
||||
|
||||
You try to ask why they can't just use a weather machine ("not powerful enough")
|
||||
and where they're even sending you ("the sky") and why your map looks mostly
|
||||
blank ("you sure ask a lot of questions") and hang on did you just say the sky
|
||||
("of course, where do you think snow comes from") when you realize that the
|
||||
Elves are already loading you into a trebuchet ("please hold still, we need to
|
||||
strap you in").
|
||||
|
||||
As they're making the final adjustments, they discover that their calibration
|
||||
document (your puzzle input) has been amended by a very young Elf who was
|
||||
apparently just excited to show off her art skills. Consequently, the Elves are
|
||||
having trouble reading the values on the document.
|
||||
|
||||
The newly-improved calibration document consists of lines of text; each line
|
||||
originally contained a specific calibration value that the Elves now need to
|
||||
recover. On each line, the calibration value can be found by combining the first
|
||||
digit and the last digit (in that order) to form a single two-digit number.
|
||||
|
||||
For example:
|
||||
|
||||
1abc2
|
||||
pqr3stu8vwx
|
||||
a1b2c3d4e5f
|
||||
treb7uchet
|
||||
|
||||
In this example, the calibration values of these four lines are 12, 38, 15, and
|
||||
77. Adding these together produces 142.
|
||||
|
||||
Consider your entire calibration document. What is the sum of all of the
|
||||
calibration values?
|
@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
main ()
|
||||
{
|
||||
declare -a components
|
||||
declare -i result=0
|
||||
while read -r line; do
|
||||
mapfile -t matches <<< "$(grep -o '[[:digit:]]' <<< "${line}")"
|
||||
components+=("${matches[0]}${matches[-1]}")
|
||||
done < input.txt
|
||||
for value in "${components[@]}"; do
|
||||
(( result += value ))
|
||||
done
|
||||
echo "${result}"
|
||||
}
|
||||
|
||||
main
|
1000
2023/1/2/input.txt
1000
2023/1/2/input.txt
File diff suppressed because it is too large
Load Diff
@ -1,21 +0,0 @@
|
||||
--- Part Two ---
|
||||
|
||||
Your calculation isn't quite right. It looks like some of the
|
||||
digits are actually spelled out with letters: one, two, three, four, five, six,
|
||||
seven, eight, and nine also count as valid "digits".
|
||||
|
||||
Equipped with this new information, you now need to find the real first and last
|
||||
digit on each line. For example:
|
||||
|
||||
two1nine
|
||||
eightwothree
|
||||
abcone2threexyz
|
||||
xtwone3four
|
||||
4nineeightseven2
|
||||
zoneight234
|
||||
7pqrstsixteen
|
||||
|
||||
In this example, the calibration values are 29, 83, 13, 24, 42, 14, and 76.
|
||||
Adding these together produces 281.
|
||||
|
||||
What is the sum of all of the calibration values?
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
main ()
|
||||
{
|
||||
digit_regex="[[:digit:]]|one|two|three|four|five|six|seven|eight|nine"
|
||||
digit_regex_reverse="[[:digit:]]|eno|owt|eerht|ruof|evif|xis|neves|thgie|enin"
|
||||
declare -A digits=([one]=1 [two]=2 [three]=3 [four]=4 [five]=5 [six]=6 [seven]=7 [eight]=8 [nine]=9)
|
||||
declare -a components
|
||||
declare -i result=0
|
||||
while read -r line; do
|
||||
first=$(grep -E -o "${digit_regex}" <<< "${line}" | head -n 1)
|
||||
last=$(rev <<< "${line}" | grep -E -o "${digit_regex_reverse}" | rev | head -n 1)
|
||||
first=$([[ ! ${first} =~ ^[0-9]$ ]] && echo "${digits[${first}]}" || echo "${first}")
|
||||
last=$([[ ! ${last} =~ ^[0-9]$ ]] && echo "${digits[${last}]}" || echo "${last}")
|
||||
components+=("${first}${last}")
|
||||
done < input.txt
|
||||
for value in "${components[@]}"; do
|
||||
(( result += value ))
|
||||
done
|
||||
echo "${result}"
|
||||
}
|
||||
|
||||
main
|
@ -1,100 +0,0 @@
|
||||
Game 1: 3 blue, 2 green, 6 red; 17 green, 4 red, 8 blue; 2 red, 1 green, 10 blue; 1 blue, 5 green
|
||||
Game 2: 9 red, 2 green; 5 red, 1 blue, 6 green; 3 green, 13 red, 1 blue; 3 red, 6 green; 1 blue, 14 red, 6 green
|
||||
Game 3: 6 red, 3 blue, 8 green; 6 blue, 12 green, 15 red; 3 blue, 18 green, 4 red
|
||||
Game 4: 1 blue, 4 red; 2 blue, 6 red; 13 blue; 11 blue, 1 green, 8 red; 10 blue, 3 green, 2 red; 3 green, 7 blue
|
||||
Game 5: 2 red, 1 blue, 8 green; 2 blue, 7 green, 3 red; 1 blue, 7 green, 4 red; 2 blue, 1 green, 1 red; 13 green, 1 blue
|
||||
Game 6: 7 green, 1 red, 3 blue; 1 red, 4 blue; 6 green, 6 blue; 8 green, 1 red; 6 green, 1 red, 5 blue
|
||||
Game 7: 10 blue, 1 green; 5 red, 8 blue, 3 green; 11 blue, 5 red, 8 green; 2 blue, 8 red, 5 green; 7 blue, 9 green; 6 blue, 2 green, 7 red
|
||||
Game 8: 15 green, 8 blue, 3 red; 6 blue, 7 green, 5 red; 2 green, 1 red, 5 blue; 9 blue, 9 green, 5 red
|
||||
Game 9: 16 red; 5 blue, 6 red, 9 green; 7 blue, 6 green, 2 red; 15 red, 5 blue, 3 green; 1 red, 6 green, 6 blue; 3 blue, 7 red, 5 green
|
||||
Game 10: 17 green, 5 blue, 6 red; 18 green, 9 red; 4 red, 4 blue, 4 green; 10 red, 6 green, 5 blue; 8 red, 4 blue, 12 green
|
||||
Game 11: 4 blue, 2 green, 5 red; 1 blue, 1 red; 9 blue, 1 green, 2 red; 4 red, 10 blue; 3 green, 4 blue, 3 red
|
||||
Game 12: 4 green, 2 blue, 7 red; 4 blue, 2 green, 1 red; 7 green, 5 blue, 9 red
|
||||
Game 13: 1 green, 3 red, 3 blue; 1 blue, 10 green; 2 green, 3 blue
|
||||
Game 14: 7 red, 3 green, 12 blue; 5 red, 4 green, 6 blue; 13 blue, 1 red; 4 blue, 6 red, 2 green; 4 red, 3 blue; 9 red, 13 blue
|
||||
Game 15: 4 blue, 5 red, 2 green; 7 red, 2 blue, 1 green; 17 red, 3 blue; 2 blue; 4 blue, 8 red
|
||||
Game 16: 5 blue; 9 red, 14 green, 5 blue; 5 blue, 9 green
|
||||
Game 17: 3 blue, 5 red; 6 blue, 1 green, 4 red; 7 green, 6 blue, 7 red; 1 red, 6 blue, 4 green; 6 green; 1 blue, 6 green
|
||||
Game 18: 9 blue, 4 green, 2 red; 1 green, 9 red, 10 blue; 14 red, 10 green, 17 blue; 12 red, 1 green, 15 blue; 3 blue, 8 red, 2 green; 3 green, 11 red, 13 blue
|
||||
Game 19: 1 blue, 3 red, 9 green; 14 green, 3 red, 2 blue; 1 blue, 8 red, 11 green; 4 blue, 3 red; 14 red, 4 green; 5 red, 8 green
|
||||
Game 20: 2 blue, 3 red, 2 green; 3 blue, 2 green; 1 red, 4 green, 5 blue; 9 blue, 9 green, 3 red; 3 green, 1 blue, 4 red; 1 red, 9 green, 2 blue
|
||||
Game 21: 11 blue, 6 red; 8 red; 7 red, 6 green, 11 blue; 7 green, 7 red, 11 blue; 6 red, 12 blue
|
||||
Game 22: 7 green, 8 blue, 5 red; 12 green, 4 red, 2 blue; 12 green, 7 red, 11 blue
|
||||
Game 23: 5 green, 2 blue, 7 red; 6 blue, 8 green, 3 red; 10 red, 5 blue; 6 green, 3 blue; 1 green, 8 red
|
||||
Game 24: 17 blue, 1 green, 2 red; 2 red, 11 green, 9 blue; 6 red, 8 blue
|
||||
Game 25: 3 red, 1 blue, 19 green; 1 blue, 1 green, 6 red; 6 green, 5 blue; 4 green, 2 red, 19 blue; 6 red, 19 blue, 18 green; 1 red, 4 blue, 1 green
|
||||
Game 26: 3 red, 4 blue, 2 green; 2 red, 1 green, 3 blue; 14 blue, 1 green, 3 red; 5 green, 2 red, 10 blue; 9 blue, 2 red, 7 green; 15 blue, 4 green, 3 red
|
||||
Game 27: 3 blue, 5 red, 2 green; 6 red, 7 blue, 9 green; 14 green, 11 red, 6 blue; 3 blue, 20 green, 3 red; 6 red, 15 green, 7 blue; 13 red, 1 blue, 14 green
|
||||
Game 28: 4 blue, 7 green, 4 red; 2 red, 4 blue, 7 green; 6 blue, 11 green, 4 red; 6 blue, 6 green, 3 red; 6 green, 12 red
|
||||
Game 29: 3 red, 9 blue; 5 red, 5 blue; 2 green, 3 red, 3 blue
|
||||
Game 30: 1 green, 1 red, 3 blue; 1 blue, 1 red, 3 green; 1 blue; 1 blue, 3 green, 1 red; 2 blue, 2 green
|
||||
Game 31: 2 blue, 1 red; 1 blue, 1 green, 1 red; 4 blue, 3 green; 1 red, 3 green, 2 blue; 2 green
|
||||
Game 32: 1 blue, 6 green; 9 red, 6 green; 1 blue, 15 red, 3 green
|
||||
Game 33: 18 green, 1 blue, 10 red; 10 red, 1 blue, 7 green; 11 green; 6 red, 13 green
|
||||
Game 34: 10 red, 14 blue, 6 green; 2 green, 13 blue, 1 red; 8 green, 7 blue, 1 red; 9 blue, 7 green, 4 red
|
||||
Game 35: 5 blue, 9 green, 2 red; 7 green, 9 blue, 5 red; 1 green, 5 red
|
||||
Game 36: 10 red; 5 red, 1 green, 1 blue; 2 green, 8 red; 9 red, 2 green; 1 blue, 10 red; 6 red, 1 green, 1 blue
|
||||
Game 37: 13 red, 1 blue, 7 green; 1 green, 9 red, 3 blue; 4 red, 1 blue, 11 green; 1 red; 1 red, 1 blue; 6 red, 3 blue, 2 green
|
||||
Game 38: 3 blue, 12 red, 7 green; 1 green; 12 red, 1 blue
|
||||
Game 39: 7 green, 12 blue, 2 red; 3 red, 10 blue, 7 green; 2 red, 8 green, 3 blue; 3 red, 12 blue, 5 green
|
||||
Game 40: 7 green, 5 red; 1 green, 2 blue; 2 red, 1 green, 7 blue
|
||||
Game 41: 1 red, 7 green, 2 blue; 2 green, 2 blue; 4 blue, 7 green, 1 red; 1 blue, 1 red, 7 green; 6 blue, 2 red, 3 green
|
||||
Game 42: 6 blue; 4 green, 18 blue, 1 red; 10 green, 14 blue, 2 red; 6 blue, 4 green; 2 red, 13 blue, 6 green; 6 green, 1 red, 5 blue
|
||||
Game 43: 5 blue, 12 red; 5 blue, 2 green, 7 red; 9 red, 4 blue; 1 green, 11 red, 2 blue; 5 red, 1 green; 2 blue, 3 red, 1 green
|
||||
Game 44: 4 blue, 9 red, 4 green; 4 blue, 10 red; 4 green, 5 red; 1 green, 2 red, 3 blue
|
||||
Game 45: 7 green, 2 blue, 18 red; 19 red, 7 green; 8 green, 1 blue, 19 red; 2 green, 12 red; 6 red, 5 green; 7 green, 10 red
|
||||
Game 46: 1 blue, 15 red, 11 green; 7 red, 1 green, 5 blue; 13 red, 2 blue, 2 green; 7 green, 5 blue, 10 red; 12 green, 3 red, 1 blue
|
||||
Game 47: 2 blue, 2 red, 5 green; 7 green, 2 red, 7 blue; 10 blue, 2 red, 8 green
|
||||
Game 48: 8 green, 10 red; 6 green, 5 red; 12 green, 2 blue; 17 green, 5 red, 1 blue; 14 green, 3 blue, 16 red; 1 blue, 5 red
|
||||
Game 49: 5 blue, 6 red, 12 green; 8 blue, 15 green; 4 blue, 3 green, 3 red; 6 red, 11 green, 10 blue; 9 green, 2 red, 10 blue
|
||||
Game 50: 10 red, 11 green, 14 blue; 6 green, 8 blue, 17 red; 2 blue, 4 red; 6 blue, 8 green, 17 red; 17 red, 9 blue, 2 green; 13 blue, 16 red, 12 green
|
||||
Game 51: 12 red, 2 green, 7 blue; 5 blue, 10 red; 1 blue, 7 red, 1 green; 14 blue, 2 red, 1 green
|
||||
Game 52: 5 blue, 5 red, 8 green; 1 blue, 9 green, 7 red; 4 blue, 5 red, 3 green; 7 green, 2 blue, 2 red; 5 red, 3 blue, 17 green; 19 green, 1 red
|
||||
Game 53: 4 red, 1 blue, 2 green; 1 green; 2 red; 1 blue, 2 green; 2 green, 4 red
|
||||
Game 54: 7 red; 9 red, 2 blue, 14 green; 1 blue, 5 green; 7 green, 3 blue
|
||||
Game 55: 11 blue, 2 green; 11 blue, 9 green, 12 red; 8 green, 6 blue, 12 red
|
||||
Game 56: 2 green, 1 red, 2 blue; 4 red, 5 green, 5 blue; 5 red, 5 blue, 10 green; 8 red, 3 green, 3 blue
|
||||
Game 57: 7 red, 3 green; 1 blue, 6 red, 1 green; 1 blue; 7 red, 1 green, 1 blue; 2 red, 1 blue, 1 green; 3 green, 1 blue
|
||||
Game 58: 9 blue, 2 red; 2 green, 9 blue, 2 red; 5 blue, 4 green
|
||||
Game 59: 8 red; 5 green, 1 blue, 3 red; 1 green, 8 red
|
||||
Game 60: 9 green, 8 blue, 3 red; 10 green, 4 red; 8 blue, 2 green, 4 red; 1 red, 5 green, 7 blue; 1 green, 4 blue, 1 red; 4 blue
|
||||
Game 61: 5 blue, 9 red, 4 green; 5 green, 7 blue, 6 red; 7 green, 8 red; 7 blue, 4 red, 2 green; 8 red, 4 blue, 5 green; 3 green, 9 red, 7 blue
|
||||
Game 62: 9 red, 10 blue; 1 green, 7 red, 13 blue; 1 green, 11 blue; 6 red, 16 blue, 5 green; 20 red, 1 green, 3 blue
|
||||
Game 63: 9 red, 8 green, 1 blue; 13 green, 12 red, 1 blue; 7 green, 5 red, 3 blue
|
||||
Game 64: 3 red, 2 blue, 10 green; 3 green; 1 blue, 8 green, 2 red; 7 red, 1 blue, 4 green; 9 red, 1 blue, 4 green
|
||||
Game 65: 7 red, 6 green; 1 blue, 4 green, 7 red; 6 red; 6 red, 4 green, 1 blue
|
||||
Game 66: 4 blue, 4 green; 1 red, 7 green, 1 blue; 7 green, 3 red, 3 blue; 1 blue, 1 red, 6 green; 3 red, 7 green
|
||||
Game 67: 5 green, 16 blue, 5 red; 4 red, 7 green, 3 blue; 4 red, 4 green, 9 blue; 12 green, 5 red; 15 green, 3 red; 10 blue, 6 red, 1 green
|
||||
Game 68: 3 green, 3 blue, 5 red; 2 green, 6 blue; 2 green, 3 blue, 1 red; 1 blue, 11 red
|
||||
Game 69: 5 green, 1 blue; 16 green, 9 red; 10 red, 18 green
|
||||
Game 70: 1 blue, 1 green; 1 red; 1 red, 2 blue, 1 green; 1 green, 2 red; 2 blue, 2 red; 1 red
|
||||
Game 71: 11 red; 2 green, 3 blue, 13 red; 1 green, 3 blue; 15 red, 1 green, 3 blue; 4 red
|
||||
Game 72: 2 blue, 6 red, 18 green; 6 red, 8 green, 7 blue; 5 blue, 3 red, 12 green; 3 red, 2 blue, 4 green
|
||||
Game 73: 12 blue, 7 green, 4 red; 5 green, 2 red, 4 blue; 3 green, 3 red, 10 blue; 1 green, 12 blue, 6 red; 3 blue, 6 green, 14 red
|
||||
Game 74: 3 red; 1 blue, 8 green, 11 red; 3 green, 2 red
|
||||
Game 75: 5 green, 2 red, 1 blue; 8 green, 2 red; 11 green, 2 red; 2 red, 17 green; 3 blue, 3 green, 2 red
|
||||
Game 76: 1 blue, 5 green, 4 red; 8 green, 11 blue, 5 red; 8 blue, 2 red, 11 green
|
||||
Game 77: 1 red, 11 blue, 7 green; 8 green, 4 blue; 1 blue, 8 green
|
||||
Game 78: 1 green, 1 red, 1 blue; 3 green, 1 blue, 3 red; 10 green, 1 blue; 12 green
|
||||
Game 79: 1 red, 11 blue, 6 green; 3 green, 3 red, 5 blue; 16 blue, 1 red, 5 green; 11 blue, 3 green, 2 red; 8 blue, 6 green, 4 red
|
||||
Game 80: 5 green; 6 green, 7 red, 4 blue; 7 green, 5 blue; 6 blue, 6 green; 7 blue, 7 green; 6 green, 7 blue, 5 red
|
||||
Game 81: 1 green, 14 blue; 11 blue, 1 red; 1 red, 16 green, 2 blue; 9 green, 1 red, 13 blue; 10 green, 8 blue
|
||||
Game 82: 7 green, 7 red, 3 blue; 4 blue, 1 green, 4 red; 2 green, 14 blue, 3 red
|
||||
Game 83: 15 blue; 2 blue, 1 green, 4 red; 8 green, 4 red, 6 blue
|
||||
Game 84: 12 blue, 17 green; 6 green, 1 red, 16 blue; 1 blue, 1 red; 5 blue, 11 green
|
||||
Game 85: 5 blue, 15 green, 3 red; 4 blue, 1 green, 11 red; 8 red, 2 blue, 4 green
|
||||
Game 86: 11 blue, 16 green, 16 red; 11 blue, 17 red, 10 green; 8 green, 7 red
|
||||
Game 87: 2 red, 4 green, 2 blue; 2 blue, 6 green; 2 red, 3 blue, 3 green; 1 red, 4 green; 1 green, 2 blue, 2 red; 4 blue, 4 green
|
||||
Game 88: 10 red, 7 green; 2 blue, 6 red, 1 green; 8 blue, 8 red, 7 green; 2 green, 5 blue, 2 red; 3 blue, 3 red, 6 green
|
||||
Game 89: 9 blue, 16 green; 2 red, 5 blue, 6 green; 12 blue, 15 green; 8 green, 2 red, 3 blue
|
||||
Game 90: 18 red, 1 blue; 3 red, 5 blue, 4 green; 1 blue, 2 green, 6 red; 2 green, 16 red, 3 blue; 5 blue, 13 red, 5 green
|
||||
Game 91: 4 red, 7 green, 1 blue; 3 green, 16 blue, 2 red; 4 green, 8 blue
|
||||
Game 92: 4 red, 3 green; 5 red, 11 green, 1 blue; 16 green, 13 red; 15 green, 14 red, 3 blue; 3 red, 5 green, 2 blue
|
||||
Game 93: 2 blue, 1 red, 3 green; 10 blue, 1 red, 10 green; 11 blue, 16 green, 4 red; 2 green, 20 blue, 7 red; 11 green, 8 red, 15 blue; 9 green, 10 blue, 1 red
|
||||
Game 94: 2 blue, 12 red, 10 green; 16 red, 9 blue, 6 green; 5 green, 9 blue, 11 red; 4 red, 2 blue
|
||||
Game 95: 2 green, 9 red, 1 blue; 2 blue, 1 red; 2 green, 5 blue, 3 red
|
||||
Game 96: 1 green, 5 red, 13 blue; 1 green, 2 red, 13 blue; 2 green, 2 red, 17 blue; 3 red, 1 green; 6 red, 2 green; 1 green, 7 blue, 4 red
|
||||
Game 97: 1 green, 1 red, 1 blue; 2 blue, 11 green; 1 blue, 13 green; 9 blue, 6 green, 1 red; 10 green, 8 blue
|
||||
Game 98: 12 green, 9 red; 12 green, 10 blue, 3 red; 3 red, 13 green, 7 blue
|
||||
Game 99: 8 green, 10 blue, 1 red; 10 green, 2 red, 6 blue; 3 green, 1 blue, 1 red; 10 blue, 1 red
|
||||
Game 100: 8 blue, 6 green, 8 red; 7 red, 2 blue; 2 red, 10 green, 10 blue; 9 green, 7 red; 3 red, 7 green, 1 blue
|
@ -1,51 +0,0 @@
|
||||
--- Day 2: Cube Conundrum ---
|
||||
|
||||
You're launched high into the atmosphere! The apex of your trajectory just
|
||||
barely reaches the surface of a large island floating in the sky. You gently
|
||||
land in a fluffy pile of leaves. It's quite cold, but you don't see much snow.
|
||||
An Elf runs over to greet you.
|
||||
|
||||
The Elf explains that you've arrived at Snow Island and apologizes for the lack
|
||||
of snow. He'll be happy to explain the situation, but it's a bit of a walk, so
|
||||
you have some time. They don't get many visitors up here; would you like to play
|
||||
a game in the meantime?
|
||||
|
||||
As you walk, the Elf shows you a small bag and some cubes which are either red,
|
||||
green, or blue. Each time you play this game, he will hide a secret number of
|
||||
cubes of each color in the bag, and your goal is to figure out information about
|
||||
the number of cubes.
|
||||
|
||||
To get information, once a bag has been loaded with cubes, the Elf will reach
|
||||
into the bag, grab a handful of random cubes, show them to you, and then put
|
||||
them back in the bag. He'll do this a few times per game.
|
||||
|
||||
You play several games and record the information from each game (your puzzle
|
||||
input). Each game is listed with its ID number (like the 11 in Game 11: ...)
|
||||
followed by a semicolon-separated list of subsets of cubes that were revealed
|
||||
from the bag (like 3 red, 5 green, 4 blue).
|
||||
|
||||
For example, the record of a few games might look like this:
|
||||
|
||||
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
|
||||
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
|
||||
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
|
||||
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
|
||||
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
|
||||
|
||||
In game 1, three sets of cubes are revealed from the bag (and then put back
|
||||
again). The first set is 3 blue cubes and 4 red cubes; the second set is 1 red
|
||||
cube, 2 green cubes, and 6 blue cubes; the third set is only 2 green cubes.
|
||||
|
||||
The Elf would first like to know which games would have been possible if the bag
|
||||
contained only 12 red cubes, 13 green cubes, and 14 blue cubes?
|
||||
|
||||
In the example above, games 1, 2, and 5 would have been possible if the bag had
|
||||
been loaded with that configuration. However, game 3 would have been impossible
|
||||
because at one point the Elf showed you 20 red cubes at once; similarly, game 4
|
||||
would also have been impossible because the Elf showed you 15 blue cubes at
|
||||
once. If you add up the IDs of the games that would have been possible, you get
|
||||
8.
|
||||
|
||||
Determine which games would have been possible if the bag had been loaded with
|
||||
only 12 red cubes, 13 green cubes, and 14 blue cubes. What is the sum of the IDs
|
||||
of those games?
|
@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#set -o errexit
|
||||
set -o nounset
|
||||
#set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
main ()
|
||||
{
|
||||
declare -a colors=(red green blue)
|
||||
declare -A limits=([red]=12 [green]=13 [blue]=14)
|
||||
declare -a possible_ids
|
||||
while read -r game; do
|
||||
possible=true
|
||||
stripped_game=$(sed 's/^Game [0-9]\+: //' <<< "${game}")
|
||||
IFS=';' read -r -a sets <<< "${stripped_game}"
|
||||
for (( i=0; i<${#sets[@]}; i++ )); do
|
||||
for color in "${colors[@]}"; do
|
||||
count=$(grep -o "[0-9]* ${color}" <<< "${sets[$i]}" | grep -o '[0-9]*')
|
||||
if [[ $count -gt ${limits[$color]} ]]; then
|
||||
possible=false
|
||||
fi
|
||||
done
|
||||
done
|
||||
if $possible; then
|
||||
id=$(grep -o '[0-9]*' <<< "${game}" | head -n 1)
|
||||
possible_ids+=($id)
|
||||
fi
|
||||
done < input.txt
|
||||
declare -i sum=0
|
||||
for id in "${possible_ids[@]}"; do
|
||||
(( sum+=id ))
|
||||
done
|
||||
echo $sum
|
||||
}
|
||||
|
||||
main
|
@ -1,100 +0,0 @@
|
||||
Game 1: 3 blue, 2 green, 6 red; 17 green, 4 red, 8 blue; 2 red, 1 green, 10 blue; 1 blue, 5 green
|
||||
Game 2: 9 red, 2 green; 5 red, 1 blue, 6 green; 3 green, 13 red, 1 blue; 3 red, 6 green; 1 blue, 14 red, 6 green
|
||||
Game 3: 6 red, 3 blue, 8 green; 6 blue, 12 green, 15 red; 3 blue, 18 green, 4 red
|
||||
Game 4: 1 blue, 4 red; 2 blue, 6 red; 13 blue; 11 blue, 1 green, 8 red; 10 blue, 3 green, 2 red; 3 green, 7 blue
|
||||
Game 5: 2 red, 1 blue, 8 green; 2 blue, 7 green, 3 red; 1 blue, 7 green, 4 red; 2 blue, 1 green, 1 red; 13 green, 1 blue
|
||||
Game 6: 7 green, 1 red, 3 blue; 1 red, 4 blue; 6 green, 6 blue; 8 green, 1 red; 6 green, 1 red, 5 blue
|
||||
Game 7: 10 blue, 1 green; 5 red, 8 blue, 3 green; 11 blue, 5 red, 8 green; 2 blue, 8 red, 5 green; 7 blue, 9 green; 6 blue, 2 green, 7 red
|
||||
Game 8: 15 green, 8 blue, 3 red; 6 blue, 7 green, 5 red; 2 green, 1 red, 5 blue; 9 blue, 9 green, 5 red
|
||||
Game 9: 16 red; 5 blue, 6 red, 9 green; 7 blue, 6 green, 2 red; 15 red, 5 blue, 3 green; 1 red, 6 green, 6 blue; 3 blue, 7 red, 5 green
|
||||
Game 10: 17 green, 5 blue, 6 red; 18 green, 9 red; 4 red, 4 blue, 4 green; 10 red, 6 green, 5 blue; 8 red, 4 blue, 12 green
|
||||
Game 11: 4 blue, 2 green, 5 red; 1 blue, 1 red; 9 blue, 1 green, 2 red; 4 red, 10 blue; 3 green, 4 blue, 3 red
|
||||
Game 12: 4 green, 2 blue, 7 red; 4 blue, 2 green, 1 red; 7 green, 5 blue, 9 red
|
||||
Game 13: 1 green, 3 red, 3 blue; 1 blue, 10 green; 2 green, 3 blue
|
||||
Game 14: 7 red, 3 green, 12 blue; 5 red, 4 green, 6 blue; 13 blue, 1 red; 4 blue, 6 red, 2 green; 4 red, 3 blue; 9 red, 13 blue
|
||||
Game 15: 4 blue, 5 red, 2 green; 7 red, 2 blue, 1 green; 17 red, 3 blue; 2 blue; 4 blue, 8 red
|
||||
Game 16: 5 blue; 9 red, 14 green, 5 blue; 5 blue, 9 green
|
||||
Game 17: 3 blue, 5 red; 6 blue, 1 green, 4 red; 7 green, 6 blue, 7 red; 1 red, 6 blue, 4 green; 6 green; 1 blue, 6 green
|
||||
Game 18: 9 blue, 4 green, 2 red; 1 green, 9 red, 10 blue; 14 red, 10 green, 17 blue; 12 red, 1 green, 15 blue; 3 blue, 8 red, 2 green; 3 green, 11 red, 13 blue
|
||||
Game 19: 1 blue, 3 red, 9 green; 14 green, 3 red, 2 blue; 1 blue, 8 red, 11 green; 4 blue, 3 red; 14 red, 4 green; 5 red, 8 green
|
||||
Game 20: 2 blue, 3 red, 2 green; 3 blue, 2 green; 1 red, 4 green, 5 blue; 9 blue, 9 green, 3 red; 3 green, 1 blue, 4 red; 1 red, 9 green, 2 blue
|
||||
Game 21: 11 blue, 6 red; 8 red; 7 red, 6 green, 11 blue; 7 green, 7 red, 11 blue; 6 red, 12 blue
|
||||
Game 22: 7 green, 8 blue, 5 red; 12 green, 4 red, 2 blue; 12 green, 7 red, 11 blue
|
||||
Game 23: 5 green, 2 blue, 7 red; 6 blue, 8 green, 3 red; 10 red, 5 blue; 6 green, 3 blue; 1 green, 8 red
|
||||
Game 24: 17 blue, 1 green, 2 red; 2 red, 11 green, 9 blue; 6 red, 8 blue
|
||||
Game 25: 3 red, 1 blue, 19 green; 1 blue, 1 green, 6 red; 6 green, 5 blue; 4 green, 2 red, 19 blue; 6 red, 19 blue, 18 green; 1 red, 4 blue, 1 green
|
||||
Game 26: 3 red, 4 blue, 2 green; 2 red, 1 green, 3 blue; 14 blue, 1 green, 3 red; 5 green, 2 red, 10 blue; 9 blue, 2 red, 7 green; 15 blue, 4 green, 3 red
|
||||
Game 27: 3 blue, 5 red, 2 green; 6 red, 7 blue, 9 green; 14 green, 11 red, 6 blue; 3 blue, 20 green, 3 red; 6 red, 15 green, 7 blue; 13 red, 1 blue, 14 green
|
||||
Game 28: 4 blue, 7 green, 4 red; 2 red, 4 blue, 7 green; 6 blue, 11 green, 4 red; 6 blue, 6 green, 3 red; 6 green, 12 red
|
||||
Game 29: 3 red, 9 blue; 5 red, 5 blue; 2 green, 3 red, 3 blue
|
||||
Game 30: 1 green, 1 red, 3 blue; 1 blue, 1 red, 3 green; 1 blue; 1 blue, 3 green, 1 red; 2 blue, 2 green
|
||||
Game 31: 2 blue, 1 red; 1 blue, 1 green, 1 red; 4 blue, 3 green; 1 red, 3 green, 2 blue; 2 green
|
||||
Game 32: 1 blue, 6 green; 9 red, 6 green; 1 blue, 15 red, 3 green
|
||||
Game 33: 18 green, 1 blue, 10 red; 10 red, 1 blue, 7 green; 11 green; 6 red, 13 green
|
||||
Game 34: 10 red, 14 blue, 6 green; 2 green, 13 blue, 1 red; 8 green, 7 blue, 1 red; 9 blue, 7 green, 4 red
|
||||
Game 35: 5 blue, 9 green, 2 red; 7 green, 9 blue, 5 red; 1 green, 5 red
|
||||
Game 36: 10 red; 5 red, 1 green, 1 blue; 2 green, 8 red; 9 red, 2 green; 1 blue, 10 red; 6 red, 1 green, 1 blue
|
||||
Game 37: 13 red, 1 blue, 7 green; 1 green, 9 red, 3 blue; 4 red, 1 blue, 11 green; 1 red; 1 red, 1 blue; 6 red, 3 blue, 2 green
|
||||
Game 38: 3 blue, 12 red, 7 green; 1 green; 12 red, 1 blue
|
||||
Game 39: 7 green, 12 blue, 2 red; 3 red, 10 blue, 7 green; 2 red, 8 green, 3 blue; 3 red, 12 blue, 5 green
|
||||
Game 40: 7 green, 5 red; 1 green, 2 blue; 2 red, 1 green, 7 blue
|
||||
Game 41: 1 red, 7 green, 2 blue; 2 green, 2 blue; 4 blue, 7 green, 1 red; 1 blue, 1 red, 7 green; 6 blue, 2 red, 3 green
|
||||
Game 42: 6 blue; 4 green, 18 blue, 1 red; 10 green, 14 blue, 2 red; 6 blue, 4 green; 2 red, 13 blue, 6 green; 6 green, 1 red, 5 blue
|
||||
Game 43: 5 blue, 12 red; 5 blue, 2 green, 7 red; 9 red, 4 blue; 1 green, 11 red, 2 blue; 5 red, 1 green; 2 blue, 3 red, 1 green
|
||||
Game 44: 4 blue, 9 red, 4 green; 4 blue, 10 red; 4 green, 5 red; 1 green, 2 red, 3 blue
|
||||
Game 45: 7 green, 2 blue, 18 red; 19 red, 7 green; 8 green, 1 blue, 19 red; 2 green, 12 red; 6 red, 5 green; 7 green, 10 red
|
||||
Game 46: 1 blue, 15 red, 11 green; 7 red, 1 green, 5 blue; 13 red, 2 blue, 2 green; 7 green, 5 blue, 10 red; 12 green, 3 red, 1 blue
|
||||
Game 47: 2 blue, 2 red, 5 green; 7 green, 2 red, 7 blue; 10 blue, 2 red, 8 green
|
||||
Game 48: 8 green, 10 red; 6 green, 5 red; 12 green, 2 blue; 17 green, 5 red, 1 blue; 14 green, 3 blue, 16 red; 1 blue, 5 red
|
||||
Game 49: 5 blue, 6 red, 12 green; 8 blue, 15 green; 4 blue, 3 green, 3 red; 6 red, 11 green, 10 blue; 9 green, 2 red, 10 blue
|
||||
Game 50: 10 red, 11 green, 14 blue; 6 green, 8 blue, 17 red; 2 blue, 4 red; 6 blue, 8 green, 17 red; 17 red, 9 blue, 2 green; 13 blue, 16 red, 12 green
|
||||
Game 51: 12 red, 2 green, 7 blue; 5 blue, 10 red; 1 blue, 7 red, 1 green; 14 blue, 2 red, 1 green
|
||||
Game 52: 5 blue, 5 red, 8 green; 1 blue, 9 green, 7 red; 4 blue, 5 red, 3 green; 7 green, 2 blue, 2 red; 5 red, 3 blue, 17 green; 19 green, 1 red
|
||||
Game 53: 4 red, 1 blue, 2 green; 1 green; 2 red; 1 blue, 2 green; 2 green, 4 red
|
||||
Game 54: 7 red; 9 red, 2 blue, 14 green; 1 blue, 5 green; 7 green, 3 blue
|
||||
Game 55: 11 blue, 2 green; 11 blue, 9 green, 12 red; 8 green, 6 blue, 12 red
|
||||
Game 56: 2 green, 1 red, 2 blue; 4 red, 5 green, 5 blue; 5 red, 5 blue, 10 green; 8 red, 3 green, 3 blue
|
||||
Game 57: 7 red, 3 green; 1 blue, 6 red, 1 green; 1 blue; 7 red, 1 green, 1 blue; 2 red, 1 blue, 1 green; 3 green, 1 blue
|
||||
Game 58: 9 blue, 2 red; 2 green, 9 blue, 2 red; 5 blue, 4 green
|
||||
Game 59: 8 red; 5 green, 1 blue, 3 red; 1 green, 8 red
|
||||
Game 60: 9 green, 8 blue, 3 red; 10 green, 4 red; 8 blue, 2 green, 4 red; 1 red, 5 green, 7 blue; 1 green, 4 blue, 1 red; 4 blue
|
||||
Game 61: 5 blue, 9 red, 4 green; 5 green, 7 blue, 6 red; 7 green, 8 red; 7 blue, 4 red, 2 green; 8 red, 4 blue, 5 green; 3 green, 9 red, 7 blue
|
||||
Game 62: 9 red, 10 blue; 1 green, 7 red, 13 blue; 1 green, 11 blue; 6 red, 16 blue, 5 green; 20 red, 1 green, 3 blue
|
||||
Game 63: 9 red, 8 green, 1 blue; 13 green, 12 red, 1 blue; 7 green, 5 red, 3 blue
|
||||
Game 64: 3 red, 2 blue, 10 green; 3 green; 1 blue, 8 green, 2 red; 7 red, 1 blue, 4 green; 9 red, 1 blue, 4 green
|
||||
Game 65: 7 red, 6 green; 1 blue, 4 green, 7 red; 6 red; 6 red, 4 green, 1 blue
|
||||
Game 66: 4 blue, 4 green; 1 red, 7 green, 1 blue; 7 green, 3 red, 3 blue; 1 blue, 1 red, 6 green; 3 red, 7 green
|
||||
Game 67: 5 green, 16 blue, 5 red; 4 red, 7 green, 3 blue; 4 red, 4 green, 9 blue; 12 green, 5 red; 15 green, 3 red; 10 blue, 6 red, 1 green
|
||||
Game 68: 3 green, 3 blue, 5 red; 2 green, 6 blue; 2 green, 3 blue, 1 red; 1 blue, 11 red
|
||||
Game 69: 5 green, 1 blue; 16 green, 9 red; 10 red, 18 green
|
||||
Game 70: 1 blue, 1 green; 1 red; 1 red, 2 blue, 1 green; 1 green, 2 red; 2 blue, 2 red; 1 red
|
||||
Game 71: 11 red; 2 green, 3 blue, 13 red; 1 green, 3 blue; 15 red, 1 green, 3 blue; 4 red
|
||||
Game 72: 2 blue, 6 red, 18 green; 6 red, 8 green, 7 blue; 5 blue, 3 red, 12 green; 3 red, 2 blue, 4 green
|
||||
Game 73: 12 blue, 7 green, 4 red; 5 green, 2 red, 4 blue; 3 green, 3 red, 10 blue; 1 green, 12 blue, 6 red; 3 blue, 6 green, 14 red
|
||||
Game 74: 3 red; 1 blue, 8 green, 11 red; 3 green, 2 red
|
||||
Game 75: 5 green, 2 red, 1 blue; 8 green, 2 red; 11 green, 2 red; 2 red, 17 green; 3 blue, 3 green, 2 red
|
||||
Game 76: 1 blue, 5 green, 4 red; 8 green, 11 blue, 5 red; 8 blue, 2 red, 11 green
|
||||
Game 77: 1 red, 11 blue, 7 green; 8 green, 4 blue; 1 blue, 8 green
|
||||
Game 78: 1 green, 1 red, 1 blue; 3 green, 1 blue, 3 red; 10 green, 1 blue; 12 green
|
||||
Game 79: 1 red, 11 blue, 6 green; 3 green, 3 red, 5 blue; 16 blue, 1 red, 5 green; 11 blue, 3 green, 2 red; 8 blue, 6 green, 4 red
|
||||
Game 80: 5 green; 6 green, 7 red, 4 blue; 7 green, 5 blue; 6 blue, 6 green; 7 blue, 7 green; 6 green, 7 blue, 5 red
|
||||
Game 81: 1 green, 14 blue; 11 blue, 1 red; 1 red, 16 green, 2 blue; 9 green, 1 red, 13 blue; 10 green, 8 blue
|
||||
Game 82: 7 green, 7 red, 3 blue; 4 blue, 1 green, 4 red; 2 green, 14 blue, 3 red
|
||||
Game 83: 15 blue; 2 blue, 1 green, 4 red; 8 green, 4 red, 6 blue
|
||||
Game 84: 12 blue, 17 green; 6 green, 1 red, 16 blue; 1 blue, 1 red; 5 blue, 11 green
|
||||
Game 85: 5 blue, 15 green, 3 red; 4 blue, 1 green, 11 red; 8 red, 2 blue, 4 green
|
||||
Game 86: 11 blue, 16 green, 16 red; 11 blue, 17 red, 10 green; 8 green, 7 red
|
||||
Game 87: 2 red, 4 green, 2 blue; 2 blue, 6 green; 2 red, 3 blue, 3 green; 1 red, 4 green; 1 green, 2 blue, 2 red; 4 blue, 4 green
|
||||
Game 88: 10 red, 7 green; 2 blue, 6 red, 1 green; 8 blue, 8 red, 7 green; 2 green, 5 blue, 2 red; 3 blue, 3 red, 6 green
|
||||
Game 89: 9 blue, 16 green; 2 red, 5 blue, 6 green; 12 blue, 15 green; 8 green, 2 red, 3 blue
|
||||
Game 90: 18 red, 1 blue; 3 red, 5 blue, 4 green; 1 blue, 2 green, 6 red; 2 green, 16 red, 3 blue; 5 blue, 13 red, 5 green
|
||||
Game 91: 4 red, 7 green, 1 blue; 3 green, 16 blue, 2 red; 4 green, 8 blue
|
||||
Game 92: 4 red, 3 green; 5 red, 11 green, 1 blue; 16 green, 13 red; 15 green, 14 red, 3 blue; 3 red, 5 green, 2 blue
|
||||
Game 93: 2 blue, 1 red, 3 green; 10 blue, 1 red, 10 green; 11 blue, 16 green, 4 red; 2 green, 20 blue, 7 red; 11 green, 8 red, 15 blue; 9 green, 10 blue, 1 red
|
||||
Game 94: 2 blue, 12 red, 10 green; 16 red, 9 blue, 6 green; 5 green, 9 blue, 11 red; 4 red, 2 blue
|
||||
Game 95: 2 green, 9 red, 1 blue; 2 blue, 1 red; 2 green, 5 blue, 3 red
|
||||
Game 96: 1 green, 5 red, 13 blue; 1 green, 2 red, 13 blue; 2 green, 2 red, 17 blue; 3 red, 1 green; 6 red, 2 green; 1 green, 7 blue, 4 red
|
||||
Game 97: 1 green, 1 red, 1 blue; 2 blue, 11 green; 1 blue, 13 green; 9 blue, 6 green, 1 red; 10 green, 8 blue
|
||||
Game 98: 12 green, 9 red; 12 green, 10 blue, 3 red; 3 red, 13 green, 7 blue
|
||||
Game 99: 8 green, 10 blue, 1 red; 10 green, 2 red, 6 blue; 3 green, 1 blue, 1 red; 10 blue, 1 red
|
||||
Game 100: 8 blue, 6 green, 8 red; 7 red, 2 blue; 2 red, 10 green, 10 blue; 9 green, 7 red; 3 red, 7 green, 1 blue
|
@ -1,34 +0,0 @@
|
||||
--- Part Two ---
|
||||
|
||||
The Elf says they've stopped producing snow because they aren't getting any
|
||||
water! He isn't sure why the water stopped; however, he can show you how to get
|
||||
to the water source to check it out for yourself. It's just up ahead!
|
||||
|
||||
As you continue your walk, the Elf poses a second question: in each game you
|
||||
played, what is the fewest number of cubes of each color that could have been in
|
||||
the bag to make the game possible?
|
||||
|
||||
Again consider the example games from earlier:
|
||||
|
||||
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
|
||||
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
|
||||
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
|
||||
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
|
||||
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
|
||||
|
||||
In game 1, the game could have been played with as few as 4 red, 2 green, and 6
|
||||
blue cubes. If any color had even one fewer cube, the game would have been
|
||||
impossible.
|
||||
|
||||
Game 2 could have been played with a minimum of 1 red, 3 green, and 4 blue cubes.
|
||||
Game 3 must have been played with at least 20 red, 13 green, and 6 blue cubes.
|
||||
Game 4 required at least 14 red, 3 green, and 15 blue cubes.
|
||||
Game 5 needed no fewer than 6 red, 3 green, and 2 blue cubes in the bag.
|
||||
|
||||
The power of a set of cubes is equal to the numbers of red, green, and blue
|
||||
cubes multiplied together. The power of the minimum set of cubes in game 1 is
|
||||
48. In games 2-5 it was 12, 1560, 630, and 36, respectively. Adding up these
|
||||
five powers produces the sum 2286.
|
||||
|
||||
For each game, find the minimum set of cubes that must have been present. What
|
||||
is the sum of the power of these sets?
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#set -o errexit
|
||||
set -o nounset
|
||||
#set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
main ()
|
||||
{
|
||||
declare -a colors=(red green blue)
|
||||
declare -i powers=0
|
||||
while read -r game; do
|
||||
declare -A colors_max=([red]=0 [green]=0 [blue]=0)
|
||||
stripped_game=$(sed 's/^Game [0-9]\+: //' <<< "${game}")
|
||||
IFS=';' read -r -a sets <<< "${stripped_game}"
|
||||
for (( i=0; i<${#sets[@]}; i++ )); do
|
||||
for color in "${colors[@]}"; do
|
||||
count=$(grep -o "[0-9]* ${color}" <<< "${sets[$i]}" | grep -o '[0-9]*')
|
||||
if [[ $count -gt ${colors_max[$color]} ]]; then
|
||||
colors_max[$color]=$count
|
||||
fi
|
||||
done
|
||||
done
|
||||
(( powers+=colors_max[red]*colors_max[green]*colors_max[blue] ))
|
||||
done < input.txt
|
||||
echo $powers
|
||||
}
|
||||
|
||||
main
|
@ -1,140 +0,0 @@
|
||||
.........426.............985.........40..........207............................841..463................................633........17.384...
|
||||
531&......+..........125....-..312..........#........895......998..945.....@......$.....-...33...................353.....*........*.........
|
||||
........................#......*...........21..727..*..../..-./.............545......80...................602......@..272.......743.........
|
||||
...........558.577..........486...186*925.....*....483.883.1....286...................................625..................#474.....491.....
|
||||
..............*.........243.................287................*............$....245............830.........793......#..........306..*......
|
||||
238.685.................*................#.........%........807.........28.947.................*.....705.....*....573...500*781...#..496....
|
||||
..................989..923.......713...539......917.................115..*.....-...........662.........-......413...........................
|
||||
...........=......*..........886.*.........................442......*...........398........*.............%.............636...........%......
|
||||
............976.413...498..../...266........796....................87.....................969.881..&.....815...........*.....279....415.....
|
||||
......728*..............*..............129..........670...890.....................760...=.......@.832........227.....632.212*...............
|
||||
..........257.....712.491....-41...........970........*....*...373........742.......*....330....................*.....................814...
|
||||
....................*..................415......406..441..35..../.........-..........828.........................239.....@...533*206........
|
||||
......687.........834......448...658...*..........&..................467*..................244.......+332....*..........35..............*...
|
||||
.............453.......616..*...........609.............662......672.....56........661.602*...............549.661...................141..73.
|
||||
.......699...*.........*...904..........................&..........*...@..............................189..........$677.......473.....*.....
|
||||
........*..670.........938.........267.......684...........514...211....875.........667..171.110&.426*......../...............*........29...
|
||||
.....164..........................*....@786.*..........646.=.........43.......885....+...=.............641.....996...........117....28......
|
||||
.........*921....150*....635..973............587...346*......771........&3....+....................=................................@.......
|
||||
......962............821....*...*...........................$....174............391+......732*177...101.....146.............555.............
|
||||
..........................117.965.........327.....................*../127.54.........354.....................*...37/.......&....56....656...
|
||||
.335.747*967..*469.................................-.....$.450..560...........553...+.......327*..........215.........950..............-....
|
||||
......................253%...........796.........267...946..*........&...583.-...........-......727.37........@....#....-.......337.........
|
||||
.............-...............-.649.........-.................316..680......*.....982..398..................961......632...718......*..%.....
|
||||
..........599.............876......700..617....344*138...611..........907........-...........................................*...291...209..
|
||||
.860...........................*......*......................850........*..............=....761...721*804...............%...33..............
|
||||
...*...........................61./....378........268....956..#..813@..191...610.168..216....$...............853%......826..................
|
||||
.757..=422.........................427..........+....%....=...................#.../..............908................@.......................
|
||||
.........................172.................464...........................-.....................*.......667...931...131..@.........939.....
|
||||
............456.....462....*.....985................801......933..464..641.874............*189..42.........................430..596...=.....
|
||||
..............*....%........945.@........456....*23...........*..........*.............335.........889..557#....................*...........
|
||||
....810.........65......382................#.532...............704......796...192....................@..........46...527......929...........
|
||||
...=....%..................*433...........................925.............................................30.....*................617.......
|
||||
.....792.......386.....................575...%859................................................................993...334*..........&......
|
||||
..........657.&.....&....................*.....................296.+513.............36..........267........703.............186..............
|
||||
......336...........443...#.....474......897.215*346.....100.....=...........+.812../......47.%....*444..&............128........-...196....
|
||||
705.............980......932.......*122..................*...........305..817..*......424.../.40.........193.210.736.*..../....&.512..*.....
|
||||
...%...............*.....................................326..615.......*.......472..*...........350*201.......*..@....681...902......330...
|
||||
...................907...303...........140*112.............../........93...875......339....361=.............730.............................
|
||||
..............540...........*...................498.170.....................*....................#...757........241...............201.......
|
||||
...359*42.....=.......309...561....528.....444.....*........570............................125/.379......707.......*........*285.$..........
|
||||
............%.........................*770.............253..*....515..926..................................=........45.946..............*...
|
||||
....155..573..103.24..............................@......*...179..*........275......................*...................*................134
|
||||
....*............*......963...........444......801...656.796.....524.84#......*433.......997.....122.500....711.......447...................
|
||||
..80.........992..........*............*...+..........*....................................*.................*...............$.....894...61.
|
||||
........183..../.......492..955....+.222....519........373....=......304........151.........691..............655......223....37......*......
|
||||
.........$...................&..221................859.....929.......*...398.......*......-......591.....&.............$..........134.......
|
||||
................960......264........./..............#..............508...@........118..449........*...907......=791.........................
|
||||
...........239....#.....=...........248.531...................@..................................696.......741...................50..174....
|
||||
.....=......*............................*.....506*809.....796.....906.....=...........17*...........51...*.......................*..*......
|
||||
...520...198...781....253..............957.222.....................*.....216..............513....959*....638.312........172.318......514....
|
||||
...............*.........*239...............*.....%.....923.........852..............414+............../.....%...104.......*.............936
|
||||
.....221.....116.....712...........201...346...475.........*...............&..............745....109..202...........*.......................
|
||||
....*............957*.....$....353...............................171....468....%..........*.........*.........906..593..592#......&316......
|
||||
.........232...........251....#.......%.......................$...*...........179..904.....365.....331..541..*..............................
|
||||
...................................856..........412..-....844.877..871....*.........../.................*....416...........810*685..776.969.
|
||||
.158.......@......319........681..........780.#...+...428.*............650.241....@....................................123.............*....
|
||||
....%....826......@....%.688*.......983../....723.........892...................270.....234....*......443...970...........*.................
|
||||
....................314................*.................................................*..=...588......*.....%........225...496*732.......
|
||||
...344+........................644......413.997....553...................................87.282..........943........866.....................
|
||||
..........*563....910......267..*..546........*.....*..................60.............+..........421*739.............*...251.169.605........
|
||||
938.....52...........*761.*....762............335....842.....................44/.......528..........................77......*.......*201....
|
||||
..........................597......$.....................896.....543.76.........................938./707...............8........982.........
|
||||
...894..195.......310*986.....=54.854...553................#.......*...*..192...127..566*768..........................*....850...*..970.....
|
||||
.....*..................................=...835...874...........663...65..*.....*.................*947..539.12...947.485.....*..749..*......
|
||||
......34.378........$............#.........*......*......922...............947.598..880........723.....*....*...@..........791........18....
|
||||
..165.............388..94.......863........132.184..973.*.......58.................*......226..............618.....................=........
|
||||
.....*.............................................@.....154.............240..34.297.......*...........429.....625...............672........
|
||||
......619...#............641*520.340.918............................../..@...............390......502..-..../.*.....164....789........984...
|
||||
.............933.....................*.....838..240..400&..........288.......196..109............*.......749...513........*.......751...*...
|
||||
.....709.....................881..905.........*....*.....................643..*.....@...114...608......................190..........*....993
|
||||
...............109...........*........368..123....98...501.....691..410-...*.126......................92........+..546...........219........
|
||||
..................*......18..70..296.....*..............&..987..*........235............8.............././...828...*........................
|
||||
.151.............551.153*..........*.....883...............*.......*833........497..287*..427.377%.428...910......448.598.....334..53..619..
|
||||
..........589.......................723.........832.131..705.............................#............*.................@......*...*..*.....
|
||||
..........*........794*686......790...............*..........192..............................970......612.546.98............942......941...
|
||||
....223.686..............................547...665.......396..*.....210......408.322..839.......*..557......*...+.................521.......
|
||||
.....*.......170...........166.....390..............100.....*..921....*.........*.....+........984....*..450..........639..../....*...296...
|
||||
...372..........*760...266.*...600*......999.........*...906........................#....632.......469........250.......*...422..643....@...
|
||||
..............-........#...911......494...*...355...159.......................848..676.................../.....*......35....................
|
||||
......81$.....544..67...............*.....159....*............209.747*29........./..........812.........430.232...................199*587...
|
||||
760.................*...#........331.................%...158...................#.....................29.................596...477...........
|
||||
..........%./....922...388..970...............510...68......*....590....545...621...-..977.593..889...*.........................=..879..*389
|
||||
....163.618.370..............................*...............946..................332....*.......&..&..837.658......................*.......
|
||||
.............................835.....129...566.....690.237..............#.............$.....386....36......#......411.....52..733...783.....
|
||||
.........670...978.84...........=......*.......991*....*....632.......957...52.......548.....&....................*.........-.*.............
|
||||
....920....*..*.....*...............949..............482...*......812........-...413.....201................663.286.....-......424...296*630
|
||||
........992...307...634.................716..287.........811.....+........4......*...413*.........896......*...........84.52................
|
||||
.........................253.............................................*.....459..........926..*.......446..............$.......175.......
|
||||
.........................*.......168-.....781*......344.........85......373..........224.....*..393.545........749%.643......-..%.....968...
|
||||
...*776../145...&.....140..........................*........578*........................#..45..........*............/......596..639.........
|
||||
415............393..................988...........878.22..............909..........284...............173...564*48.......33.............444..
|
||||
........259..........%.....207-........*631...........*......669*...................*...........282......%........%.....*...................
|
||||
.130................119.....................422......440.........461...-154........575.............$.=....329...180..576.....367............
|
||||
...........618...............=.../..538$.......&............493*............729..........903.........82.......................*.............
|
||||
.............*............541..124.........627........806*......666.703.146*...........*.%..............-.....................142........551
|
||||
...#..3......660.....................*........*.......................*......./164...498..............872.621....991........................
|
||||
174....*...............683..542*.....960.....782.....755............557../.....................#282.......#.........*409.103.......943......
|
||||
........231.891...........*.....782.....................*992.............492......69.......610...............+...............557......*.....
|
||||
............*...964.104.289..........853......691..830.......&.....................*...870.*.............77..189.310*...............583.....
|
||||
....449....435.*....../........732+.=.........*...*.........238...161.....688......675..*...934......................891....................
|
||||
...............21.......................239........430..........@....*.....@..376.......205......790........................73..334...598...
|
||||
......863-................474...339.....*.................765.534.116...........*..................*..........@.......513...-....%...../....
|
||||
.262..........#......785....*..$....915..622....440$.&416.*.............143...34..45....515#....448...........268........*..................
|
||||
...*..+.......844......*.142..................*...........666.......266...*......*...................236..............439......338.496...285
|
||||
647...393...........236.......218..........819.779...+................./.........765...................*.......292.........$......*.........
|
||||
..........................257....*.................274.........247...........951........................121........391....817.../...........
|
||||
........742..................&....98...................628....*.................%.168..........539............................701...........
|
||||
.......................659................................*.622...868.............=...713.357....*.298....917...781.........................
|
||||
.....467....382..899......*819.....952*388..............684.......*.....................*.....558...%....%...............$..*.....60..615...
|
||||
.....*.....*.......*............-..........604.................85.76....%893.866.&...784.....................$423.....334....935..*....*....
|
||||
..154....424......583.......8....926...$............$441.....................*...50...............=....155.......................599..115...
|
||||
.............%............-...........96.506..846.................152.....985..........589.......384...@...44...............560.............
|
||||
.............161...%167..906..901.........*......&....92..+610.......*247.............*...................*...........330..*....92..........
|
||||
....26.........................*...........523........*......................190...711.......*..........302.690.........*.986........714@...
|
||||
........154.....................763..59..............305..560...726......79...*...........521.160..159................81....................
|
||||
991.339*........-.........434..........*....................-..*.........*..626....................*..............692......+................
|
||||
..............448.....96./...........782............353........949.....655...............752.522....905...964#......-.683..83...............
|
||||
.......=..........127../.........$....................../.......................................*......................+.........671........
|
||||
.783..14...........*...........746....271.38............666..................513..37.....=984.824....@....$..463.................*...154....
|
||||
.................60..892..304............*....354*20.................99.........*..%.351............367..914.*....622...........310...*..194
|
||||
.../.....339............*......318..........6.................329*...*..240.....76...*...45....*..............601......+.............211....
|
||||
.700...../...925......616...........*56.570.$...970...751...........556..%..958.....50..*...667........63...........793.....................
|
||||
...............................8.........*........*......*854................*.........304........324.....%..................*.....213%.....
|
||||
832...............%....$.........572......303.....872.=.............822.....2...434........%..76.@......34...866.684*.......571..........756
|
||||
.....922........908.811......792....#.967..............432..............304......+........676......314........*..................364....#...
|
||||
........................=.....*.........*.......39............127.........*........27..............+.........937.172.....532*......&........
|
||||
....*.............156....626...667......151..../.......................776..846...*............562.....254$......../..@......297.......751..
|
||||
..457.213.....403*....=......................#.......656.....546%..............*.......*866......+...................954.576...........%....
|
||||
.........*..........227........364....752..977.231..*...........................739.610...................................*...730..#........
|
||||
......838......645........$692.................*....170...............906........................149.....578..470.........981.....310.......
|
||||
959...........*....447.................33.513...412..........784.......*....................365.....%....*..................................
|
||||
...../......593......*....=..965..=907...*.............................482.....................*.......915..............327...529.....425...
|
||||
......613.........%.490..971.-..............&542..............................695.......803.....917........446.....53...*........*455..$....
|
||||
...............258..................+..303+..........................517....7*....598..@....472.....224...*............903..#...............
|
||||
........................724...+....575........312...&.........................................*....*......628........@.....108..............
|
||||
.....343.374.......$....*....675...............%...371......409.....502.928.135...482.384....195...59.............144..982........787.......
|
||||
....*....*.......289..729..........990....................../.........+.......*..*......*...............*.@...........#.............+.......
|
||||
....147...613.............*534.........938....882...740.518.....994..........800.222..933...836.......260..339.=...........628.$935...../...
|
||||
...............726.....308.............%........*...../.+........=..../146.................*...................509..........*........593....
|
||||
930.........................823..............994.................................100.....857.......................708.220.184..............
|
@ -1,44 +0,0 @@
|
||||
--- Day 3: Gear Ratios ---
|
||||
|
||||
You and the Elf eventually reach a gondola lift station; he says the gondola
|
||||
lift will take you up to the water source, but this is as far as he can bring
|
||||
you. You go inside.
|
||||
|
||||
It doesn't take long to find the gondolas, but there seems to be a problem:
|
||||
they're not moving.
|
||||
|
||||
"Aaah!"
|
||||
|
||||
You turn around to see a slightly-greasy Elf with a wrench and a look of
|
||||
surprise. "Sorry, I wasn't expecting anyone! The gondola lift isn't working
|
||||
right now; it'll still be a while before I can fix it." You offer to help.
|
||||
|
||||
The engineer explains that an engine part seems to be missing from the engine,
|
||||
but nobody can figure out which one. If you can add up all the part numbers in
|
||||
the engine schematic, it should be easy to work out which part is missing.
|
||||
|
||||
The engine schematic (your puzzle input) consists of a visual representation of
|
||||
the engine. There are lots of numbers and symbols you don't really understand,
|
||||
but apparently any number adjacent to a symbol, even diagonally, is a "part
|
||||
number" and should be included in your sum. (Periods (.) do not count as a
|
||||
symbol.)
|
||||
|
||||
Here is an example engine schematic:
|
||||
|
||||
467..114..
|
||||
...*......
|
||||
..35..633.
|
||||
......#...
|
||||
617*......
|
||||
.....+.58.
|
||||
..592.....
|
||||
......755.
|
||||
...$.*....
|
||||
.664.598..
|
||||
|
||||
In this schematic, two numbers are not part numbers because they are not
|
||||
adjacent to a symbol: 114 (top right) and 58 (middle right). Every other number
|
||||
is adjacent to a symbol and so is a part number; their sum is 4361.
|
||||
|
||||
Of course, the actual engine schematic is much larger. What is the sum of all of
|
||||
the part numbers in the engine schematic?
|
@ -1,74 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
LINES=$(wc -l < "$1")
|
||||
COLUMNS=140
|
||||
mapfile -t -O 1 INPUT < "$1"
|
||||
declare -a valid_numbers
|
||||
|
||||
find_numbers ()
|
||||
{
|
||||
# Find and append valid numbers to array.
|
||||
for ((line=1; line<=LINES; line++)); do
|
||||
for ((column=1; column<=COLUMNS; column++)); do
|
||||
if [[ $(arr "${line}" $((column-1))) =~ ^[0-9]$ ]]; then
|
||||
continue # not start of number
|
||||
else
|
||||
local number='' length=0
|
||||
for ((i=column; ; i++)); do # find length
|
||||
if [[ $(arr "${line}" "${i}") =~ ^[0-9]$ ]]; then
|
||||
((length++)) || true
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
[[ length -gt 0 ]] || continue # not a number
|
||||
for ((i=0; i<length; i++)); do # get number
|
||||
number+="$(arr "${line}" $((column+i)))"
|
||||
done
|
||||
declare -a to_check=("${line},$((column-1))" "${line},$((column+length))") # before and after
|
||||
for ((i=column-1; i<=column+length; i++)); do
|
||||
to_check+=("$((line-1)),${i}") # above
|
||||
to_check+=("$((line+1)),${i}") # below
|
||||
done
|
||||
for ((i=0; i<${#to_check[@]}; i++)); do
|
||||
if [[ $(arr "${to_check[i]%,*}" "${to_check[i]#*,}") =~ ^(\$|\*|/|=|\+|-|#|@|&|%)$ ]]; then
|
||||
valid_numbers+=("${number}")
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
arr ()
|
||||
{
|
||||
# Usage: arr LINE COLUMN
|
||||
line="$1"
|
||||
column=$(($2-1))
|
||||
if ((line<=0)) || ((line>LINES)) || ((column<0)); then
|
||||
echo -n ''
|
||||
else
|
||||
echo -n "${INPUT[${line}]:${column}:1}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main ()
|
||||
{
|
||||
find_numbers
|
||||
sum=0
|
||||
for number in "${valid_numbers[@]}"; do
|
||||
sum=$((sum+number))
|
||||
done
|
||||
echo $sum
|
||||
}
|
||||
|
||||
main
|
@ -1,140 +0,0 @@
|
||||
.........426.............985.........40..........207............................841..463................................633........17.384...
|
||||
531&......+..........125....-..312..........#........895......998..945.....@......$.....-...33...................353.....*........*.........
|
||||
........................#......*...........21..727..*..../..-./.............545......80...................602......@..272.......743.........
|
||||
...........558.577..........486...186*925.....*....483.883.1....286...................................625..................#474.....491.....
|
||||
..............*.........243.................287................*............$....245............830.........793......#..........306..*......
|
||||
238.685.................*................#.........%........807.........28.947.................*.....705.....*....573...500*781...#..496....
|
||||
..................989..923.......713...539......917.................115..*.....-...........662.........-......413...........................
|
||||
...........=......*..........886.*.........................442......*...........398........*.............%.............636...........%......
|
||||
............976.413...498..../...266........796....................87.....................969.881..&.....815...........*.....279....415.....
|
||||
......728*..............*..............129..........670...890.....................760...=.......@.832........227.....632.212*...............
|
||||
..........257.....712.491....-41...........970........*....*...373........742.......*....330....................*.....................814...
|
||||
....................*..................415......406..441..35..../.........-..........828.........................239.....@...533*206........
|
||||
......687.........834......448...658...*..........&..................467*..................244.......+332....*..........35..............*...
|
||||
.............453.......616..*...........609.............662......672.....56........661.602*...............549.661...................141..73.
|
||||
.......699...*.........*...904..........................&..........*...@..............................189..........$677.......473.....*.....
|
||||
........*..670.........938.........267.......684...........514...211....875.........667..171.110&.426*......../...............*........29...
|
||||
.....164..........................*....@786.*..........646.=.........43.......885....+...=.............641.....996...........117....28......
|
||||
.........*921....150*....635..973............587...346*......771........&3....+....................=................................@.......
|
||||
......962............821....*...*...........................$....174............391+......732*177...101.....146.............555.............
|
||||
..........................117.965.........327.....................*../127.54.........354.....................*...37/.......&....56....656...
|
||||
.335.747*967..*469.................................-.....$.450..560...........553...+.......327*..........215.........950..............-....
|
||||
......................253%...........796.........267...946..*........&...583.-...........-......727.37........@....#....-.......337.........
|
||||
.............-...............-.649.........-.................316..680......*.....982..398..................961......632...718......*..%.....
|
||||
..........599.............876......700..617....344*138...611..........907........-...........................................*...291...209..
|
||||
.860...........................*......*......................850........*..............=....761...721*804...............%...33..............
|
||||
...*...........................61./....378........268....956..#..813@..191...610.168..216....$...............853%......826..................
|
||||
.757..=422.........................427..........+....%....=...................#.../..............908................@.......................
|
||||
.........................172.................464...........................-.....................*.......667...931...131..@.........939.....
|
||||
............456.....462....*.....985................801......933..464..641.874............*189..42.........................430..596...=.....
|
||||
..............*....%........945.@........456....*23...........*..........*.............335.........889..557#....................*...........
|
||||
....810.........65......382................#.532...............704......796...192....................@..........46...527......929...........
|
||||
...=....%..................*433...........................925.............................................30.....*................617.......
|
||||
.....792.......386.....................575...%859................................................................993...334*..........&......
|
||||
..........657.&.....&....................*.....................296.+513.............36..........267........703.............186..............
|
||||
......336...........443...#.....474......897.215*346.....100.....=...........+.812../......47.%....*444..&............128........-...196....
|
||||
705.............980......932.......*122..................*...........305..817..*......424.../.40.........193.210.736.*..../....&.512..*.....
|
||||
...%...............*.....................................326..615.......*.......472..*...........350*201.......*..@....681...902......330...
|
||||
...................907...303...........140*112.............../........93...875......339....361=.............730.............................
|
||||
..............540...........*...................498.170.....................*....................#...757........241...............201.......
|
||||
...359*42.....=.......309...561....528.....444.....*........570............................125/.379......707.......*........*285.$..........
|
||||
............%.........................*770.............253..*....515..926..................................=........45.946..............*...
|
||||
....155..573..103.24..............................@......*...179..*........275......................*...................*................134
|
||||
....*............*......963...........444......801...656.796.....524.84#......*433.......997.....122.500....711.......447...................
|
||||
..80.........992..........*............*...+..........*....................................*.................*...............$.....894...61.
|
||||
........183..../.......492..955....+.222....519........373....=......304........151.........691..............655......223....37......*......
|
||||
.........$...................&..221................859.....929.......*...398.......*......-......591.....&.............$..........134.......
|
||||
................960......264........./..............#..............508...@........118..449........*...907......=791.........................
|
||||
...........239....#.....=...........248.531...................@..................................696.......741...................50..174....
|
||||
.....=......*............................*.....506*809.....796.....906.....=...........17*...........51...*.......................*..*......
|
||||
...520...198...781....253..............957.222.....................*.....216..............513....959*....638.312........172.318......514....
|
||||
...............*.........*239...............*.....%.....923.........852..............414+............../.....%...104.......*.............936
|
||||
.....221.....116.....712...........201...346...475.........*...............&..............745....109..202...........*.......................
|
||||
....*............957*.....$....353...............................171....468....%..........*.........*.........906..593..592#......&316......
|
||||
.........232...........251....#.......%.......................$...*...........179..904.....365.....331..541..*..............................
|
||||
...................................856..........412..-....844.877..871....*.........../.................*....416...........810*685..776.969.
|
||||
.158.......@......319........681..........780.#...+...428.*............650.241....@....................................123.............*....
|
||||
....%....826......@....%.688*.......983../....723.........892...................270.....234....*......443...970...........*.................
|
||||
....................314................*.................................................*..=...588......*.....%........225...496*732.......
|
||||
...344+........................644......413.997....553...................................87.282..........943........866.....................
|
||||
..........*563....910......267..*..546........*.....*..................60.............+..........421*739.............*...251.169.605........
|
||||
938.....52...........*761.*....762............335....842.....................44/.......528..........................77......*.......*201....
|
||||
..........................597......$.....................896.....543.76.........................938./707...............8........982.........
|
||||
...894..195.......310*986.....=54.854...553................#.......*...*..192...127..566*768..........................*....850...*..970.....
|
||||
.....*..................................=...835...874...........663...65..*.....*.................*947..539.12...947.485.....*..749..*......
|
||||
......34.378........$............#.........*......*......922...............947.598..880........723.....*....*...@..........791........18....
|
||||
..165.............388..94.......863........132.184..973.*.......58.................*......226..............618.....................=........
|
||||
.....*.............................................@.....154.............240..34.297.......*...........429.....625...............672........
|
||||
......619...#............641*520.340.918............................../..@...............390......502..-..../.*.....164....789........984...
|
||||
.............933.....................*.....838..240..400&..........288.......196..109............*.......749...513........*.......751...*...
|
||||
.....709.....................881..905.........*....*.....................643..*.....@...114...608......................190..........*....993
|
||||
...............109...........*........368..123....98...501.....691..410-...*.126......................92........+..546...........219........
|
||||
..................*......18..70..296.....*..............&..987..*........235............8.............././...828...*........................
|
||||
.151.............551.153*..........*.....883...............*.......*833........497..287*..427.377%.428...910......448.598.....334..53..619..
|
||||
..........589.......................723.........832.131..705.............................#............*.................@......*...*..*.....
|
||||
..........*........794*686......790...............*..........192..............................970......612.546.98............942......941...
|
||||
....223.686..............................547...665.......396..*.....210......408.322..839.......*..557......*...+.................521.......
|
||||
.....*.......170...........166.....390..............100.....*..921....*.........*.....+........984....*..450..........639..../....*...296...
|
||||
...372..........*760...266.*...600*......999.........*...906........................#....632.......469........250.......*...422..643....@...
|
||||
..............-........#...911......494...*...355...159.......................848..676.................../.....*......35....................
|
||||
......81$.....544..67...............*.....159....*............209.747*29........./..........812.........430.232...................199*587...
|
||||
760.................*...#........331.................%...158...................#.....................29.................596...477...........
|
||||
..........%./....922...388..970...............510...68......*....590....545...621...-..977.593..889...*.........................=..879..*389
|
||||
....163.618.370..............................*...............946..................332....*.......&..&..837.658......................*.......
|
||||
.............................835.....129...566.....690.237..............#.............$.....386....36......#......411.....52..733...783.....
|
||||
.........670...978.84...........=......*.......991*....*....632.......957...52.......548.....&....................*.........-.*.............
|
||||
....920....*..*.....*...............949..............482...*......812........-...413.....201................663.286.....-......424...296*630
|
||||
........992...307...634.................716..287.........811.....+........4......*...413*.........896......*...........84.52................
|
||||
.........................253.............................................*.....459..........926..*.......446..............$.......175.......
|
||||
.........................*.......168-.....781*......344.........85......373..........224.....*..393.545........749%.643......-..%.....968...
|
||||
...*776../145...&.....140..........................*........578*........................#..45..........*............/......596..639.........
|
||||
415............393..................988...........878.22..............909..........284...............173...564*48.......33.............444..
|
||||
........259..........%.....207-........*631...........*......669*...................*...........282......%........%.....*...................
|
||||
.130................119.....................422......440.........461...-154........575.............$.=....329...180..576.....367............
|
||||
...........618...............=.../..538$.......&............493*............729..........903.........82.......................*.............
|
||||
.............*............541..124.........627........806*......666.703.146*...........*.%..............-.....................142........551
|
||||
...#..3......660.....................*........*.......................*......./164...498..............872.621....991........................
|
||||
174....*...............683..542*.....960.....782.....755............557../.....................#282.......#.........*409.103.......943......
|
||||
........231.891...........*.....782.....................*992.............492......69.......610...............+...............557......*.....
|
||||
............*...964.104.289..........853......691..830.......&.....................*...870.*.............77..189.310*...............583.....
|
||||
....449....435.*....../........732+.=.........*...*.........238...161.....688......675..*...934......................891....................
|
||||
...............21.......................239........430..........@....*.....@..376.......205......790........................73..334...598...
|
||||
......863-................474...339.....*.................765.534.116...........*..................*..........@.......513...-....%...../....
|
||||
.262..........#......785....*..$....915..622....440$.&416.*.............143...34..45....515#....448...........268........*..................
|
||||
...*..+.......844......*.142..................*...........666.......266...*......*...................236..............439......338.496...285
|
||||
647...393...........236.......218..........819.779...+................./.........765...................*.......292.........$......*.........
|
||||
..........................257....*.................274.........247...........951........................121........391....817.../...........
|
||||
........742..................&....98...................628....*.................%.168..........539............................701...........
|
||||
.......................659................................*.622...868.............=...713.357....*.298....917...781.........................
|
||||
.....467....382..899......*819.....952*388..............684.......*.....................*.....558...%....%...............$..*.....60..615...
|
||||
.....*.....*.......*............-..........604.................85.76....%893.866.&...784.....................$423.....334....935..*....*....
|
||||
..154....424......583.......8....926...$............$441.....................*...50...............=....155.......................599..115...
|
||||
.............%............-...........96.506..846.................152.....985..........589.......384...@...44...............560.............
|
||||
.............161...%167..906..901.........*......&....92..+610.......*247.............*...................*...........330..*....92..........
|
||||
....26.........................*...........523........*......................190...711.......*..........302.690.........*.986........714@...
|
||||
........154.....................763..59..............305..560...726......79...*...........521.160..159................81....................
|
||||
991.339*........-.........434..........*....................-..*.........*..626....................*..............692......+................
|
||||
..............448.....96./...........782............353........949.....655...............752.522....905...964#......-.683..83...............
|
||||
.......=..........127../.........$....................../.......................................*......................+.........671........
|
||||
.783..14...........*...........746....271.38............666..................513..37.....=984.824....@....$..463.................*...154....
|
||||
.................60..892..304............*....354*20.................99.........*..%.351............367..914.*....622...........310...*..194
|
||||
.../.....339............*......318..........6.................329*...*..240.....76...*...45....*..............601......+.............211....
|
||||
.700...../...925......616...........*56.570.$...970...751...........556..%..958.....50..*...667........63...........793.....................
|
||||
...............................8.........*........*......*854................*.........304........324.....%..................*.....213%.....
|
||||
832...............%....$.........572......303.....872.=.............822.....2...434........%..76.@......34...866.684*.......571..........756
|
||||
.....922........908.811......792....#.967..............432..............304......+........676......314........*..................364....#...
|
||||
........................=.....*.........*.......39............127.........*........27..............+.........937.172.....532*......&........
|
||||
....*.............156....626...667......151..../.......................776..846...*............562.....254$......../..@......297.......751..
|
||||
..457.213.....403*....=......................#.......656.....546%..............*.......*866......+...................954.576...........%....
|
||||
.........*..........227........364....752..977.231..*...........................739.610...................................*...730..#........
|
||||
......838......645........$692.................*....170...............906........................149.....578..470.........981.....310.......
|
||||
959...........*....447.................33.513...412..........784.......*....................365.....%....*..................................
|
||||
...../......593......*....=..965..=907...*.............................482.....................*.......915..............327...529.....425...
|
||||
......613.........%.490..971.-..............&542..............................695.......803.....917........446.....53...*........*455..$....
|
||||
...............258..................+..303+..........................517....7*....598..@....472.....224...*............903..#...............
|
||||
........................724...+....575........312...&.........................................*....*......628........@.....108..............
|
||||
.....343.374.......$....*....675...............%...371......409.....502.928.135...482.384....195...59.............144..982........787.......
|
||||
....*....*.......289..729..........990....................../.........+.......*..*......*...............*.@...........#.............+.......
|
||||
....147...613.............*534.........938....882...740.518.....994..........800.222..933...836.......260..339.=...........628.$935...../...
|
||||
...............726.....308.............%........*...../.+........=..../146.................*...................509..........*........593....
|
||||
930.........................823..............994.................................100.....857.......................708.220.184..............
|
@ -1,42 +0,0 @@
|
||||
--- Part Two ---
|
||||
|
||||
The engineer finds the missing part and installs it in the engine! As the engine
|
||||
springs to life, you jump in the closest gondola, finally ready to ascend to the
|
||||
water source.
|
||||
|
||||
You don't seem to be going very fast, though. Maybe something is still wrong?
|
||||
Fortunately, the gondola has a phone labeled "help", so you pick it up and the
|
||||
engineer answers.
|
||||
|
||||
Before you can explain the situation, she suggests that you look out the window.
|
||||
There stands the engineer, holding a phone in one hand and waving with the
|
||||
other. You're going so slowly that you haven't even left the station. You exit
|
||||
the gondola.
|
||||
|
||||
The missing part wasn't the only issue - one of the gears in the engine is
|
||||
wrong. A gear is any * symbol that is adjacent to exactly two part numbers. Its
|
||||
gear ratio is the result of multiplying those two numbers together.
|
||||
|
||||
This time, you need to find the gear ratio of every gear and add them all up so
|
||||
that the engineer can figure out which gear needs to be replaced.
|
||||
|
||||
Consider the same engine schematic again:
|
||||
|
||||
467..114..
|
||||
...*......
|
||||
..35..633.
|
||||
......#...
|
||||
617*......
|
||||
.....+.58.
|
||||
..592.....
|
||||
......755.
|
||||
...$.*....
|
||||
.664.598..
|
||||
|
||||
In this schematic, there are two gears. The first is in the top left; it has
|
||||
part numbers 467 and 35, so its gear ratio is 16345. The second gear is in the
|
||||
lower right; its gear ratio is 451490. (The * adjacent to 617 is not a gear
|
||||
because it is only adjacent to one part number.) Adding up all of the gear
|
||||
ratios produces 467835.
|
||||
|
||||
What is the sum of all of the gear ratios in your engine schematic?
|
@ -1,125 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
LINES=$(wc -l < "$1")
|
||||
COLUMNS=140
|
||||
mapfile -t -O 1 INPUT < "$1"
|
||||
declare -a gear_ratios
|
||||
|
||||
find_gears ()
|
||||
{
|
||||
# Find and append gear ratios to array.
|
||||
for ((line=1; line<=LINES; line++)); do
|
||||
for ((column=1; column<=COLUMNS; column++)); do
|
||||
if [[ $(arr "${line}" "${column}") =~ ^\*$ ]]; then
|
||||
declare -i ratio=1
|
||||
declare -a adjacent=()
|
||||
for ((i=column-1; i<=column+1; i++)); do # check above
|
||||
if [[ $(arr $((line-1)) "${i}") =~ ^[0-9]$ ]]; then
|
||||
number="$(arr $((line-1)) "${i}")"
|
||||
for ((j=i-1; j>i-3; j--)); do # check before i, numbers are max 3-digit
|
||||
if [[ $(arr $((line-1)) "${j}") =~ ^[0-9]$ ]]; then
|
||||
number="$(arr $((line-1)) "${j}")${number}"
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
add_to_i=0
|
||||
for ((k=i+1; k<i+3; k++)); do # check after i
|
||||
if [[ $(arr $((line-1)) "${k}") =~ ^[0-9]$ ]]; then
|
||||
number="${number}$(arr $((line-1)) "${k}")"
|
||||
add_to_i=$((add_to_i+1))
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
i=$((i+add_to_i))
|
||||
adjacent+=("${number}")
|
||||
fi
|
||||
done
|
||||
for ((i=column-1; i<=column+1; i++)); do # check below
|
||||
if [[ $(arr $((line+1)) "${i}") =~ ^[0-9]$ ]]; then
|
||||
number="$(arr $((line+1)) "${i}")"
|
||||
for ((j=i-1; j>i-3; j--)); do # check before i
|
||||
if [[ $(arr $((line+1)) "${j}") =~ ^[0-9]$ ]]; then
|
||||
number="$(arr $((line+1)) "${j}")${number}"
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
add_to_i=0
|
||||
for ((k=i+1; k<i+3; k++)); do # check after i
|
||||
if [[ $(arr $((line+1)) "${k}") =~ ^[0-9]$ ]]; then
|
||||
number="${number}$(arr $((line+1)) "${k}")"
|
||||
add_to_i=$((add_to_i+1))
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
i=$((i+add_to_i))
|
||||
adjacent+=("${number}")
|
||||
fi
|
||||
done
|
||||
if [[ $(arr "${line}" $((column-1))) =~ ^[0-9]$ ]]; then # check before gear
|
||||
number="$(arr "${line}" $((column-1)))"
|
||||
for ((i=column-2; i>column-4; i--)); do # search for beginning
|
||||
if [[ $(arr "${line}" "${i}") =~ ^[0-9]$ ]]; then
|
||||
number="$(arr "${line}" "${i}")${number}"
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
adjacent+=("${number}")
|
||||
fi
|
||||
if [[ $(arr "${line}" $((column+1))) =~ ^[0-9]$ ]]; then # check after gear
|
||||
number="$(arr "${line}" $((column+1)))"
|
||||
for ((i=column+2; i<column+4; i++)); do # search for end
|
||||
if [[ $(arr "${line}" "${i}") =~ ^[0-9]$ ]]; then
|
||||
number="${number}$(arr "${line}" "${i}")"
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
adjacent+=("${number}")
|
||||
fi
|
||||
if [[ ${#adjacent[@]} -gt 1 ]]; then
|
||||
for number in "${adjacent[@]}"; do
|
||||
ratio=$((ratio*number))
|
||||
done
|
||||
gear_ratios+=("${ratio}")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
arr ()
|
||||
{
|
||||
# Usage: arr LINE COLUMN
|
||||
line="$1"
|
||||
column=$(($2-1))
|
||||
if ((line<=0)) || ((line>LINES)) || ((column<0)); then
|
||||
echo -n ''
|
||||
else
|
||||
echo -n "${INPUT[${line}]:${column}:1}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main ()
|
||||
{
|
||||
find_gears
|
||||
sum=0
|
||||
for number in "${gear_ratios[@]}"; do
|
||||
sum=$((sum+number))
|
||||
done
|
||||
echo "${sum}"
|
||||
}
|
||||
|
||||
main
|
@ -1,203 +0,0 @@
|
||||
Card 1: 87 75 80 68 71 57 58 59 70 48 | 56 67 75 76 31 49 48 22 43 68 98 86 70 91 27 46 4 87 72 37 71 58 29 79 80
|
||||
Card 2: 95 97 90 91 79 71 60 87 46 80 | 28 90 55 87 82 34 44 96 77 15 22 63 31 33 5 99 36 91 17 10 64 59 68 37 13
|
||||
Card 3: 23 73 50 78 93 30 56 10 8 64 | 61 48 87 46 12 75 92 37 62 45 24 81 79 55 76 82 9 1 16 72 13 27 41 86 19
|
||||
Card 4: 16 50 13 24 94 27 74 58 15 53 | 58 53 20 57 69 28 47 2 41 4 66 61 15 44 24 68 50 74 86 45 36 73 43 27 91
|
||||
Card 5: 39 53 29 10 84 22 83 4 5 32 | 50 28 45 5 6 65 18 7 92 83 3 55 81 26 80 39 44 60 90 37 91 36 54 14 74
|
||||
Card 6: 84 12 96 93 72 97 91 76 7 82 | 85 15 29 33 37 60 14 30 63 73 38 62 77 44 86 39 51 2 99 75 70 36 32 98 78
|
||||
Card 7: 78 12 1 50 48 62 33 8 83 99 | 12 50 79 48 59 81 26 14 5 11 37 8 36 91 95 20 46 44 21 32 58 93 53 90 54
|
||||
Card 8: 55 58 8 36 16 23 88 73 45 65 | 19 10 34 64 52 27 75 22 33 58 74 45 16 11 63 56 12 14 8 25 59 4 95 47 78
|
||||
Card 9: 95 14 83 17 7 69 44 31 45 37 | 2 69 81 39 76 86 29 73 72 32 67 5 9 16 95 90 36 27 88 55 61 6 37 79 1
|
||||
Card 10: 24 83 98 76 87 6 32 59 4 96 | 54 5 68 85 76 50 60 33 58 32 88 61 27 55 90 65 93 13 53 29 44 15 6 45 24
|
||||
Card 11: 55 92 57 65 44 21 49 8 13 48 | 17 44 79 11 65 50 46 14 40 69 31 62 55 86 36 60 30 52 25 93 41 56 48 99 51
|
||||
Card 12: 14 93 52 89 35 42 13 22 76 26 | 14 5 46 80 22 39 1 67 43 31 78 87 68 95 90 83 96 71 74 29 15 88 36 11 76
|
||||
Card 13: 55 78 95 85 43 53 80 12 1 59 | 42 60 32 70 10 91 94 88 68 99 45 71 54 93 76 52 44 30 2 18 72 90 9 7 63
|
||||
Card 14: 6 44 46 59 91 60 47 26 12 17 | 35 52 36 5 18 30 63 79 75 55 45 99 84 81 71 34 48 24 14 70 11 69 1 4 77
|
||||
Card 15: 29 17 94 87 84 3 96 33 5 48 | 65 25 20 45 85 1 43 37 14 11 69 81 6 92 93 46 8 23 31 2 30 61 22 79 71
|
||||
Card 16: 73 81 13 23 61 35 49 48 99 5 | 10 69 22 40 73 29 61 23 13 99 26 7 39 70 5 56 88 46 49 81 68 25 35 48 14
|
||||
Card 17: 64 47 6 10 16 74 26 95 28 73 | 86 27 47 6 68 49 64 48 74 26 16 28 20 99 61 10 12 25 73 88 70 95 67 3 76
|
||||
Card 18: 1 29 86 72 65 52 67 64 68 79 | 5 88 77 52 18 31 67 41 37 55 68 65 39 22 72 97 23 64 34 29 48 1 79 49 86
|
||||
Card 19: 71 33 43 91 59 35 69 18 78 9 | 86 55 54 59 91 36 45 9 94 43 39 11 44 1 93 23 66 97 4 62 71 98 18 31 28
|
||||
Card 20: 72 86 59 6 85 1 74 25 87 20 | 21 14 6 39 4 54 37 2 61 83 82 59 10 67 19 50 12 16 51 55 1 5 45 98 73
|
||||
Card 21: 35 39 40 21 19 87 58 49 78 32 | 28 91 27 45 44 25 11 35 84 26 98 87 14 97 93 70 55 19 34 16 8 7 67 54 5
|
||||
Card 22: 87 30 6 9 73 47 29 7 33 63 | 87 80 21 3 63 38 14 7 20 9 73 31 33 29 11 30 22 68 57 54 43 42 47 34 6
|
||||
Card 23: 51 61 36 99 86 88 21 6 30 74 | 30 42 99 86 20 44 74 64 72 67 81 93 79 51 5 48 21 75 36 23 6 60 4 66 88
|
||||
Card 24: 96 21 44 42 57 34 59 45 58 2 | 6 81 92 13 66 98 47 73 26 10 84 62 93 49 57 35 90 27 75 19 52 1 37 32 85
|
||||
Card 25: 17 55 53 49 25 59 71 33 35 11 | 55 82 92 74 29 17 46 40 2 26 25 32 96 49 11 35 53 3 87 59 71 33 73 36 38
|
||||
Card 26: 33 85 26 21 13 51 73 76 20 7 | 85 53 42 21 31 76 33 97 71 73 20 90 13 52 95 98 93 99 11 32 26 51 24 37 7
|
||||
Card 27: 62 39 22 67 69 5 89 1 36 34 | 10 52 68 95 32 82 22 94 21 29 5 45 87 51 18 4 15 19 59 55 11 78 60 63 84
|
||||
Card 28: 65 31 58 70 2 49 46 14 72 11 | 24 95 11 14 27 22 38 65 15 35 36 18 59 49 6 70 69 62 46 58 60 34 92 72 2
|
||||
Card 29: 78 6 94 55 65 17 97 30 66 33 | 80 32 56 48 49 16 88 61 57 20 37 75 51 58 86 29 42 39 41 60 62 69 10 81 24
|
||||
Card 30: 72 33 93 5 58 92 10 90 29 20 | 77 73 41 42 67 17 24 28 23 69 27 43 80 49 75 74 2 3 21 26 76 32 48 30 4
|
||||
Card 31: 9 93 77 42 49 71 36 98 46 1 | 68 39 10 32 36 7 47 55 95 33 48 56 31 61 98 40 50 81 94 77 45 12 16 6 35
|
||||
Card 32: 35 54 65 19 62 37 63 68 17 47 | 14 20 65 27 84 48 85 56 64 37 51 81 11 52 63 40 93 15 92 90 19 35 43 68 7
|
||||
Card 33: 21 80 78 56 29 65 6 12 57 22 | 51 61 7 1 19 22 77 62 78 54 58 29 89 97 34 83 56 57 11 98 73 6 17 16 70
|
||||
Card 34: 57 83 56 87 58 68 46 86 78 77 | 98 58 46 51 14 1 17 60 11 13 5 49 56 96 19 15 99 28 62 38 9 40 57 92 22
|
||||
Card 35: 34 29 33 85 95 9 47 11 39 25 | 49 91 61 13 99 84 80 96 77 82 97 59 20 30 4 65 70 74 5 37 41 81 75 93 48
|
||||
Card 36: 42 30 69 88 84 90 58 26 2 47 | 98 14 3 30 56 20 49 83 29 48 46 34 99 51 12 61 92 1 55 60 70 53 75 52 27
|
||||
Card 37: 7 70 87 71 25 85 50 86 77 72 | 94 23 90 73 52 79 31 30 49 71 8 26 88 38 42 5 81 82 69 51 63 35 80 22 19
|
||||
Card 38: 37 4 98 58 7 95 19 22 17 86 | 60 38 13 79 62 49 85 77 8 52 63 20 16 81 21 59 43 36 80 70 87 35 51 10 12
|
||||
Card 39: 68 79 63 42 17 92 99 95 2 29 | 85 24 88 25 52 81 61 1 27 50 84 98 31 49 19 51 38 93 33 15 22 28 14 70 67
|
||||
Card 40: 7 15 73 55 87 18 52 17 34 12 | 87 73 42 77 21 33 44 69 24 52 94 17 7 16 78 12 34 97 67 41 15 47 55 91 18
|
||||
Card 41: 70 1 14 88 52 46 32 59 67 75 | 17 1 75 13 46 87 64 32 48 52 53 80 30 21 3 88 94 14 38 70 73 67 28 41 86
|
||||
Card 42: 65 18 51 72 76 7 93 64 21 92 | 51 64 94 77 45 98 28 67 11 42 41 72 93 22 21 56 65 76 54 7 26 92 74 18 55
|
||||
Card 43: 35 82 2 99 52 68 81 38 14 94 | 51 46 27 10 21 7 56 71 77 6 38 44 25 79 94 33 76 15 22 99 68 84 5 14 81
|
||||
Card 44: 7 47 1 61 51 46 36 87 43 34 | 14 43 91 86 47 51 29 95 76 61 39 85 84 7 87 69 46 56 88 36 27 1 10 67 34
|
||||
Card 45: 17 83 85 90 65 18 67 75 68 25 | 89 67 31 51 99 46 85 42 84 75 59 96 17 68 26 79 65 81 32 83 25 90 37 4 18
|
||||
Card 46: 2 56 38 47 9 11 61 68 51 49 | 53 56 60 47 49 61 82 5 38 2 97 9 51 80 86 22 68 31 11 59 24 4 35 13 8
|
||||
Card 47: 39 2 68 61 28 8 23 62 46 89 | 23 15 46 78 62 1 60 36 52 35 10 65 90 67 4 18 16 72 44 61 6 59 14 45 91
|
||||
Card 48: 60 49 62 14 88 84 80 18 7 20 | 88 91 77 10 2 59 94 25 67 9 16 72 80 20 32 78 14 69 56 70 73 96 15 6 92
|
||||
Card 49: 14 67 94 15 12 40 7 68 22 88 | 91 15 67 61 7 95 85 72 94 78 12 68 14 35 41 89 60 22 88 81 93 86 40 84 92
|
||||
Card 50: 65 75 63 30 38 28 27 51 58 54 | 30 99 21 28 2 81 77 85 25 38 27 63 70 62 87 58 16 9 75 54 65 69 51 78 8
|
||||
Card 51: 30 18 35 67 45 87 27 13 82 51 | 9 51 95 45 2 67 61 82 81 30 52 35 5 43 27 87 83 49 13 44 21 22 48 78 18
|
||||
Card 52: 23 21 13 53 5 78 43 94 98 59 | 72 57 18 34 11 39 95 26 56 68 22 10 21 98 96 87 4 43 74 7 46 40 88 97 58
|
||||
Card 53: 39 55 57 87 6 68 78 14 36 7 | 74 76 20 58 87 6 67 26 57 1 41 44 17 14 42 7 43 81 35 39 55 36 59 66 96
|
||||
Card 54: 26 62 39 28 76 32 98 19 2 61 | 9 62 61 75 28 42 40 39 64 32 98 37 58 16 15 19 35 2 80 76 10 26 70 18 47
|
||||
Card 55: 31 47 13 40 5 80 94 45 54 43 | 61 17 52 78 60 2 37 58 19 85 89 14 20 10 3 13 80 41 25 79 4 70 36 75 11
|
||||
Card 56: 59 68 42 47 97 53 32 46 17 76 | 64 94 32 46 68 5 49 14 91 19 59 53 26 80 33 39 6 99 18 73 45 87 69 54 66
|
||||
Card 57: 70 23 37 94 4 46 26 33 71 72 | 64 38 71 53 37 96 29 80 41 90 60 94 18 45 27 62 72 33 79 32 26 92 49 12 4
|
||||
Card 58: 47 44 65 83 91 78 17 60 7 35 | 95 65 26 52 68 9 69 61 19 87 93 27 90 57 49 23 24 17 86 16 28 62 11 63 85
|
||||
Card 59: 3 92 67 72 64 2 74 14 49 73 | 41 57 98 95 91 78 20 42 25 60 54 36 56 34 86 37 9 10 52 79 80 53 88 18 46
|
||||
Card 60: 38 5 63 77 69 9 79 50 58 51 | 20 72 80 52 68 64 33 61 47 84 65 90 29 48 16 82 4 98 83 89 17 94 81 41 85
|
||||
Card 61: 13 65 75 26 39 63 88 92 72 87 | 98 43 81 95 26 69 27 7 57 37 82 41 71 18 55 53 10 36 64 47 84 4 20 77 67
|
||||
Card 62: 19 70 5 25 23 76 90 29 61 97 | 17 20 38 58 1 29 74 13 94 47 86 56 60 14 82 83 87 91 52 39 33 37 77 62 45
|
||||
Card 63: 22 24 17 19 55 48 23 3 8 11 | 4 67 90 50 99 54 49 78 94 20 96 2 86 74 83 79 76 15 70 52 34 98 5 82 88
|
||||
Card 64: 15 92 72 63 95 34 58 85 18 57 | 64 40 67 81 89 27 84 54 75 43 70 77 13 52 19 35 46 30 12 61 78 10 82 55 45
|
||||
Card 65: 66 35 28 50 30 80 15 85 4 23 | 3 30 99 96 70 47 4 64 35 66 78 41 65 63 23 28 44 67 85 80 61 50 17 15 92
|
||||
Card 66: 71 67 68 20 93 6 76 30 15 89 | 12 69 80 11 91 34 2 65 95 8 37 86 38 10 79 3 43 90 87 45 92 50 88 39 56
|
||||
Card 67: 94 46 12 2 53 27 57 45 33 1 | 33 72 74 64 25 97 17 2 73 48 3 56 63 40 31 24 45 83 85 79 6 75 38 55 49
|
||||
Card 68: 82 68 40 3 73 81 61 1 60 50 | 15 29 82 51 73 28 43 94 85 50 96 11 98 9 86 20 6 14 5 95 10 23 61 12 62
|
||||
Card 69: 25 94 17 29 2 34 48 87 51 49 | 95 17 84 91 14 34 3 89 87 71 2 51 35 93 7 29 74 55 48 25 49 56 94 20 68
|
||||
Card 70: 37 51 36 79 15 29 88 69 6 97 | 27 66 88 90 41 29 25 36 82 56 69 37 18 40 33 97 42 91 62 6 65 79 15 28 51
|
||||
Card 71: 77 28 31 19 40 35 80 11 76 26 | 10 74 63 70 11 67 76 31 40 75 96 77 60 80 35 28 68 53 19 64 51 43 26 9 25
|
||||
Card 72: 18 96 9 79 87 37 94 69 8 74 | 69 18 9 41 21 80 72 96 71 20 15 12 36 87 99 37 44 79 46 54 94 19 8 74 39
|
||||
Card 73: 11 60 75 68 66 57 51 70 20 30 | 6 12 35 45 56 38 46 65 54 59 19 68 64 11 57 22 74 30 90 13 37 93 5 20 51
|
||||
Card 74: 6 20 99 75 87 1 70 52 4 61 | 97 98 99 34 75 11 8 92 49 81 19 12 87 20 70 6 27 4 44 61 52 67 82 1 55
|
||||
Card 75: 95 80 34 33 66 55 63 19 7 46 | 19 83 58 4 46 57 72 99 98 63 36 80 34 30 11 64 24 52 93 55 22 76 78 32 89
|
||||
Card 76: 55 56 58 16 50 24 27 75 35 44 | 75 42 35 87 7 13 55 44 8 27 56 14 24 78 61 4 19 38 18 58 50 1 16 51 22
|
||||
Card 77: 99 2 77 33 48 47 44 87 32 23 | 46 71 47 54 23 55 18 28 56 48 69 14 26 44 24 32 77 60 81 2 40 33 83 11 87
|
||||
Card 78: 67 46 27 29 44 1 22 4 13 52 | 80 98 63 29 97 67 58 86 25 52 95 23 92 76 27 74 13 93 78 22 81 96 1 46 64
|
||||
Card 79: 60 94 4 59 76 64 34 69 35 62 | 10 8 82 43 76 44 69 20 41 29 1 35 34 59 42 22 13 32 4 40 65 28 16 84 99
|
||||
Card 80: 88 60 47 76 82 5 14 63 58 16 | 83 62 57 21 89 79 53 60 87 22 76 20 78 96 63 68 56 91 5 7 47 16 94 98 45
|
||||
Card 81: 46 67 14 43 39 44 48 35 6 94 | 2 31 12 42 78 76 61 62 40 37 29 36 16 75 4 41 21 19 85 49 84 73 89 96 3
|
||||
Card 82: 61 73 72 47 71 96 4 2 41 20 | 76 78 94 65 51 85 92 60 31 80 81 34 46 69 90 70 17 74 89 40 27 35 14 15 10
|
||||
Card 83: 82 60 62 23 81 27 61 26 75 28 | 29 78 79 9 13 39 30 97 31 96 86 84 42 28 14 55 81 44 17 8 25 12 35 34 82
|
||||
Card 84: 91 61 73 55 98 28 11 40 33 50 | 21 55 27 2 54 44 94 59 58 67 79 66 82 87 92 25 9 7 65 80 38 30 10 97 16
|
||||
Card 85: 39 81 47 2 8 95 35 63 36 10 | 75 58 6 19 20 55 18 99 88 25 78 77 65 93 59 57 12 13 66 91 3 67 34 41 29
|
||||
Card 86: 15 33 8 84 57 35 50 76 43 17 | 34 20 55 59 97 51 44 46 53 5 10 79 58 89 39 82 16 42 71 81 22 40 85 63 56
|
||||
Card 87: 44 7 57 42 53 85 62 9 56 63 | 95 60 69 56 24 43 7 4 91 44 63 76 30 39 62 9 85 57 16 34 53 99 50 66 42
|
||||
Card 88: 47 85 12 1 98 86 94 84 33 51 | 27 54 45 55 38 12 96 51 1 83 36 65 13 85 32 94 29 52 47 59 33 48 86 82 98
|
||||
Card 89: 45 15 77 41 57 43 54 2 32 24 | 44 79 10 28 23 97 99 40 95 25 22 9 35 59 53 74 14 37 34 61 39 30 71 12 94
|
||||
Card 90: 76 75 36 82 28 2 87 81 31 14 | 38 67 87 90 6 9 19 2 13 37 24 15 65 84 32 85 44 18 98 79 23 35 80 60 47
|
||||
Card 91: 21 19 37 97 7 29 34 79 45 13 | 17 42 12 71 21 4 51 37 7 81 34 65 36 19 13 59 96 97 31 16 79 87 29 86 45
|
||||
Card 92: 16 14 67 60 39 25 26 34 12 96 | 79 66 11 93 38 29 37 12 50 32 7 82 39 59 84 54 42 83 43 92 19 1 34 26 77
|
||||
Card 93: 70 37 71 28 22 62 85 9 65 27 | 78 91 28 65 42 22 70 30 92 54 9 72 38 24 62 51 10 49 89 13 14 66 84 61 93
|
||||
Card 94: 80 48 40 83 87 19 53 66 69 33 | 80 79 66 76 58 94 60 70 20 42 72 87 19 30 75 40 67 12 36 96 11 29 59 63 33
|
||||
Card 95: 68 91 48 52 79 40 83 97 16 63 | 77 73 52 88 97 91 48 22 35 64 31 40 63 68 60 28 57 30 51 54 36 16 92 19 79
|
||||
Card 96: 78 81 13 87 20 8 80 63 2 3 | 20 29 62 72 44 90 54 22 3 35 55 16 96 80 37 93 73 23 50 33 6 63 78 8 13
|
||||
Card 97: 32 39 59 73 8 34 36 46 85 47 | 14 22 15 87 46 34 67 77 44 91 47 5 73 68 59 7 40 94 98 36 21 76 64 86 39
|
||||
Card 98: 19 75 37 82 94 6 57 15 78 58 | 9 79 6 71 91 39 38 61 59 89 90 1 80 17 86 35 98 63 27 74 5 49 25 70 73
|
||||
Card 99: 44 22 48 23 31 78 15 89 49 24 | 36 89 27 81 67 56 22 28 74 47 25 18 44 3 15 23 58 73 69 39 75 17 85 1 7
|
||||
Card 100: 56 15 30 64 37 89 51 96 63 90 | 56 23 24 57 44 9 41 65 6 26 69 36 21 66 94 67 7 10 34 59 14 40 99 93 98
|
||||
Card 101: 42 95 60 30 25 87 82 98 40 54 | 22 85 24 84 19 34 3 43 97 8 18 57 58 26 91 44 56 11 16 66 78 73 62 50 68
|
||||
Card 102: 14 64 72 79 55 78 44 12 76 36 | 69 74 13 78 59 82 15 46 49 11 81 83 97 9 58 4 98 60 43 34 30 67 2 47 37
|
||||
Card 103: 64 82 36 57 33 8 80 91 95 32 | 84 45 12 44 59 94 86 53 48 96 26 66 70 65 39 37 21 72 49 60 56 35 82 98 92
|
||||
Card 104: 76 18 88 52 69 44 57 99 20 12 | 60 74 21 35 77 39 40 29 46 37 95 65 93 36 43 86 48 59 6 11 16 72 28 55 97
|
||||
Card 105: 91 30 6 25 7 64 41 28 72 53 | 93 63 59 31 4 87 45 97 70 29 39 80 98 66 44 51 54 62 57 46 56 18 13 81 27
|
||||
Card 106: 15 59 45 36 74 86 35 62 87 14 | 29 35 81 53 60 69 47 25 61 43 13 62 84 96 79 75 68 23 32 18 37 72 63 4 36
|
||||
Card 107: 62 41 56 15 66 50 63 20 43 84 | 43 66 99 3 49 20 80 50 36 38 52 22 23 24 41 62 84 83 15 68 63 56 94 35 97
|
||||
Card 108: 67 51 97 26 11 61 91 55 7 23 | 47 96 26 78 22 87 33 51 34 59 53 3 97 91 86 11 21 89 13 61 23 67 55 7 24
|
||||
Card 109: 72 23 61 6 1 65 83 47 10 41 | 27 16 98 74 55 61 5 1 88 68 41 47 99 48 76 31 85 83 38 72 91 93 36 90 80
|
||||
Card 110: 34 22 81 62 40 25 43 60 12 69 | 69 81 71 66 54 15 17 79 25 93 34 51 43 62 40 12 30 56 27 47 60 33 22 94 65
|
||||
Card 111: 48 24 75 46 37 65 33 74 64 92 | 75 46 25 65 92 33 64 83 39 16 45 48 97 56 11 78 94 62 4 24 37 96 74 31 40
|
||||
Card 112: 94 92 39 58 34 78 61 7 50 88 | 83 6 52 39 92 17 40 63 54 34 7 85 89 64 25 50 99 77 33 13 11 81 35 78 41
|
||||
Card 113: 23 25 75 44 18 8 29 79 48 60 | 7 70 80 63 60 42 88 25 44 23 21 11 51 93 47 82 16 86 73 62 96 75 2 29 19
|
||||
Card 114: 52 42 66 15 57 29 21 47 89 22 | 77 81 52 8 66 21 98 61 71 2 85 34 42 95 93 25 67 60 82 47 78 56 63 87 84
|
||||
Card 115: 63 81 53 30 8 94 75 76 45 71 | 53 93 40 18 45 71 76 67 75 92 15 72 35 94 65 30 88 22 81 8 63 50 80 5 82
|
||||
Card 116: 8 33 23 82 63 25 65 4 97 28 | 79 75 71 46 41 74 6 86 64 33 24 70 82 87 9 76 36 3 5 97 92 4 1 12 62
|
||||
Card 117: 9 97 4 59 31 78 73 99 84 11 | 93 65 12 39 29 76 80 82 43 37 26 57 79 27 46 90 98 54 31 34 17 62 95 51 9
|
||||
Card 118: 11 42 73 23 28 62 68 15 31 48 | 17 81 29 15 10 86 25 68 28 80 33 78 89 11 82 96 12 34 19 99 67 13 64 59 91
|
||||
Card 119: 22 16 61 76 19 92 5 89 86 1 | 37 35 77 44 7 42 86 92 41 81 16 95 12 1 85 60 63 79 5 25 62 46 73 45 19
|
||||
Card 120: 97 11 71 31 44 24 12 49 15 17 | 97 44 78 49 64 61 42 55 31 38 12 87 53 32 41 6 68 62 19 94 13 79 29 56 71
|
||||
Card 121: 5 50 95 7 14 6 35 64 99 94 | 30 54 80 90 68 98 6 71 61 81 23 24 64 37 40 15 53 63 31 35 7 49 14 99 42
|
||||
Card 122: 5 72 29 22 71 35 41 82 15 56 | 3 45 61 68 70 41 56 26 82 62 29 36 84 80 95 81 96 83 20 35 28 54 21 76 47
|
||||
Card 123: 80 4 93 25 97 10 20 84 3 67 | 14 18 12 20 86 96 63 67 60 54 13 85 23 37 10 16 71 65 33 5 98 1 74 53 51
|
||||
Card 124: 43 64 62 31 86 1 30 23 15 28 | 77 1 99 27 48 35 2 40 57 61 23 9 37 74 91 46 92 83 24 90 96 32 80 45 31
|
||||
Card 125: 53 47 45 50 82 37 26 41 22 57 | 43 25 37 29 89 20 17 8 1 46 2 55 53 44 61 78 65 72 69 85 12 93 28 34 80
|
||||
Card 126: 36 27 94 41 56 21 18 13 59 96 | 73 91 2 14 29 98 79 8 11 3 38 16 69 71 77 92 66 60 18 9 1 57 12 22 43
|
||||
Card 127: 19 12 69 97 81 26 73 83 34 51 | 91 47 89 62 94 8 66 43 35 93 48 24 71 40 42 75 13 14 65 28 61 95 32 25 9
|
||||
Card 128: 99 78 81 4 44 58 10 83 67 5 | 5 83 95 17 34 68 91 10 4 88 56 38 49 44 66 11 78 7 50 67 45 21 98 99 58
|
||||
Card 129: 94 35 8 59 72 56 51 98 47 63 | 98 71 61 72 51 54 35 34 95 9 82 88 47 8 66 57 90 55 81 33 59 56 64 63 94
|
||||
Card 130: 81 25 85 84 88 26 87 14 40 77 | 25 74 20 13 30 11 72 77 88 40 70 67 47 14 80 86 81 26 45 87 79 33 85 84 39
|
||||
Card 131: 28 83 7 69 87 48 46 67 33 10 | 37 10 48 96 38 99 14 60 28 42 26 94 46 24 84 68 87 72 85 67 4 83 31 7 47
|
||||
Card 132: 33 65 47 66 48 9 69 68 76 73 | 21 18 70 64 55 19 31 81 20 77 12 94 59 15 98 44 57 52 92 54 93 40 89 16 78
|
||||
Card 133: 67 54 21 71 43 56 68 65 55 99 | 16 83 20 45 85 92 34 61 88 33 51 65 24 68 58 55 91 81 54 43 5 1 77 49 25
|
||||
Card 134: 73 82 41 78 91 72 13 7 46 88 | 78 88 32 57 12 56 44 73 41 79 27 99 49 13 82 91 87 97 62 46 83 7 23 60 71
|
||||
Card 135: 19 30 91 16 15 88 5 4 72 38 | 38 41 23 87 3 78 75 11 88 53 5 72 4 56 54 65 19 76 15 27 82 39 70 69 17
|
||||
Card 136: 39 66 64 79 90 51 69 6 44 23 | 51 1 21 44 23 78 27 66 69 42 6 50 74 48 39 79 57 29 53 3 10 13 30 90 64
|
||||
Card 137: 82 75 28 96 13 25 30 59 76 5 | 25 45 59 79 96 44 88 75 82 30 13 18 20 97 21 5 70 31 76 95 17 37 27 28 53
|
||||
Card 138: 23 21 53 59 82 11 99 30 68 1 | 51 11 21 53 8 43 24 71 33 63 75 66 23 82 1 20 92 50 86 59 99 45 84 30 68
|
||||
Card 139: 43 44 12 68 14 70 83 84 39 40 | 72 18 54 48 43 91 56 1 11 49 83 59 29 73 87 40 37 6 50 14 74 61 70 2 36
|
||||
Card 140: 64 4 86 61 11 72 66 73 83 14 | 74 86 84 8 36 5 76 73 83 88 10 28 38 64 4 12 72 23 53 42 33 91 61 45 55
|
||||
Card 141: 46 33 44 21 99 64 29 4 28 30 | 1 95 13 97 9 59 15 41 89 35 43 98 81 27 94 3 65 88 91 12 17 10 23 61 48
|
||||
Card 142: 2 85 8 98 74 62 76 7 79 60 | 59 42 2 49 24 34 25 76 8 71 98 86 6 7 16 33 74 62 89 13 39 31 85 79 87
|
||||
Card 143: 50 10 55 73 71 3 20 57 15 9 | 42 20 71 54 11 9 55 37 15 3 53 41 13 99 63 57 7 73 28 84 18 35 5 32 10
|
||||
Card 144: 26 38 75 71 89 40 96 81 83 48 | 42 77 11 76 78 15 19 86 10 34 61 58 29 14 64 94 63 33 70 13 88 82 59 28 93
|
||||
Card 145: 72 35 67 80 78 20 57 48 64 28 | 44 70 79 37 5 96 31 13 10 83 93 29 46 94 66 47 6 34 14 18 33 8 69 49 20
|
||||
Card 146: 42 10 61 56 2 22 38 15 67 6 | 72 83 53 80 52 31 74 73 20 12 87 71 78 95 25 45 75 43 32 85 82 7 13 90 19
|
||||
Card 147: 30 2 48 5 16 25 70 89 35 85 | 3 5 55 90 16 86 70 87 17 29 74 14 22 78 39 37 71 45 79 42 2 60 21 62 89
|
||||
Card 148: 61 50 41 22 75 80 46 93 55 6 | 62 68 95 45 74 21 13 52 66 2 17 53 97 83 90 40 44 28 25 86 14 82 15 30 84
|
||||
Card 149: 49 54 61 92 19 16 78 83 15 71 | 7 33 40 69 2 34 70 9 91 79 74 42 67 38 82 60 28 43 23 80 39 56 30 66 1
|
||||
Card 150: 47 85 71 36 9 98 45 28 7 58 | 94 88 20 62 13 77 85 27 43 92 18 41 31 3 2 45 74 99 30 40 26 93 19 23 65
|
||||
Card 151: 65 90 39 91 53 76 79 51 9 36 | 5 84 49 13 70 64 15 33 92 67 41 57 19 21 22 87 54 50 46 66 52 24 71 29 16
|
||||
Card 152: 61 62 51 11 14 44 10 29 31 35 | 95 47 96 16 5 32 88 90 52 65 70 94 9 80 81 56 50 43 15 34 45 68 67 42 18
|
||||
Card 153: 91 86 12 23 53 39 96 79 14 76 | 68 66 83 69 73 42 59 67 4 38 11 46 16 95 71 52 88 13 19 48 9 99 30 62 43
|
||||
Card 154: 47 44 72 6 95 7 21 64 59 29 | 72 7 12 33 21 14 91 3 99 71 64 44 70 63 6 22 88 16 43 57 73 59 76 60 47
|
||||
Card 155: 38 36 24 69 59 58 96 45 39 30 | 17 64 59 31 80 36 25 89 96 4 27 12 30 74 11 29 57 63 45 19 42 38 69 58 39
|
||||
Card 156: 60 93 14 54 53 40 34 26 1 28 | 46 62 40 69 48 39 35 68 86 22 19 10 42 25 88 67 58 96 54 44 56 85 31 90 99
|
||||
Card 157: 82 93 7 76 69 1 36 5 4 3 | 66 96 92 52 29 5 91 62 45 27 25 31 28 78 99 95 73 14 37 26 9 98 42 55 11
|
||||
Card 158: 34 52 78 67 96 62 54 85 86 31 | 21 42 63 51 12 70 15 83 34 35 62 69 52 54 36 85 31 86 67 41 53 7 1 96 82
|
||||
Card 159: 67 49 58 35 82 57 29 6 20 25 | 30 46 2 75 38 57 99 7 29 69 94 40 12 45 97 49 66 6 35 76 32 37 71 60 68
|
||||
Card 160: 17 49 10 5 34 2 23 91 3 19 | 29 39 67 53 14 61 41 85 18 65 56 77 54 55 13 27 28 45 60 7 62 6 96 38 35
|
||||
Card 161: 4 42 38 50 85 92 27 25 82 7 | 82 5 83 71 52 43 12 75 73 92 96 1 61 59 25 85 7 22 23 80 35 15 97 88 30
|
||||
Card 162: 42 69 75 64 40 12 29 56 33 62 | 57 5 83 79 26 55 84 60 70 16 47 2 19 30 7 62 89 76 20 90 66 78 21 9 87
|
||||
Card 163: 52 10 27 86 7 72 95 88 13 75 | 94 76 43 33 31 69 35 68 39 78 48 83 28 66 67 15 72 34 32 25 85 53 40 46 1
|
||||
Card 164: 14 95 31 43 91 56 22 68 17 33 | 74 98 24 59 4 93 67 23 64 35 51 42 92 88 63 20 29 70 16 82 89 45 39 27 12
|
||||
Card 165: 29 5 49 25 67 79 56 44 43 93 | 20 54 10 52 8 50 98 9 73 92 78 24 86 69 77 82 80 41 94 36 35 22 32 38 3
|
||||
Card 166: 63 92 68 93 58 16 90 6 13 46 | 31 45 39 8 65 49 23 81 62 72 7 15 82 35 53 4 80 83 48 13 10 11 71 40 61
|
||||
Card 167: 58 70 1 3 7 81 65 83 79 77 | 87 8 59 29 18 6 14 48 35 9 60 94 80 92 51 2 73 36 47 27 86 89 41 42 4
|
||||
Card 168: 69 93 96 77 76 90 17 88 11 26 | 31 13 77 9 86 82 51 67 53 99 76 35 81 6 28 92 24 14 87 59 41 37 88 18 96
|
||||
Card 169: 99 40 11 87 24 55 4 46 66 49 | 60 67 72 31 94 69 42 46 86 17 47 70 95 90 6 4 3 59 61 24 93 73 28 58 96
|
||||
Card 170: 29 84 4 80 72 94 9 7 55 68 | 24 62 7 35 21 55 85 94 29 4 84 38 42 33 2 77 58 9 11 80 41 72 76 13 68
|
||||
Card 171: 93 7 9 11 12 13 79 51 99 62 | 99 28 51 12 82 11 35 18 93 34 7 17 2 13 63 54 9 69 62 84 68 79 58 36 70
|
||||
Card 172: 16 79 33 10 58 22 67 98 46 43 | 75 24 96 64 4 50 38 10 5 31 45 21 98 7 17 34 60 72 97 92 6 3 99 86 9
|
||||
Card 173: 98 73 26 29 85 75 13 22 27 35 | 87 76 25 43 82 17 79 74 16 91 37 97 46 15 14 40 52 70 31 68 81 5 36 72 57
|
||||
Card 174: 4 29 72 26 46 89 61 15 16 11 | 4 68 89 24 58 94 46 26 55 15 67 61 72 98 75 84 29 11 47 2 54 13 9 28 16
|
||||
Card 175: 40 49 71 63 25 47 44 26 98 31 | 26 20 18 96 64 92 88 63 62 95 47 33 86 35 70 75 90 27 1 59 54 74 80 41 77
|
||||
Card 176: 92 17 34 39 64 49 70 69 44 91 | 49 24 4 81 74 31 28 36 69 39 68 16 98 2 3 26 96 76 57 19 44 95 93 29 34
|
||||
Card 177: 60 32 48 84 3 86 62 55 22 58 | 17 91 95 50 64 89 32 60 82 62 49 58 25 12 86 3 40 16 84 87 66 61 77 55 9
|
||||
Card 178: 92 4 66 65 13 87 57 16 78 3 | 92 16 81 7 78 42 25 44 43 24 66 29 50 40 19 71 89 53 59 77 67 76 39 84 1
|
||||
Card 179: 6 67 72 98 79 45 12 87 77 60 | 19 12 57 66 14 26 28 31 18 24 45 6 15 29 99 27 90 87 10 59 92 36 58 72 79
|
||||
Card 180: 6 9 43 74 48 87 52 56 76 30 | 97 8 88 19 2 54 9 29 3 39 23 71 93 41 95 87 98 68 36 42 94 40 45 84 85
|
||||
Card 181: 26 5 23 14 59 6 33 89 97 96 | 16 7 41 8 45 71 47 98 67 88 58 13 79 66 85 81 32 17 60 91 51 49 27 69 3
|
||||
Card 182: 53 5 83 87 3 44 25 98 48 24 | 14 77 95 98 40 81 97 85 80 15 33 38 75 17 5 56 71 43 65 28 87 10 66 22 70
|
||||
Card 183: 67 20 49 89 38 55 16 79 27 45 | 43 57 35 34 26 93 13 63 5 87 72 69 28 96 78 3 48 47 61 94 59 7 37 95 1
|
||||
Card 184: 1 73 35 99 24 74 64 21 14 81 | 48 81 57 15 28 49 31 82 91 8 62 79 54 20 95 13 21 97 98 19 51 6 83 70 61
|
||||
Card 185: 31 6 98 7 17 45 42 37 67 56 | 53 73 7 91 20 63 57 96 28 72 15 44 55 29 23 77 58 32 1 11 62 65 95 83 25
|
||||
Card 186: 93 81 16 50 3 40 87 46 90 58 | 89 70 62 28 4 19 2 63 21 53 14 9 55 25 54 38 94 82 47 86 36 96 49 8 80
|
||||
Card 187: 45 71 74 81 84 18 23 35 86 25 | 34 90 45 74 63 35 1 3 88 12 84 71 97 29 32 26 40 18 76 89 9 80 86 94 64
|
||||
Card 188: 3 21 56 32 1 26 54 60 13 28 | 40 24 26 28 78 12 11 92 17 98 30 27 1 87 25 97 57 49 52 38 51 32 42 47 7
|
||||
Card 189: 41 82 69 64 35 71 79 61 44 36 | 35 69 22 37 44 29 79 39 14 3 56 66 36 62 82 26 72 61 88 33 97 64 41 98 34
|
||||
Card 190: 96 84 47 27 31 17 59 40 64 67 | 16 32 82 27 21 75 93 74 60 80 29 48 23 31 54 98 79 58 17 67 18 43 12 25 96
|
||||
Card 191: 35 60 71 44 21 62 81 14 67 85 | 36 37 69 9 34 35 62 40 54 41 1 13 23 58 85 86 24 55 14 7 92 96 50 11 81
|
||||
Card 192: 82 95 6 69 48 56 42 96 94 93 | 98 92 96 63 42 76 16 50 95 48 28 8 39 6 94 47 69 97 56 82 44 93 21 26 7
|
||||
Card 193: 22 86 12 38 3 6 44 77 27 59 | 53 80 89 25 92 38 63 86 65 34 99 46 27 75 8 1 7 47 66 29 2 77 61 12 54
|
||||
Card 194: 15 20 33 91 80 61 37 99 58 92 | 10 76 99 58 97 91 71 64 33 36 29 30 42 37 87 66 90 6 49 22 68 40 92 2 73
|
||||
Card 195: 10 59 86 92 5 55 25 48 36 45 | 27 5 48 84 25 57 35 78 56 63 82 28 87 92 88 10 19 42 36 53 86 60 81 39 55
|
||||
Card 196: 69 95 34 9 80 55 11 30 49 88 | 15 89 44 26 48 49 74 54 35 77 47 11 9 21 25 95 31 88 53 56 42 69 18 10 60
|
||||
Card 197: 62 23 83 63 24 58 57 72 8 68 | 41 25 26 58 80 45 99 55 63 96 46 60 84 33 98 42 50 62 44 52 47 7 57 75 12
|
||||
Card 198: 86 22 73 29 41 40 11 76 69 83 | 78 20 14 67 51 93 8 47 43 44 82 16 2 55 96 98 61 48 31 49 91 24 3 27 87
|
||||
Card 199: 27 59 83 12 76 82 74 98 47 73 | 30 20 63 53 67 68 16 4 66 10 93 61 89 80 36 75 62 99 1 5 70 31 17 82 22
|
||||
Card 200: 49 66 64 92 36 61 44 96 68 67 | 57 55 19 18 78 64 90 85 72 84 5 10 38 71 74 34 68 30 46 83 86 25 89 50 49
|
||||
Card 201: 83 53 58 64 84 72 70 19 41 17 | 22 55 50 90 65 88 6 76 43 70 26 63 41 91 82 79 89 98 71 54 80 67 59 36 49
|
||||
Card 202: 70 55 83 56 42 25 11 1 41 49 | 32 54 80 59 53 23 75 8 68 6 94 45 86 3 61 98 36 14 44 18 89 39 81 51 88
|
||||
Card 203: 12 10 29 80 87 71 65 37 55 9 | 11 5 75 46 3 81 6 54 64 32 95 33 49 34 74 48 92 20 21 56 53 50 41 61 36
|
@ -1,63 +0,0 @@
|
||||
--- Day 4: Scratchcards ---
|
||||
|
||||
The gondola takes you up. Strangely, though, the ground doesn't seem to be
|
||||
coming with you; you're not climbing a mountain. As the circle of Snow Island
|
||||
recedes below you, an entire new landmass suddenly appears above you! The
|
||||
gondola carries you to the surface of the new island and lurches into the
|
||||
station.
|
||||
|
||||
As you exit the gondola, the first thing you notice is that the air here is much
|
||||
warmer than it was on Snow Island. It's also quite humid. Is this where the
|
||||
water source is?
|
||||
|
||||
The next thing you notice is an Elf sitting on the floor across the station in
|
||||
what seems to be a pile of colorful square cards.
|
||||
|
||||
"Oh! Hello!" The Elf excitedly runs over to you. "How may I be of service?" You
|
||||
ask about water sources.
|
||||
|
||||
"I'm not sure; I just operate the gondola lift. That does sound like something
|
||||
we'd have, though - this is Island Island, after all! I bet the gardener would
|
||||
know. He's on a different island, though - er, the small kind surrounded by
|
||||
water, not the floating kind. We really need to come up with a better naming
|
||||
scheme. Tell you what: if you can help me with something quick, I'll let you
|
||||
borrow my boat and you can go visit the gardener. I got all these scratchcards
|
||||
as a gift, but I can't figure out what I've won."
|
||||
|
||||
The Elf leads you over to the pile of colorful cards. There, you discover dozens
|
||||
of scratchcards, all with their opaque covering already scratched off. Picking
|
||||
one up, it looks like each card has two lists of numbers separated by a vertical
|
||||
bar (|): a list of winning numbers and then a list of numbers you have. You
|
||||
organize the information into a table (your puzzle input).
|
||||
|
||||
As far as the Elf has been able to figure out, you have to figure out which of
|
||||
the numbers you have appear in the list of winning numbers. The first match
|
||||
makes the card worth one point and each match after the first doubles the point
|
||||
value of that card.
|
||||
|
||||
For example:
|
||||
|
||||
Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
|
||||
Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
|
||||
Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1
|
||||
Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83
|
||||
Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
|
||||
Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11
|
||||
|
||||
In the above example, card 1 has five winning numbers (41, 48, 83, 86, and 17)
|
||||
and eight numbers you have (83, 86, 6, 31, 17, 9, 48, and 53). Of the numbers
|
||||
you have, four of them (48, 83, 17, and 86) are winning numbers! That means card
|
||||
1 is worth 8 points (1 for the first match, then doubled three times for each of
|
||||
the three matches after the first).
|
||||
|
||||
Card 2 has two winning numbers (32 and 61), so it is worth 2 points.
|
||||
Card 3 has two winning numbers (1 and 21), so it is worth 2 points.
|
||||
Card 4 has one winning number (84), so it is worth 1 point.
|
||||
Card 5 has no winning numbers, so it is worth no points.
|
||||
Card 6 has no winning numbers, so it is worth no points.
|
||||
|
||||
So, in this example, the Elf's pile of scratchcards is worth 13 points.
|
||||
|
||||
|
||||
Take a seat in the large pile of colorful cards. How many points are they worth
|
||||
in total?
|
@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
main ()
|
||||
{
|
||||
declare -i sum=0
|
||||
while read -r line; do
|
||||
declare -a winning=() mine=() mywinning=()
|
||||
declare -i card_sum=0
|
||||
stripped=$(sed 's/Card\s\{1,3\}[0-9]\{1,3\}: //' <<< "${line}")
|
||||
winning+=($(cut -d '|' -f 1 <<< "${stripped}"))
|
||||
mine+=($(cut -d '|' -f 2 <<< "${stripped}"))
|
||||
for number in "${mine[@]}"; do
|
||||
for w in "${winning[@]}"; do
|
||||
if [[ ${number} -eq ${w} ]]; then
|
||||
mywinning+=("${number}")
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
for number in "${mywinning[@]}"; do
|
||||
if [[ card_sum -eq 0 ]]; then
|
||||
card_sum=$((card_sum+1))
|
||||
else
|
||||
card_sum=$((card_sum*2))
|
||||
fi
|
||||
done
|
||||
sum=$((sum+card_sum))
|
||||
done < input.txt
|
||||
echo "${sum}"
|
||||
}
|
||||
|
||||
main "$@"
|
@ -1,203 +0,0 @@
|
||||
Card 1: 87 75 80 68 71 57 58 59 70 48 | 56 67 75 76 31 49 48 22 43 68 98 86 70 91 27 46 4 87 72 37 71 58 29 79 80
|
||||
Card 2: 95 97 90 91 79 71 60 87 46 80 | 28 90 55 87 82 34 44 96 77 15 22 63 31 33 5 99 36 91 17 10 64 59 68 37 13
|
||||
Card 3: 23 73 50 78 93 30 56 10 8 64 | 61 48 87 46 12 75 92 37 62 45 24 81 79 55 76 82 9 1 16 72 13 27 41 86 19
|
||||
Card 4: 16 50 13 24 94 27 74 58 15 53 | 58 53 20 57 69 28 47 2 41 4 66 61 15 44 24 68 50 74 86 45 36 73 43 27 91
|
||||
Card 5: 39 53 29 10 84 22 83 4 5 32 | 50 28 45 5 6 65 18 7 92 83 3 55 81 26 80 39 44 60 90 37 91 36 54 14 74
|
||||
Card 6: 84 12 96 93 72 97 91 76 7 82 | 85 15 29 33 37 60 14 30 63 73 38 62 77 44 86 39 51 2 99 75 70 36 32 98 78
|
||||
Card 7: 78 12 1 50 48 62 33 8 83 99 | 12 50 79 48 59 81 26 14 5 11 37 8 36 91 95 20 46 44 21 32 58 93 53 90 54
|
||||
Card 8: 55 58 8 36 16 23 88 73 45 65 | 19 10 34 64 52 27 75 22 33 58 74 45 16 11 63 56 12 14 8 25 59 4 95 47 78
|
||||
Card 9: 95 14 83 17 7 69 44 31 45 37 | 2 69 81 39 76 86 29 73 72 32 67 5 9 16 95 90 36 27 88 55 61 6 37 79 1
|
||||
Card 10: 24 83 98 76 87 6 32 59 4 96 | 54 5 68 85 76 50 60 33 58 32 88 61 27 55 90 65 93 13 53 29 44 15 6 45 24
|
||||
Card 11: 55 92 57 65 44 21 49 8 13 48 | 17 44 79 11 65 50 46 14 40 69 31 62 55 86 36 60 30 52 25 93 41 56 48 99 51
|
||||
Card 12: 14 93 52 89 35 42 13 22 76 26 | 14 5 46 80 22 39 1 67 43 31 78 87 68 95 90 83 96 71 74 29 15 88 36 11 76
|
||||
Card 13: 55 78 95 85 43 53 80 12 1 59 | 42 60 32 70 10 91 94 88 68 99 45 71 54 93 76 52 44 30 2 18 72 90 9 7 63
|
||||
Card 14: 6 44 46 59 91 60 47 26 12 17 | 35 52 36 5 18 30 63 79 75 55 45 99 84 81 71 34 48 24 14 70 11 69 1 4 77
|
||||
Card 15: 29 17 94 87 84 3 96 33 5 48 | 65 25 20 45 85 1 43 37 14 11 69 81 6 92 93 46 8 23 31 2 30 61 22 79 71
|
||||
Card 16: 73 81 13 23 61 35 49 48 99 5 | 10 69 22 40 73 29 61 23 13 99 26 7 39 70 5 56 88 46 49 81 68 25 35 48 14
|
||||
Card 17: 64 47 6 10 16 74 26 95 28 73 | 86 27 47 6 68 49 64 48 74 26 16 28 20 99 61 10 12 25 73 88 70 95 67 3 76
|
||||
Card 18: 1 29 86 72 65 52 67 64 68 79 | 5 88 77 52 18 31 67 41 37 55 68 65 39 22 72 97 23 64 34 29 48 1 79 49 86
|
||||
Card 19: 71 33 43 91 59 35 69 18 78 9 | 86 55 54 59 91 36 45 9 94 43 39 11 44 1 93 23 66 97 4 62 71 98 18 31 28
|
||||
Card 20: 72 86 59 6 85 1 74 25 87 20 | 21 14 6 39 4 54 37 2 61 83 82 59 10 67 19 50 12 16 51 55 1 5 45 98 73
|
||||
Card 21: 35 39 40 21 19 87 58 49 78 32 | 28 91 27 45 44 25 11 35 84 26 98 87 14 97 93 70 55 19 34 16 8 7 67 54 5
|
||||
Card 22: 87 30 6 9 73 47 29 7 33 63 | 87 80 21 3 63 38 14 7 20 9 73 31 33 29 11 30 22 68 57 54 43 42 47 34 6
|
||||
Card 23: 51 61 36 99 86 88 21 6 30 74 | 30 42 99 86 20 44 74 64 72 67 81 93 79 51 5 48 21 75 36 23 6 60 4 66 88
|
||||
Card 24: 96 21 44 42 57 34 59 45 58 2 | 6 81 92 13 66 98 47 73 26 10 84 62 93 49 57 35 90 27 75 19 52 1 37 32 85
|
||||
Card 25: 17 55 53 49 25 59 71 33 35 11 | 55 82 92 74 29 17 46 40 2 26 25 32 96 49 11 35 53 3 87 59 71 33 73 36 38
|
||||
Card 26: 33 85 26 21 13 51 73 76 20 7 | 85 53 42 21 31 76 33 97 71 73 20 90 13 52 95 98 93 99 11 32 26 51 24 37 7
|
||||
Card 27: 62 39 22 67 69 5 89 1 36 34 | 10 52 68 95 32 82 22 94 21 29 5 45 87 51 18 4 15 19 59 55 11 78 60 63 84
|
||||
Card 28: 65 31 58 70 2 49 46 14 72 11 | 24 95 11 14 27 22 38 65 15 35 36 18 59 49 6 70 69 62 46 58 60 34 92 72 2
|
||||
Card 29: 78 6 94 55 65 17 97 30 66 33 | 80 32 56 48 49 16 88 61 57 20 37 75 51 58 86 29 42 39 41 60 62 69 10 81 24
|
||||
Card 30: 72 33 93 5 58 92 10 90 29 20 | 77 73 41 42 67 17 24 28 23 69 27 43 80 49 75 74 2 3 21 26 76 32 48 30 4
|
||||
Card 31: 9 93 77 42 49 71 36 98 46 1 | 68 39 10 32 36 7 47 55 95 33 48 56 31 61 98 40 50 81 94 77 45 12 16 6 35
|
||||
Card 32: 35 54 65 19 62 37 63 68 17 47 | 14 20 65 27 84 48 85 56 64 37 51 81 11 52 63 40 93 15 92 90 19 35 43 68 7
|
||||
Card 33: 21 80 78 56 29 65 6 12 57 22 | 51 61 7 1 19 22 77 62 78 54 58 29 89 97 34 83 56 57 11 98 73 6 17 16 70
|
||||
Card 34: 57 83 56 87 58 68 46 86 78 77 | 98 58 46 51 14 1 17 60 11 13 5 49 56 96 19 15 99 28 62 38 9 40 57 92 22
|
||||
Card 35: 34 29 33 85 95 9 47 11 39 25 | 49 91 61 13 99 84 80 96 77 82 97 59 20 30 4 65 70 74 5 37 41 81 75 93 48
|
||||
Card 36: 42 30 69 88 84 90 58 26 2 47 | 98 14 3 30 56 20 49 83 29 48 46 34 99 51 12 61 92 1 55 60 70 53 75 52 27
|
||||
Card 37: 7 70 87 71 25 85 50 86 77 72 | 94 23 90 73 52 79 31 30 49 71 8 26 88 38 42 5 81 82 69 51 63 35 80 22 19
|
||||
Card 38: 37 4 98 58 7 95 19 22 17 86 | 60 38 13 79 62 49 85 77 8 52 63 20 16 81 21 59 43 36 80 70 87 35 51 10 12
|
||||
Card 39: 68 79 63 42 17 92 99 95 2 29 | 85 24 88 25 52 81 61 1 27 50 84 98 31 49 19 51 38 93 33 15 22 28 14 70 67
|
||||
Card 40: 7 15 73 55 87 18 52 17 34 12 | 87 73 42 77 21 33 44 69 24 52 94 17 7 16 78 12 34 97 67 41 15 47 55 91 18
|
||||
Card 41: 70 1 14 88 52 46 32 59 67 75 | 17 1 75 13 46 87 64 32 48 52 53 80 30 21 3 88 94 14 38 70 73 67 28 41 86
|
||||
Card 42: 65 18 51 72 76 7 93 64 21 92 | 51 64 94 77 45 98 28 67 11 42 41 72 93 22 21 56 65 76 54 7 26 92 74 18 55
|
||||
Card 43: 35 82 2 99 52 68 81 38 14 94 | 51 46 27 10 21 7 56 71 77 6 38 44 25 79 94 33 76 15 22 99 68 84 5 14 81
|
||||
Card 44: 7 47 1 61 51 46 36 87 43 34 | 14 43 91 86 47 51 29 95 76 61 39 85 84 7 87 69 46 56 88 36 27 1 10 67 34
|
||||
Card 45: 17 83 85 90 65 18 67 75 68 25 | 89 67 31 51 99 46 85 42 84 75 59 96 17 68 26 79 65 81 32 83 25 90 37 4 18
|
||||
Card 46: 2 56 38 47 9 11 61 68 51 49 | 53 56 60 47 49 61 82 5 38 2 97 9 51 80 86 22 68 31 11 59 24 4 35 13 8
|
||||
Card 47: 39 2 68 61 28 8 23 62 46 89 | 23 15 46 78 62 1 60 36 52 35 10 65 90 67 4 18 16 72 44 61 6 59 14 45 91
|
||||
Card 48: 60 49 62 14 88 84 80 18 7 20 | 88 91 77 10 2 59 94 25 67 9 16 72 80 20 32 78 14 69 56 70 73 96 15 6 92
|
||||
Card 49: 14 67 94 15 12 40 7 68 22 88 | 91 15 67 61 7 95 85 72 94 78 12 68 14 35 41 89 60 22 88 81 93 86 40 84 92
|
||||
Card 50: 65 75 63 30 38 28 27 51 58 54 | 30 99 21 28 2 81 77 85 25 38 27 63 70 62 87 58 16 9 75 54 65 69 51 78 8
|
||||
Card 51: 30 18 35 67 45 87 27 13 82 51 | 9 51 95 45 2 67 61 82 81 30 52 35 5 43 27 87 83 49 13 44 21 22 48 78 18
|
||||
Card 52: 23 21 13 53 5 78 43 94 98 59 | 72 57 18 34 11 39 95 26 56 68 22 10 21 98 96 87 4 43 74 7 46 40 88 97 58
|
||||
Card 53: 39 55 57 87 6 68 78 14 36 7 | 74 76 20 58 87 6 67 26 57 1 41 44 17 14 42 7 43 81 35 39 55 36 59 66 96
|
||||
Card 54: 26 62 39 28 76 32 98 19 2 61 | 9 62 61 75 28 42 40 39 64 32 98 37 58 16 15 19 35 2 80 76 10 26 70 18 47
|
||||
Card 55: 31 47 13 40 5 80 94 45 54 43 | 61 17 52 78 60 2 37 58 19 85 89 14 20 10 3 13 80 41 25 79 4 70 36 75 11
|
||||
Card 56: 59 68 42 47 97 53 32 46 17 76 | 64 94 32 46 68 5 49 14 91 19 59 53 26 80 33 39 6 99 18 73 45 87 69 54 66
|
||||
Card 57: 70 23 37 94 4 46 26 33 71 72 | 64 38 71 53 37 96 29 80 41 90 60 94 18 45 27 62 72 33 79 32 26 92 49 12 4
|
||||
Card 58: 47 44 65 83 91 78 17 60 7 35 | 95 65 26 52 68 9 69 61 19 87 93 27 90 57 49 23 24 17 86 16 28 62 11 63 85
|
||||
Card 59: 3 92 67 72 64 2 74 14 49 73 | 41 57 98 95 91 78 20 42 25 60 54 36 56 34 86 37 9 10 52 79 80 53 88 18 46
|
||||
Card 60: 38 5 63 77 69 9 79 50 58 51 | 20 72 80 52 68 64 33 61 47 84 65 90 29 48 16 82 4 98 83 89 17 94 81 41 85
|
||||
Card 61: 13 65 75 26 39 63 88 92 72 87 | 98 43 81 95 26 69 27 7 57 37 82 41 71 18 55 53 10 36 64 47 84 4 20 77 67
|
||||
Card 62: 19 70 5 25 23 76 90 29 61 97 | 17 20 38 58 1 29 74 13 94 47 86 56 60 14 82 83 87 91 52 39 33 37 77 62 45
|
||||
Card 63: 22 24 17 19 55 48 23 3 8 11 | 4 67 90 50 99 54 49 78 94 20 96 2 86 74 83 79 76 15 70 52 34 98 5 82 88
|
||||
Card 64: 15 92 72 63 95 34 58 85 18 57 | 64 40 67 81 89 27 84 54 75 43 70 77 13 52 19 35 46 30 12 61 78 10 82 55 45
|
||||
Card 65: 66 35 28 50 30 80 15 85 4 23 | 3 30 99 96 70 47 4 64 35 66 78 41 65 63 23 28 44 67 85 80 61 50 17 15 92
|
||||
Card 66: 71 67 68 20 93 6 76 30 15 89 | 12 69 80 11 91 34 2 65 95 8 37 86 38 10 79 3 43 90 87 45 92 50 88 39 56
|
||||
Card 67: 94 46 12 2 53 27 57 45 33 1 | 33 72 74 64 25 97 17 2 73 48 3 56 63 40 31 24 45 83 85 79 6 75 38 55 49
|
||||
Card 68: 82 68 40 3 73 81 61 1 60 50 | 15 29 82 51 73 28 43 94 85 50 96 11 98 9 86 20 6 14 5 95 10 23 61 12 62
|
||||
Card 69: 25 94 17 29 2 34 48 87 51 49 | 95 17 84 91 14 34 3 89 87 71 2 51 35 93 7 29 74 55 48 25 49 56 94 20 68
|
||||
Card 70: 37 51 36 79 15 29 88 69 6 97 | 27 66 88 90 41 29 25 36 82 56 69 37 18 40 33 97 42 91 62 6 65 79 15 28 51
|
||||
Card 71: 77 28 31 19 40 35 80 11 76 26 | 10 74 63 70 11 67 76 31 40 75 96 77 60 80 35 28 68 53 19 64 51 43 26 9 25
|
||||
Card 72: 18 96 9 79 87 37 94 69 8 74 | 69 18 9 41 21 80 72 96 71 20 15 12 36 87 99 37 44 79 46 54 94 19 8 74 39
|
||||
Card 73: 11 60 75 68 66 57 51 70 20 30 | 6 12 35 45 56 38 46 65 54 59 19 68 64 11 57 22 74 30 90 13 37 93 5 20 51
|
||||
Card 74: 6 20 99 75 87 1 70 52 4 61 | 97 98 99 34 75 11 8 92 49 81 19 12 87 20 70 6 27 4 44 61 52 67 82 1 55
|
||||
Card 75: 95 80 34 33 66 55 63 19 7 46 | 19 83 58 4 46 57 72 99 98 63 36 80 34 30 11 64 24 52 93 55 22 76 78 32 89
|
||||
Card 76: 55 56 58 16 50 24 27 75 35 44 | 75 42 35 87 7 13 55 44 8 27 56 14 24 78 61 4 19 38 18 58 50 1 16 51 22
|
||||
Card 77: 99 2 77 33 48 47 44 87 32 23 | 46 71 47 54 23 55 18 28 56 48 69 14 26 44 24 32 77 60 81 2 40 33 83 11 87
|
||||
Card 78: 67 46 27 29 44 1 22 4 13 52 | 80 98 63 29 97 67 58 86 25 52 95 23 92 76 27 74 13 93 78 22 81 96 1 46 64
|
||||
Card 79: 60 94 4 59 76 64 34 69 35 62 | 10 8 82 43 76 44 69 20 41 29 1 35 34 59 42 22 13 32 4 40 65 28 16 84 99
|
||||
Card 80: 88 60 47 76 82 5 14 63 58 16 | 83 62 57 21 89 79 53 60 87 22 76 20 78 96 63 68 56 91 5 7 47 16 94 98 45
|
||||
Card 81: 46 67 14 43 39 44 48 35 6 94 | 2 31 12 42 78 76 61 62 40 37 29 36 16 75 4 41 21 19 85 49 84 73 89 96 3
|
||||
Card 82: 61 73 72 47 71 96 4 2 41 20 | 76 78 94 65 51 85 92 60 31 80 81 34 46 69 90 70 17 74 89 40 27 35 14 15 10
|
||||
Card 83: 82 60 62 23 81 27 61 26 75 28 | 29 78 79 9 13 39 30 97 31 96 86 84 42 28 14 55 81 44 17 8 25 12 35 34 82
|
||||
Card 84: 91 61 73 55 98 28 11 40 33 50 | 21 55 27 2 54 44 94 59 58 67 79 66 82 87 92 25 9 7 65 80 38 30 10 97 16
|
||||
Card 85: 39 81 47 2 8 95 35 63 36 10 | 75 58 6 19 20 55 18 99 88 25 78 77 65 93 59 57 12 13 66 91 3 67 34 41 29
|
||||
Card 86: 15 33 8 84 57 35 50 76 43 17 | 34 20 55 59 97 51 44 46 53 5 10 79 58 89 39 82 16 42 71 81 22 40 85 63 56
|
||||
Card 87: 44 7 57 42 53 85 62 9 56 63 | 95 60 69 56 24 43 7 4 91 44 63 76 30 39 62 9 85 57 16 34 53 99 50 66 42
|
||||
Card 88: 47 85 12 1 98 86 94 84 33 51 | 27 54 45 55 38 12 96 51 1 83 36 65 13 85 32 94 29 52 47 59 33 48 86 82 98
|
||||
Card 89: 45 15 77 41 57 43 54 2 32 24 | 44 79 10 28 23 97 99 40 95 25 22 9 35 59 53 74 14 37 34 61 39 30 71 12 94
|
||||
Card 90: 76 75 36 82 28 2 87 81 31 14 | 38 67 87 90 6 9 19 2 13 37 24 15 65 84 32 85 44 18 98 79 23 35 80 60 47
|
||||
Card 91: 21 19 37 97 7 29 34 79 45 13 | 17 42 12 71 21 4 51 37 7 81 34 65 36 19 13 59 96 97 31 16 79 87 29 86 45
|
||||
Card 92: 16 14 67 60 39 25 26 34 12 96 | 79 66 11 93 38 29 37 12 50 32 7 82 39 59 84 54 42 83 43 92 19 1 34 26 77
|
||||
Card 93: 70 37 71 28 22 62 85 9 65 27 | 78 91 28 65 42 22 70 30 92 54 9 72 38 24 62 51 10 49 89 13 14 66 84 61 93
|
||||
Card 94: 80 48 40 83 87 19 53 66 69 33 | 80 79 66 76 58 94 60 70 20 42 72 87 19 30 75 40 67 12 36 96 11 29 59 63 33
|
||||
Card 95: 68 91 48 52 79 40 83 97 16 63 | 77 73 52 88 97 91 48 22 35 64 31 40 63 68 60 28 57 30 51 54 36 16 92 19 79
|
||||
Card 96: 78 81 13 87 20 8 80 63 2 3 | 20 29 62 72 44 90 54 22 3 35 55 16 96 80 37 93 73 23 50 33 6 63 78 8 13
|
||||
Card 97: 32 39 59 73 8 34 36 46 85 47 | 14 22 15 87 46 34 67 77 44 91 47 5 73 68 59 7 40 94 98 36 21 76 64 86 39
|
||||
Card 98: 19 75 37 82 94 6 57 15 78 58 | 9 79 6 71 91 39 38 61 59 89 90 1 80 17 86 35 98 63 27 74 5 49 25 70 73
|
||||
Card 99: 44 22 48 23 31 78 15 89 49 24 | 36 89 27 81 67 56 22 28 74 47 25 18 44 3 15 23 58 73 69 39 75 17 85 1 7
|
||||
Card 100: 56 15 30 64 37 89 51 96 63 90 | 56 23 24 57 44 9 41 65 6 26 69 36 21 66 94 67 7 10 34 59 14 40 99 93 98
|
||||
Card 101: 42 95 60 30 25 87 82 98 40 54 | 22 85 24 84 19 34 3 43 97 8 18 57 58 26 91 44 56 11 16 66 78 73 62 50 68
|
||||
Card 102: 14 64 72 79 55 78 44 12 76 36 | 69 74 13 78 59 82 15 46 49 11 81 83 97 9 58 4 98 60 43 34 30 67 2 47 37
|
||||
Card 103: 64 82 36 57 33 8 80 91 95 32 | 84 45 12 44 59 94 86 53 48 96 26 66 70 65 39 37 21 72 49 60 56 35 82 98 92
|
||||
Card 104: 76 18 88 52 69 44 57 99 20 12 | 60 74 21 35 77 39 40 29 46 37 95 65 93 36 43 86 48 59 6 11 16 72 28 55 97
|
||||
Card 105: 91 30 6 25 7 64 41 28 72 53 | 93 63 59 31 4 87 45 97 70 29 39 80 98 66 44 51 54 62 57 46 56 18 13 81 27
|
||||
Card 106: 15 59 45 36 74 86 35 62 87 14 | 29 35 81 53 60 69 47 25 61 43 13 62 84 96 79 75 68 23 32 18 37 72 63 4 36
|
||||
Card 107: 62 41 56 15 66 50 63 20 43 84 | 43 66 99 3 49 20 80 50 36 38 52 22 23 24 41 62 84 83 15 68 63 56 94 35 97
|
||||
Card 108: 67 51 97 26 11 61 91 55 7 23 | 47 96 26 78 22 87 33 51 34 59 53 3 97 91 86 11 21 89 13 61 23 67 55 7 24
|
||||
Card 109: 72 23 61 6 1 65 83 47 10 41 | 27 16 98 74 55 61 5 1 88 68 41 47 99 48 76 31 85 83 38 72 91 93 36 90 80
|
||||
Card 110: 34 22 81 62 40 25 43 60 12 69 | 69 81 71 66 54 15 17 79 25 93 34 51 43 62 40 12 30 56 27 47 60 33 22 94 65
|
||||
Card 111: 48 24 75 46 37 65 33 74 64 92 | 75 46 25 65 92 33 64 83 39 16 45 48 97 56 11 78 94 62 4 24 37 96 74 31 40
|
||||
Card 112: 94 92 39 58 34 78 61 7 50 88 | 83 6 52 39 92 17 40 63 54 34 7 85 89 64 25 50 99 77 33 13 11 81 35 78 41
|
||||
Card 113: 23 25 75 44 18 8 29 79 48 60 | 7 70 80 63 60 42 88 25 44 23 21 11 51 93 47 82 16 86 73 62 96 75 2 29 19
|
||||
Card 114: 52 42 66 15 57 29 21 47 89 22 | 77 81 52 8 66 21 98 61 71 2 85 34 42 95 93 25 67 60 82 47 78 56 63 87 84
|
||||
Card 115: 63 81 53 30 8 94 75 76 45 71 | 53 93 40 18 45 71 76 67 75 92 15 72 35 94 65 30 88 22 81 8 63 50 80 5 82
|
||||
Card 116: 8 33 23 82 63 25 65 4 97 28 | 79 75 71 46 41 74 6 86 64 33 24 70 82 87 9 76 36 3 5 97 92 4 1 12 62
|
||||
Card 117: 9 97 4 59 31 78 73 99 84 11 | 93 65 12 39 29 76 80 82 43 37 26 57 79 27 46 90 98 54 31 34 17 62 95 51 9
|
||||
Card 118: 11 42 73 23 28 62 68 15 31 48 | 17 81 29 15 10 86 25 68 28 80 33 78 89 11 82 96 12 34 19 99 67 13 64 59 91
|
||||
Card 119: 22 16 61 76 19 92 5 89 86 1 | 37 35 77 44 7 42 86 92 41 81 16 95 12 1 85 60 63 79 5 25 62 46 73 45 19
|
||||
Card 120: 97 11 71 31 44 24 12 49 15 17 | 97 44 78 49 64 61 42 55 31 38 12 87 53 32 41 6 68 62 19 94 13 79 29 56 71
|
||||
Card 121: 5 50 95 7 14 6 35 64 99 94 | 30 54 80 90 68 98 6 71 61 81 23 24 64 37 40 15 53 63 31 35 7 49 14 99 42
|
||||
Card 122: 5 72 29 22 71 35 41 82 15 56 | 3 45 61 68 70 41 56 26 82 62 29 36 84 80 95 81 96 83 20 35 28 54 21 76 47
|
||||
Card 123: 80 4 93 25 97 10 20 84 3 67 | 14 18 12 20 86 96 63 67 60 54 13 85 23 37 10 16 71 65 33 5 98 1 74 53 51
|
||||
Card 124: 43 64 62 31 86 1 30 23 15 28 | 77 1 99 27 48 35 2 40 57 61 23 9 37 74 91 46 92 83 24 90 96 32 80 45 31
|
||||
Card 125: 53 47 45 50 82 37 26 41 22 57 | 43 25 37 29 89 20 17 8 1 46 2 55 53 44 61 78 65 72 69 85 12 93 28 34 80
|
||||
Card 126: 36 27 94 41 56 21 18 13 59 96 | 73 91 2 14 29 98 79 8 11 3 38 16 69 71 77 92 66 60 18 9 1 57 12 22 43
|
||||
Card 127: 19 12 69 97 81 26 73 83 34 51 | 91 47 89 62 94 8 66 43 35 93 48 24 71 40 42 75 13 14 65 28 61 95 32 25 9
|
||||
Card 128: 99 78 81 4 44 58 10 83 67 5 | 5 83 95 17 34 68 91 10 4 88 56 38 49 44 66 11 78 7 50 67 45 21 98 99 58
|
||||
Card 129: 94 35 8 59 72 56 51 98 47 63 | 98 71 61 72 51 54 35 34 95 9 82 88 47 8 66 57 90 55 81 33 59 56 64 63 94
|
||||
Card 130: 81 25 85 84 88 26 87 14 40 77 | 25 74 20 13 30 11 72 77 88 40 70 67 47 14 80 86 81 26 45 87 79 33 85 84 39
|
||||
Card 131: 28 83 7 69 87 48 46 67 33 10 | 37 10 48 96 38 99 14 60 28 42 26 94 46 24 84 68 87 72 85 67 4 83 31 7 47
|
||||
Card 132: 33 65 47 66 48 9 69 68 76 73 | 21 18 70 64 55 19 31 81 20 77 12 94 59 15 98 44 57 52 92 54 93 40 89 16 78
|
||||
Card 133: 67 54 21 71 43 56 68 65 55 99 | 16 83 20 45 85 92 34 61 88 33 51 65 24 68 58 55 91 81 54 43 5 1 77 49 25
|
||||
Card 134: 73 82 41 78 91 72 13 7 46 88 | 78 88 32 57 12 56 44 73 41 79 27 99 49 13 82 91 87 97 62 46 83 7 23 60 71
|
||||
Card 135: 19 30 91 16 15 88 5 4 72 38 | 38 41 23 87 3 78 75 11 88 53 5 72 4 56 54 65 19 76 15 27 82 39 70 69 17
|
||||
Card 136: 39 66 64 79 90 51 69 6 44 23 | 51 1 21 44 23 78 27 66 69 42 6 50 74 48 39 79 57 29 53 3 10 13 30 90 64
|
||||
Card 137: 82 75 28 96 13 25 30 59 76 5 | 25 45 59 79 96 44 88 75 82 30 13 18 20 97 21 5 70 31 76 95 17 37 27 28 53
|
||||
Card 138: 23 21 53 59 82 11 99 30 68 1 | 51 11 21 53 8 43 24 71 33 63 75 66 23 82 1 20 92 50 86 59 99 45 84 30 68
|
||||
Card 139: 43 44 12 68 14 70 83 84 39 40 | 72 18 54 48 43 91 56 1 11 49 83 59 29 73 87 40 37 6 50 14 74 61 70 2 36
|
||||
Card 140: 64 4 86 61 11 72 66 73 83 14 | 74 86 84 8 36 5 76 73 83 88 10 28 38 64 4 12 72 23 53 42 33 91 61 45 55
|
||||
Card 141: 46 33 44 21 99 64 29 4 28 30 | 1 95 13 97 9 59 15 41 89 35 43 98 81 27 94 3 65 88 91 12 17 10 23 61 48
|
||||
Card 142: 2 85 8 98 74 62 76 7 79 60 | 59 42 2 49 24 34 25 76 8 71 98 86 6 7 16 33 74 62 89 13 39 31 85 79 87
|
||||
Card 143: 50 10 55 73 71 3 20 57 15 9 | 42 20 71 54 11 9 55 37 15 3 53 41 13 99 63 57 7 73 28 84 18 35 5 32 10
|
||||
Card 144: 26 38 75 71 89 40 96 81 83 48 | 42 77 11 76 78 15 19 86 10 34 61 58 29 14 64 94 63 33 70 13 88 82 59 28 93
|
||||
Card 145: 72 35 67 80 78 20 57 48 64 28 | 44 70 79 37 5 96 31 13 10 83 93 29 46 94 66 47 6 34 14 18 33 8 69 49 20
|
||||
Card 146: 42 10 61 56 2 22 38 15 67 6 | 72 83 53 80 52 31 74 73 20 12 87 71 78 95 25 45 75 43 32 85 82 7 13 90 19
|
||||
Card 147: 30 2 48 5 16 25 70 89 35 85 | 3 5 55 90 16 86 70 87 17 29 74 14 22 78 39 37 71 45 79 42 2 60 21 62 89
|
||||
Card 148: 61 50 41 22 75 80 46 93 55 6 | 62 68 95 45 74 21 13 52 66 2 17 53 97 83 90 40 44 28 25 86 14 82 15 30 84
|
||||
Card 149: 49 54 61 92 19 16 78 83 15 71 | 7 33 40 69 2 34 70 9 91 79 74 42 67 38 82 60 28 43 23 80 39 56 30 66 1
|
||||
Card 150: 47 85 71 36 9 98 45 28 7 58 | 94 88 20 62 13 77 85 27 43 92 18 41 31 3 2 45 74 99 30 40 26 93 19 23 65
|
||||
Card 151: 65 90 39 91 53 76 79 51 9 36 | 5 84 49 13 70 64 15 33 92 67 41 57 19 21 22 87 54 50 46 66 52 24 71 29 16
|
||||
Card 152: 61 62 51 11 14 44 10 29 31 35 | 95 47 96 16 5 32 88 90 52 65 70 94 9 80 81 56 50 43 15 34 45 68 67 42 18
|
||||
Card 153: 91 86 12 23 53 39 96 79 14 76 | 68 66 83 69 73 42 59 67 4 38 11 46 16 95 71 52 88 13 19 48 9 99 30 62 43
|
||||
Card 154: 47 44 72 6 95 7 21 64 59 29 | 72 7 12 33 21 14 91 3 99 71 64 44 70 63 6 22 88 16 43 57 73 59 76 60 47
|
||||
Card 155: 38 36 24 69 59 58 96 45 39 30 | 17 64 59 31 80 36 25 89 96 4 27 12 30 74 11 29 57 63 45 19 42 38 69 58 39
|
||||
Card 156: 60 93 14 54 53 40 34 26 1 28 | 46 62 40 69 48 39 35 68 86 22 19 10 42 25 88 67 58 96 54 44 56 85 31 90 99
|
||||
Card 157: 82 93 7 76 69 1 36 5 4 3 | 66 96 92 52 29 5 91 62 45 27 25 31 28 78 99 95 73 14 37 26 9 98 42 55 11
|
||||
Card 158: 34 52 78 67 96 62 54 85 86 31 | 21 42 63 51 12 70 15 83 34 35 62 69 52 54 36 85 31 86 67 41 53 7 1 96 82
|
||||
Card 159: 67 49 58 35 82 57 29 6 20 25 | 30 46 2 75 38 57 99 7 29 69 94 40 12 45 97 49 66 6 35 76 32 37 71 60 68
|
||||
Card 160: 17 49 10 5 34 2 23 91 3 19 | 29 39 67 53 14 61 41 85 18 65 56 77 54 55 13 27 28 45 60 7 62 6 96 38 35
|
||||
Card 161: 4 42 38 50 85 92 27 25 82 7 | 82 5 83 71 52 43 12 75 73 92 96 1 61 59 25 85 7 22 23 80 35 15 97 88 30
|
||||
Card 162: 42 69 75 64 40 12 29 56 33 62 | 57 5 83 79 26 55 84 60 70 16 47 2 19 30 7 62 89 76 20 90 66 78 21 9 87
|
||||
Card 163: 52 10 27 86 7 72 95 88 13 75 | 94 76 43 33 31 69 35 68 39 78 48 83 28 66 67 15 72 34 32 25 85 53 40 46 1
|
||||
Card 164: 14 95 31 43 91 56 22 68 17 33 | 74 98 24 59 4 93 67 23 64 35 51 42 92 88 63 20 29 70 16 82 89 45 39 27 12
|
||||
Card 165: 29 5 49 25 67 79 56 44 43 93 | 20 54 10 52 8 50 98 9 73 92 78 24 86 69 77 82 80 41 94 36 35 22 32 38 3
|
||||
Card 166: 63 92 68 93 58 16 90 6 13 46 | 31 45 39 8 65 49 23 81 62 72 7 15 82 35 53 4 80 83 48 13 10 11 71 40 61
|
||||
Card 167: 58 70 1 3 7 81 65 83 79 77 | 87 8 59 29 18 6 14 48 35 9 60 94 80 92 51 2 73 36 47 27 86 89 41 42 4
|
||||
Card 168: 69 93 96 77 76 90 17 88 11 26 | 31 13 77 9 86 82 51 67 53 99 76 35 81 6 28 92 24 14 87 59 41 37 88 18 96
|
||||
Card 169: 99 40 11 87 24 55 4 46 66 49 | 60 67 72 31 94 69 42 46 86 17 47 70 95 90 6 4 3 59 61 24 93 73 28 58 96
|
||||
Card 170: 29 84 4 80 72 94 9 7 55 68 | 24 62 7 35 21 55 85 94 29 4 84 38 42 33 2 77 58 9 11 80 41 72 76 13 68
|
||||
Card 171: 93 7 9 11 12 13 79 51 99 62 | 99 28 51 12 82 11 35 18 93 34 7 17 2 13 63 54 9 69 62 84 68 79 58 36 70
|
||||
Card 172: 16 79 33 10 58 22 67 98 46 43 | 75 24 96 64 4 50 38 10 5 31 45 21 98 7 17 34 60 72 97 92 6 3 99 86 9
|
||||
Card 173: 98 73 26 29 85 75 13 22 27 35 | 87 76 25 43 82 17 79 74 16 91 37 97 46 15 14 40 52 70 31 68 81 5 36 72 57
|
||||
Card 174: 4 29 72 26 46 89 61 15 16 11 | 4 68 89 24 58 94 46 26 55 15 67 61 72 98 75 84 29 11 47 2 54 13 9 28 16
|
||||
Card 175: 40 49 71 63 25 47 44 26 98 31 | 26 20 18 96 64 92 88 63 62 95 47 33 86 35 70 75 90 27 1 59 54 74 80 41 77
|
||||
Card 176: 92 17 34 39 64 49 70 69 44 91 | 49 24 4 81 74 31 28 36 69 39 68 16 98 2 3 26 96 76 57 19 44 95 93 29 34
|
||||
Card 177: 60 32 48 84 3 86 62 55 22 58 | 17 91 95 50 64 89 32 60 82 62 49 58 25 12 86 3 40 16 84 87 66 61 77 55 9
|
||||
Card 178: 92 4 66 65 13 87 57 16 78 3 | 92 16 81 7 78 42 25 44 43 24 66 29 50 40 19 71 89 53 59 77 67 76 39 84 1
|
||||
Card 179: 6 67 72 98 79 45 12 87 77 60 | 19 12 57 66 14 26 28 31 18 24 45 6 15 29 99 27 90 87 10 59 92 36 58 72 79
|
||||
Card 180: 6 9 43 74 48 87 52 56 76 30 | 97 8 88 19 2 54 9 29 3 39 23 71 93 41 95 87 98 68 36 42 94 40 45 84 85
|
||||
Card 181: 26 5 23 14 59 6 33 89 97 96 | 16 7 41 8 45 71 47 98 67 88 58 13 79 66 85 81 32 17 60 91 51 49 27 69 3
|
||||
Card 182: 53 5 83 87 3 44 25 98 48 24 | 14 77 95 98 40 81 97 85 80 15 33 38 75 17 5 56 71 43 65 28 87 10 66 22 70
|
||||
Card 183: 67 20 49 89 38 55 16 79 27 45 | 43 57 35 34 26 93 13 63 5 87 72 69 28 96 78 3 48 47 61 94 59 7 37 95 1
|
||||
Card 184: 1 73 35 99 24 74 64 21 14 81 | 48 81 57 15 28 49 31 82 91 8 62 79 54 20 95 13 21 97 98 19 51 6 83 70 61
|
||||
Card 185: 31 6 98 7 17 45 42 37 67 56 | 53 73 7 91 20 63 57 96 28 72 15 44 55 29 23 77 58 32 1 11 62 65 95 83 25
|
||||
Card 186: 93 81 16 50 3 40 87 46 90 58 | 89 70 62 28 4 19 2 63 21 53 14 9 55 25 54 38 94 82 47 86 36 96 49 8 80
|
||||
Card 187: 45 71 74 81 84 18 23 35 86 25 | 34 90 45 74 63 35 1 3 88 12 84 71 97 29 32 26 40 18 76 89 9 80 86 94 64
|
||||
Card 188: 3 21 56 32 1 26 54 60 13 28 | 40 24 26 28 78 12 11 92 17 98 30 27 1 87 25 97 57 49 52 38 51 32 42 47 7
|
||||
Card 189: 41 82 69 64 35 71 79 61 44 36 | 35 69 22 37 44 29 79 39 14 3 56 66 36 62 82 26 72 61 88 33 97 64 41 98 34
|
||||
Card 190: 96 84 47 27 31 17 59 40 64 67 | 16 32 82 27 21 75 93 74 60 80 29 48 23 31 54 98 79 58 17 67 18 43 12 25 96
|
||||
Card 191: 35 60 71 44 21 62 81 14 67 85 | 36 37 69 9 34 35 62 40 54 41 1 13 23 58 85 86 24 55 14 7 92 96 50 11 81
|
||||
Card 192: 82 95 6 69 48 56 42 96 94 93 | 98 92 96 63 42 76 16 50 95 48 28 8 39 6 94 47 69 97 56 82 44 93 21 26 7
|
||||
Card 193: 22 86 12 38 3 6 44 77 27 59 | 53 80 89 25 92 38 63 86 65 34 99 46 27 75 8 1 7 47 66 29 2 77 61 12 54
|
||||
Card 194: 15 20 33 91 80 61 37 99 58 92 | 10 76 99 58 97 91 71 64 33 36 29 30 42 37 87 66 90 6 49 22 68 40 92 2 73
|
||||
Card 195: 10 59 86 92 5 55 25 48 36 45 | 27 5 48 84 25 57 35 78 56 63 82 28 87 92 88 10 19 42 36 53 86 60 81 39 55
|
||||
Card 196: 69 95 34 9 80 55 11 30 49 88 | 15 89 44 26 48 49 74 54 35 77 47 11 9 21 25 95 31 88 53 56 42 69 18 10 60
|
||||
Card 197: 62 23 83 63 24 58 57 72 8 68 | 41 25 26 58 80 45 99 55 63 96 46 60 84 33 98 42 50 62 44 52 47 7 57 75 12
|
||||
Card 198: 86 22 73 29 41 40 11 76 69 83 | 78 20 14 67 51 93 8 47 43 44 82 16 2 55 96 98 61 48 31 49 91 24 3 27 87
|
||||
Card 199: 27 59 83 12 76 82 74 98 47 73 | 30 20 63 53 67 68 16 4 66 10 93 61 89 80 36 75 62 99 1 5 70 31 17 82 22
|
||||
Card 200: 49 66 64 92 36 61 44 96 68 67 | 57 55 19 18 78 64 90 85 72 84 5 10 38 71 74 34 68 30 46 83 86 25 89 50 49
|
||||
Card 201: 83 53 58 64 84 72 70 19 41 17 | 22 55 50 90 65 88 6 76 43 70 26 63 41 91 82 79 89 98 71 54 80 67 59 36 49
|
||||
Card 202: 70 55 83 56 42 25 11 1 41 49 | 32 54 80 59 53 23 75 8 68 6 94 45 86 3 61 98 36 14 44 18 89 39 81 51 88
|
||||
Card 203: 12 10 29 80 87 71 65 37 55 9 | 11 5 75 46 3 81 6 54 64 32 95 33 49 34 74 48 92 20 21 56 53 50 41 61 36
|
@ -1,57 +0,0 @@
|
||||
--- Part Two ---
|
||||
|
||||
Just as you're about to report your findings to the Elf, one of you realizes
|
||||
that the rules have actually been printed on the back of every card this whole
|
||||
time.
|
||||
|
||||
There's no such thing as "points". Instead, scratchcards only cause you to win
|
||||
more scratchcards equal to the number of winning numbers you have.
|
||||
|
||||
Specifically, you win copies of the scratchcards below the winning card equal to
|
||||
the number of matches. So, if card 10 were to have 5 matching numbers, you would
|
||||
win one copy each of cards 11, 12, 13, 14, and 15.
|
||||
|
||||
Copies of scratchcards are scored like normal scratchcards and have the same
|
||||
card number as the card they copied. So, if you win a copy of card 10 and it has
|
||||
5 matching numbers, it would then win a copy of the same cards that the original
|
||||
card 10 won: cards 11, 12, 13, 14, and 15. This process repeats until none of
|
||||
the copies cause you to win any more cards. (Cards will never make you copy a
|
||||
card past the end of the table.)
|
||||
|
||||
This time, the above example goes differently:
|
||||
|
||||
Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
|
||||
Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
|
||||
Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1
|
||||
Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83
|
||||
Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
|
||||
Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11
|
||||
|
||||
Card 1 has four matching numbers, so you win one copy each of the next four
|
||||
cards: cards 2, 3, 4, and 5.
|
||||
|
||||
Your original card 2 has two matching numbers, so you win one copy each of cards
|
||||
3 and 4.
|
||||
|
||||
Your copy of card 2 also wins one copy each of cards 3 and 4.
|
||||
|
||||
Your four instances of card 3 (one original and three copies) have two matching
|
||||
numbers, so you win four copies each of cards 4 and 5.
|
||||
|
||||
Your eight instances of card 4 (one original and seven copies) have one matching
|
||||
number, so you win eight copies of card 5.
|
||||
|
||||
Your fourteen instances of card 5 (one original and thirteen copies) have no
|
||||
matching numbers and win no more cards.
|
||||
|
||||
Your one instance of card 6 (one original) has no matching numbers and wins no
|
||||
more cards.
|
||||
|
||||
Once all of the originals and copies have been processed, you end up with 1
|
||||
instance of card 1, 2 instances of card 2, 4 instances of card 3, 8 instances of
|
||||
card 4, 14 instances of card 5, and 1 instance of card 6. In total, this example
|
||||
pile of scratchcards causes you to ultimately have 30 scratchcards!
|
||||
|
||||
Process all of the original and copied scratchcards until no more scratchcards
|
||||
are won. Including the original set of scratchcards, how many total scratchcards
|
||||
do you end up with?
|
@ -1,52 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
mapfile -t -O 1 INPUT < "input.txt"
|
||||
CARDS="${#INPUT[@]}"
|
||||
|
||||
run_cards ()
|
||||
{
|
||||
for ((x=1; x<=CARDS; x++)); do
|
||||
declare -a winning=() mine=()
|
||||
declare -i matching=0
|
||||
declare -i count="${hand[$x]}"
|
||||
stripped=$(sed 's/Card\s\{1,3\}[0-9]\{1,3\}: //' <<< "${INPUT[$x]}")
|
||||
winning+=($(cut -d '|' -f 1 <<< "${stripped}"))
|
||||
mine+=($(cut -d '|' -f 2 <<< "${stripped}"))
|
||||
for number in "${mine[@]}"; do
|
||||
for w in "${winning[@]}"; do
|
||||
if [[ ${number} -eq ${w} ]]; then
|
||||
matching=$((matching+1))
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
for ((i=1; i<=matching; i++)); do
|
||||
hand[$((x+i))]=$((${hand[$((x+i))]}+count))
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
declare -i sum=0
|
||||
declare -A hand=()
|
||||
for ((z=1; z<=CARDS; z++)); do
|
||||
hand+=([${z}]=1)
|
||||
done
|
||||
run_cards "${hand[@]}"
|
||||
for ((z=1; z<=CARDS; z++)); do
|
||||
sum=$((sum+${hand[$z]}))
|
||||
done
|
||||
echo "${sum}"
|
||||
}
|
||||
|
||||
main "$@"
|
174
2023/5/1/input
174
2023/5/1/input
@ -1,174 +0,0 @@
|
||||
seeds: 194657215 187012821 1093203236 6077151 44187305 148722449 2959577030 152281079 3400626717 198691716 1333399202 287624830 2657325069 35258407 1913289352 410917164 1005856673 850939 839895010 162018909
|
||||
|
||||
seed-to-soil map:
|
||||
466206721 134904099 264145987
|
||||
3226739510 2500159633 122177414
|
||||
1107118949 4139510909 155456387
|
||||
2314679916 2622337047 59899451
|
||||
2642618541 1908002826 511067679
|
||||
0 399050086 167531444
|
||||
1262575336 2682236498 1052104580
|
||||
3448620320 1415756771 259155097
|
||||
302435543 566581530 163771178
|
||||
3348916924 4039807513 99703396
|
||||
3153686220 1674911868 73053290
|
||||
3788293662 1747965158 160037668
|
||||
3948331330 3734341078 305466435
|
||||
2374579367 1228806725 186950046
|
||||
2561529413 2419070505 81089128
|
||||
167531444 0 134904099
|
||||
3707775417 1148288480 80518245
|
||||
4253797765 1107118949 41169531
|
||||
|
||||
soil-to-fertilizer map:
|
||||
3913658055 3217667557 44136240
|
||||
3043638173 1755409772 387575354
|
||||
1214033686 3261803797 213545970
|
||||
3431213527 3475349767 482444528
|
||||
1994011339 2522356968 695310589
|
||||
2689321928 1214033686 354316245
|
||||
1427579656 2142985126 379371842
|
||||
1806951498 1568349931 187059841
|
||||
|
||||
fertilizer-to-water map:
|
||||
2553394045 2097964132 64191777
|
||||
3153687517 3499502814 665965431
|
||||
1104565830 789107360 151317021
|
||||
4084493704 2165934452 60088979
|
||||
981078109 1551802916 123487721
|
||||
2935219151 4165468245 66838136
|
||||
10669639 1277616562 132965227
|
||||
839228347 1410581789 141221127
|
||||
3942173186 2018304529 79659603
|
||||
393057134 444333135 344145590
|
||||
2617585822 2253442971 317633329
|
||||
4237573988 3156387517 57393308
|
||||
1341340213 99436946 344896189
|
||||
143634866 1746717555 204406814
|
||||
776848617 0 21473714
|
||||
386359019 1270918447 6698115
|
||||
4168968434 3430897260 68605554
|
||||
2497629182 3375132397 55764863
|
||||
3819652948 3213780825 9721342
|
||||
1686236402 940424381 47687418
|
||||
4021832789 4232306381 62660915
|
||||
4144582683 2162155909 3778543
|
||||
1733923820 1675290637 30520902
|
||||
737202724 21473714 39645893
|
||||
2018304529 2591683508 479324653
|
||||
798322331 1705811539 40906016
|
||||
0 1260248808 10669639
|
||||
980449474 788478725 628635
|
||||
3002057287 3223502167 151630230
|
||||
3829374290 2226023431 27419540
|
||||
348041680 61119607 38317339
|
||||
3856793830 3071008161 85379356
|
||||
1764444722 1073569161 186679647
|
||||
4148361226 2571076300 20607208
|
||||
1255882851 988111799 85457362
|
||||
|
||||
water-to-light map:
|
||||
3143216572 2396957585 46085818
|
||||
2930160319 3087666064 82806318
|
||||
3012966637 3275730008 11481558
|
||||
1791164654 628261856 251676187
|
||||
1156959152 1008045214 174725983
|
||||
3597974089 4238330323 56636973
|
||||
2659665097 3287211566 62612544
|
||||
489714994 0 304501033
|
||||
2323644539 2017991146 71374674
|
||||
2611713237 3480351863 47951860
|
||||
4135255968 3931716786 159711328
|
||||
1331685135 879938043 128107171
|
||||
2396957585 2748883399 70018348
|
||||
408833803 1297158141 80881191
|
||||
1469631779 1182771197 103330914
|
||||
4004728215 3349824110 58812180
|
||||
1012078485 2008335392 9655754
|
||||
3024448195 2932857654 118768377
|
||||
192304632 2089365820 87451432
|
||||
4063540395 3408636290 71715573
|
||||
3823753472 2665304126 83579273
|
||||
117236420 1933267180 75068212
|
||||
2218325460 1378039332 105319079
|
||||
2722277641 3170472382 32223106
|
||||
1459792306 618379493 9839473
|
||||
3225342423 3528303723 55360789
|
||||
901528396 304501033 110507199
|
||||
3654611062 2471800766 96107890
|
||||
1012035595 628218966 42890
|
||||
1118925110 1719748519 38034042
|
||||
3907332745 2567908656 97395470
|
||||
2466975933 3786979482 144737304
|
||||
794216027 1612436150 107312369
|
||||
2901402956 2443043403 28757363
|
||||
0 415008232 117236420
|
||||
3750718952 3202695488 73034520
|
||||
3189302390 3051626031 36040033
|
||||
3394659119 3583664512 203314970
|
||||
2754500747 4091428114 146902209
|
||||
2042840841 1757782561 175484619
|
||||
3280703212 2818901747 113955907
|
||||
1021734239 532244652 86134841
|
||||
279756064 1483358411 129077739
|
||||
1572962693 2176817252 218201961
|
||||
1107869080 1286102111 11056030
|
||||
|
||||
light-to-temperature map:
|
||||
1609050489 2309171782 372577802
|
||||
2023682469 2836643763 897111138
|
||||
834447570 143604042 411534753
|
||||
428779503 1217157762 28824561
|
||||
143604042 931982301 108906615
|
||||
252510657 1040888916 176268846
|
||||
3431278062 1484221851 471209429
|
||||
1981628291 3733754901 42054178
|
||||
4140073117 2681749584 154894179
|
||||
1484221851 4170138658 124828638
|
||||
3902487491 1955431280 237585626
|
||||
457604064 555138795 376843506
|
||||
3036948483 3775809079 394329579
|
||||
2920793607 2193016906 116154876
|
||||
|
||||
temperature-to-humidity map:
|
||||
1348484361 0 45849582
|
||||
1394333943 726347262 166590764
|
||||
1797084784 3346946555 119105515
|
||||
1163891565 1265639794 165909682
|
||||
2199751891 3274125222 72821333
|
||||
4012454029 2231107899 181228118
|
||||
1008425725 207338839 56688993
|
||||
2322219090 3174539335 24543729
|
||||
3987057737 3199083064 25396292
|
||||
1560924707 45849582 62712410
|
||||
3424140824 1837299459 190417072
|
||||
2272573224 3224479356 27702302
|
||||
2346762819 2412336017 518856401
|
||||
329181964 1432789749 172164254
|
||||
3783666369 2027716531 203391368
|
||||
753484930 471406467 254940795
|
||||
1916190299 2931192418 243346917
|
||||
501346218 892938026 44760077
|
||||
1329801247 1604954003 18683114
|
||||
2865619220 3567337219 558521604
|
||||
546106295 264027832 207378635
|
||||
2300275526 3252181658 21943564
|
||||
4193682147 3466052070 101285149
|
||||
327941691 1431549476 1240273
|
||||
0 937698103 327941691
|
||||
2159537216 1797084784 40214675
|
||||
3614557896 4125858823 169108473
|
||||
1065114718 108561992 98776847
|
||||
|
||||
humidity-to-location map:
|
||||
440744287 1133551978 536306564
|
||||
4042633851 4000620330 37465866
|
||||
977050851 1669858542 136276424
|
||||
2136551597 4038086196 256881100
|
||||
198620952 0 242123335
|
||||
1113327275 242123335 891428643
|
||||
4080099717 3802748040 197872290
|
||||
2695699324 2136551597 1346934527
|
||||
4277972007 3785752751 16995289
|
||||
2393432697 3483486124 302266627
|
||||
0 1806134966 198620952
|
@ -1,116 +0,0 @@
|
||||
\--- Day 5: If You Give A Seed A Fertilizer ---
|
||||
----------
|
||||
|
||||
You take the boat and find the gardener right where you were told he would be: managing a giant "garden" that looks more to you like a farm.
|
||||
|
||||
"A water source? Island Island *is* the water source!" You point out that Snow Island isn't receiving any water.
|
||||
|
||||
"Oh, we had to stop the water because we *ran out of sand* to [filter](https://en.wikipedia.org/wiki/Sand_filter) it with! Can't make snow with dirty water. Don't worry, I'm sure we'll get more sand soon; we only turned off the water a few days... weeks... oh no." His face sinks into a look of horrified realization.
|
||||
|
||||
"I've been so busy making sure everyone here has food that I completely forgot to check why we stopped getting more sand! There's a ferry leaving soon that is headed over in that direction - it's much faster than your boat. Could you please go check it out?"
|
||||
|
||||
You barely have time to agree to this request when he brings up another. "While you wait for the ferry, maybe you can help us with our *food production problem*. The latest Island Island [Almanac](https://en.wikipedia.org/wiki/Almanac) just arrived and we're having trouble making sense of it."
|
||||
|
||||
The almanac (your puzzle input) lists all of the seeds that need to be planted. It also lists what type of soil to use with each kind of seed, what type of fertilizer to use with each kind of soil, what type of water to use with each kind of fertilizer, and so on. Every type of seed, soil, fertilizer and so on is identified with a number, but numbers are reused by each category - that is, soil `123` and fertilizer `123` aren't necessarily related to each other.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
seeds: 79 14 55 13
|
||||
|
||||
seed-to-soil map:
|
||||
50 98 2
|
||||
52 50 48
|
||||
|
||||
soil-to-fertilizer map:
|
||||
0 15 37
|
||||
37 52 2
|
||||
39 0 15
|
||||
|
||||
fertilizer-to-water map:
|
||||
49 53 8
|
||||
0 11 42
|
||||
42 0 7
|
||||
57 7 4
|
||||
|
||||
water-to-light map:
|
||||
88 18 7
|
||||
18 25 70
|
||||
|
||||
light-to-temperature map:
|
||||
45 77 23
|
||||
81 45 19
|
||||
68 64 13
|
||||
|
||||
temperature-to-humidity map:
|
||||
0 69 1
|
||||
1 0 69
|
||||
|
||||
humidity-to-location map:
|
||||
60 56 37
|
||||
56 93 4
|
||||
|
||||
```
|
||||
|
||||
The almanac starts by listing which seeds need to be planted: seeds `79`, `14`, `55`, and `13`.
|
||||
|
||||
The rest of the almanac contains a list of *maps* which describe how to convert numbers from a *source category* into numbers in a *destination category*. That is, the section that starts with `seed-to-soil map:` describes how to convert a *seed number* (the source) to a *soil number* (the destination). This lets the gardener and his team know which soil to use with which seeds, which water to use with which fertilizer, and so on.
|
||||
|
||||
Rather than list every source number and its corresponding destination number one by one, the maps describe entire *ranges* of numbers that can be converted. Each line within a map contains three numbers: the *destination range start*, the *source range start*, and the *range length*.
|
||||
|
||||
Consider again the example `seed-to-soil map`:
|
||||
|
||||
```
|
||||
50 98 2
|
||||
52 50 48
|
||||
|
||||
```
|
||||
|
||||
The first line has a *destination range start* of `50`, a *source range start* of `98`, and a *range length* of `2`. This line means that the source range starts at `98` and contains two values: `98` and `99`. The destination range is the same length, but it starts at `50`, so its two values are `50` and `51`. With this information, you know that seed number `98` corresponds to soil number `50` and that seed number `99` corresponds to soil number `51`.
|
||||
|
||||
The second line means that the source range starts at `50` and contains `48` values: `50`, `51`, ..., `96`, `97`. This corresponds to a destination range starting at `52` and also containing `48` values: `52`, `53`, ..., `98`, `99`. So, seed number `53` corresponds to soil number `55`.
|
||||
|
||||
Any source numbers that *aren't mapped* correspond to the *same* destination number. So, seed number `10` corresponds to soil number `10`.
|
||||
|
||||
So, the entire list of seed numbers and their corresponding soil numbers looks like this:
|
||||
|
||||
```
|
||||
seed soil
|
||||
0 0
|
||||
1 1
|
||||
... ...
|
||||
48 48
|
||||
49 49
|
||||
50 52
|
||||
51 53
|
||||
... ...
|
||||
96 98
|
||||
97 99
|
||||
98 50
|
||||
99 51
|
||||
|
||||
```
|
||||
|
||||
With this map, you can look up the soil number required for each initial seed number:
|
||||
|
||||
* Seed number `79` corresponds to soil number `81`.
|
||||
* Seed number `14` corresponds to soil number `14`.
|
||||
* Seed number `55` corresponds to soil number `57`.
|
||||
* Seed number `13` corresponds to soil number `13`.
|
||||
|
||||
The gardener and his team want to get started as soon as possible, so they'd like to know the closest location that needs a seed. Using these maps, find *the lowest location number that corresponds to any of the initial seeds*. To do this, you'll need to convert each seed number through other categories until you can find its corresponding *location number*. In this example, the corresponding types are:
|
||||
|
||||
* Seed `79`, soil `81`, fertilizer `81`, water `81`, light `74`, temperature `78`, humidity `78`, *location `82`*.
|
||||
* Seed `14`, soil `14`, fertilizer `53`, water `49`, light `42`, temperature `42`, humidity `43`, *location `43`*.
|
||||
* Seed `55`, soil `57`, fertilizer `57`, water `53`, light `46`, temperature `82`, humidity `82`, *location `86`*.
|
||||
* Seed `13`, soil `13`, fertilizer `52`, water `41`, light `34`, temperature `34`, humidity `35`, *location `35`*.
|
||||
|
||||
So, the lowest location number in this example is `*35*`.
|
||||
|
||||
*What is the lowest location number that corresponds to any of the initial seed numbers?*
|
||||
|
||||
To begin, [get your puzzle input](5/input).
|
||||
|
||||
Answer:
|
||||
|
||||
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22If+You+Give+A+Seed+A+Fertilizer%22+%2D+Day+5+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F5&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.
|
@ -1,82 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
INPUT_FILE="$1"
|
||||
|
||||
get_seeds ()
|
||||
{
|
||||
echo -n "$(grep seeds "${INPUT_FILE}" | cut -d ' ' -f 2-)"
|
||||
}
|
||||
|
||||
gen_map ()
|
||||
{
|
||||
# Generates files for given index of map in input file.
|
||||
local paragraph map_name map_content
|
||||
paragraph=$(($1+1)) # number of paragraph in input file
|
||||
map_name=$(awk -v RS= "{if(NR == ${paragraph}) print}" "${INPUT_FILE}" | head -n 1 | cut -d ' ' -f 1)
|
||||
map_content=$(awk -v RS= "{if(NR == ${paragraph}) print}" "${INPUT_FILE}"| tail -n +2)
|
||||
echo "${map_content}" > "${map_name}.map"
|
||||
maps+=("${map_name}.map")
|
||||
}
|
||||
|
||||
map_seed ()
|
||||
{
|
||||
# Usage: map_seed MAP_FILE SEED_NUMBER
|
||||
# Prints the mapping of the seed number in the give map.
|
||||
local map seed dest_start source_start length diff
|
||||
map="$1"
|
||||
seed="$2"
|
||||
while read -r line; do
|
||||
dest_start=$(cut -d ' ' -f 1 <<< "${line}")
|
||||
source_start=$(cut -d ' ' -f 2 <<< "${line}")
|
||||
length=$(cut -d ' ' -f 3 <<< "${line}")
|
||||
if [[ ${seed} -ge ${source_start} && ${seed} -le $((source_start+length-1)) ]]; then
|
||||
diff=$((seed-source_start))
|
||||
echo -n $((dest_start+diff))
|
||||
return
|
||||
fi
|
||||
done < "${map}"
|
||||
echo -n "${seed}" # no mapping
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
IFS=" " read -r -a seeds <<< "$(get_seeds)"
|
||||
declare -a maps=()
|
||||
declare -a destinations=()
|
||||
local map_count destination lowest
|
||||
map_count=$(awk -v RS= 'END {print NR}' "${INPUT_FILE}")
|
||||
map_count=$((map_count-1)) # one of the paragraphs in the file is seeds
|
||||
for ((i=1; i<=map_count; i++)); do
|
||||
gen_map "${i}"
|
||||
done
|
||||
for seed in "${seeds[@]}"; do
|
||||
destination=''
|
||||
for map in "${maps[@]}"; do
|
||||
if [[ -z ${destination} ]]; then
|
||||
destination=$(map_seed "${map}" "${seed}")
|
||||
else
|
||||
destination=$(map_seed "${map}" "${destination}")
|
||||
fi
|
||||
done
|
||||
destinations+=("${destination}")
|
||||
done
|
||||
lowest="${destinations[0]}"
|
||||
for dest in "${destinations[@]}"; do
|
||||
if [[ ${dest} -lt ${lowest} ]]; then
|
||||
lowest="${dest}"
|
||||
fi
|
||||
done
|
||||
echo "${lowest}"
|
||||
rm -f ./*.map
|
||||
}
|
||||
|
||||
main
|
174
2023/5/2/input
174
2023/5/2/input
@ -1,174 +0,0 @@
|
||||
seeds: 194657215 187012821 1093203236 6077151 44187305 148722449 2959577030 152281079 3400626717 198691716 1333399202 287624830 2657325069 35258407 1913289352 410917164 1005856673 850939 839895010 162018909
|
||||
|
||||
seed-to-soil map:
|
||||
466206721 134904099 264145987
|
||||
3226739510 2500159633 122177414
|
||||
1107118949 4139510909 155456387
|
||||
2314679916 2622337047 59899451
|
||||
2642618541 1908002826 511067679
|
||||
0 399050086 167531444
|
||||
1262575336 2682236498 1052104580
|
||||
3448620320 1415756771 259155097
|
||||
302435543 566581530 163771178
|
||||
3348916924 4039807513 99703396
|
||||
3153686220 1674911868 73053290
|
||||
3788293662 1747965158 160037668
|
||||
3948331330 3734341078 305466435
|
||||
2374579367 1228806725 186950046
|
||||
2561529413 2419070505 81089128
|
||||
167531444 0 134904099
|
||||
3707775417 1148288480 80518245
|
||||
4253797765 1107118949 41169531
|
||||
|
||||
soil-to-fertilizer map:
|
||||
3913658055 3217667557 44136240
|
||||
3043638173 1755409772 387575354
|
||||
1214033686 3261803797 213545970
|
||||
3431213527 3475349767 482444528
|
||||
1994011339 2522356968 695310589
|
||||
2689321928 1214033686 354316245
|
||||
1427579656 2142985126 379371842
|
||||
1806951498 1568349931 187059841
|
||||
|
||||
fertilizer-to-water map:
|
||||
2553394045 2097964132 64191777
|
||||
3153687517 3499502814 665965431
|
||||
1104565830 789107360 151317021
|
||||
4084493704 2165934452 60088979
|
||||
981078109 1551802916 123487721
|
||||
2935219151 4165468245 66838136
|
||||
10669639 1277616562 132965227
|
||||
839228347 1410581789 141221127
|
||||
3942173186 2018304529 79659603
|
||||
393057134 444333135 344145590
|
||||
2617585822 2253442971 317633329
|
||||
4237573988 3156387517 57393308
|
||||
1341340213 99436946 344896189
|
||||
143634866 1746717555 204406814
|
||||
776848617 0 21473714
|
||||
386359019 1270918447 6698115
|
||||
4168968434 3430897260 68605554
|
||||
2497629182 3375132397 55764863
|
||||
3819652948 3213780825 9721342
|
||||
1686236402 940424381 47687418
|
||||
4021832789 4232306381 62660915
|
||||
4144582683 2162155909 3778543
|
||||
1733923820 1675290637 30520902
|
||||
737202724 21473714 39645893
|
||||
2018304529 2591683508 479324653
|
||||
798322331 1705811539 40906016
|
||||
0 1260248808 10669639
|
||||
980449474 788478725 628635
|
||||
3002057287 3223502167 151630230
|
||||
3829374290 2226023431 27419540
|
||||
348041680 61119607 38317339
|
||||
3856793830 3071008161 85379356
|
||||
1764444722 1073569161 186679647
|
||||
4148361226 2571076300 20607208
|
||||
1255882851 988111799 85457362
|
||||
|
||||
water-to-light map:
|
||||
3143216572 2396957585 46085818
|
||||
2930160319 3087666064 82806318
|
||||
3012966637 3275730008 11481558
|
||||
1791164654 628261856 251676187
|
||||
1156959152 1008045214 174725983
|
||||
3597974089 4238330323 56636973
|
||||
2659665097 3287211566 62612544
|
||||
489714994 0 304501033
|
||||
2323644539 2017991146 71374674
|
||||
2611713237 3480351863 47951860
|
||||
4135255968 3931716786 159711328
|
||||
1331685135 879938043 128107171
|
||||
2396957585 2748883399 70018348
|
||||
408833803 1297158141 80881191
|
||||
1469631779 1182771197 103330914
|
||||
4004728215 3349824110 58812180
|
||||
1012078485 2008335392 9655754
|
||||
3024448195 2932857654 118768377
|
||||
192304632 2089365820 87451432
|
||||
4063540395 3408636290 71715573
|
||||
3823753472 2665304126 83579273
|
||||
117236420 1933267180 75068212
|
||||
2218325460 1378039332 105319079
|
||||
2722277641 3170472382 32223106
|
||||
1459792306 618379493 9839473
|
||||
3225342423 3528303723 55360789
|
||||
901528396 304501033 110507199
|
||||
3654611062 2471800766 96107890
|
||||
1012035595 628218966 42890
|
||||
1118925110 1719748519 38034042
|
||||
3907332745 2567908656 97395470
|
||||
2466975933 3786979482 144737304
|
||||
794216027 1612436150 107312369
|
||||
2901402956 2443043403 28757363
|
||||
0 415008232 117236420
|
||||
3750718952 3202695488 73034520
|
||||
3189302390 3051626031 36040033
|
||||
3394659119 3583664512 203314970
|
||||
2754500747 4091428114 146902209
|
||||
2042840841 1757782561 175484619
|
||||
3280703212 2818901747 113955907
|
||||
1021734239 532244652 86134841
|
||||
279756064 1483358411 129077739
|
||||
1572962693 2176817252 218201961
|
||||
1107869080 1286102111 11056030
|
||||
|
||||
light-to-temperature map:
|
||||
1609050489 2309171782 372577802
|
||||
2023682469 2836643763 897111138
|
||||
834447570 143604042 411534753
|
||||
428779503 1217157762 28824561
|
||||
143604042 931982301 108906615
|
||||
252510657 1040888916 176268846
|
||||
3431278062 1484221851 471209429
|
||||
1981628291 3733754901 42054178
|
||||
4140073117 2681749584 154894179
|
||||
1484221851 4170138658 124828638
|
||||
3902487491 1955431280 237585626
|
||||
457604064 555138795 376843506
|
||||
3036948483 3775809079 394329579
|
||||
2920793607 2193016906 116154876
|
||||
|
||||
temperature-to-humidity map:
|
||||
1348484361 0 45849582
|
||||
1394333943 726347262 166590764
|
||||
1797084784 3346946555 119105515
|
||||
1163891565 1265639794 165909682
|
||||
2199751891 3274125222 72821333
|
||||
4012454029 2231107899 181228118
|
||||
1008425725 207338839 56688993
|
||||
2322219090 3174539335 24543729
|
||||
3987057737 3199083064 25396292
|
||||
1560924707 45849582 62712410
|
||||
3424140824 1837299459 190417072
|
||||
2272573224 3224479356 27702302
|
||||
2346762819 2412336017 518856401
|
||||
329181964 1432789749 172164254
|
||||
3783666369 2027716531 203391368
|
||||
753484930 471406467 254940795
|
||||
1916190299 2931192418 243346917
|
||||
501346218 892938026 44760077
|
||||
1329801247 1604954003 18683114
|
||||
2865619220 3567337219 558521604
|
||||
546106295 264027832 207378635
|
||||
2300275526 3252181658 21943564
|
||||
4193682147 3466052070 101285149
|
||||
327941691 1431549476 1240273
|
||||
0 937698103 327941691
|
||||
2159537216 1797084784 40214675
|
||||
3614557896 4125858823 169108473
|
||||
1065114718 108561992 98776847
|
||||
|
||||
humidity-to-location map:
|
||||
440744287 1133551978 536306564
|
||||
4042633851 4000620330 37465866
|
||||
977050851 1669858542 136276424
|
||||
2136551597 4038086196 256881100
|
||||
198620952 0 242123335
|
||||
1113327275 242123335 891428643
|
||||
4080099717 3802748040 197872290
|
||||
2695699324 2136551597 1346934527
|
||||
4277972007 3785752751 16995289
|
||||
2393432697 3483486124 302266627
|
||||
0 1806134966 198620952
|
@ -1,139 +0,0 @@
|
||||
\--- Day 5: If You Give A Seed A Fertilizer ---
|
||||
----------
|
||||
|
||||
You take the boat and find the gardener right where you were told he would be: managing a giant "garden" that looks more to you like a farm.
|
||||
|
||||
"A water source? Island Island *is* the water source!" You point out that Snow Island isn't receiving any water.
|
||||
|
||||
"Oh, we had to stop the water because we *ran out of sand* to [filter](https://en.wikipedia.org/wiki/Sand_filter) it with! Can't make snow with dirty water. Don't worry, I'm sure we'll get more sand soon; we only turned off the water a few days... weeks... oh no." His face sinks into a look of horrified realization.
|
||||
|
||||
"I've been so busy making sure everyone here has food that I completely forgot to check why we stopped getting more sand! There's a ferry leaving soon that is headed over in that direction - it's much faster than your boat. Could you please go check it out?"
|
||||
|
||||
You barely have time to agree to this request when he brings up another. "While you wait for the ferry, maybe you can help us with our *food production problem*. The latest Island Island [Almanac](https://en.wikipedia.org/wiki/Almanac) just arrived and we're having trouble making sense of it."
|
||||
|
||||
The almanac (your puzzle input) lists all of the seeds that need to be planted. It also lists what type of soil to use with each kind of seed, what type of fertilizer to use with each kind of soil, what type of water to use with each kind of fertilizer, and so on. Every type of seed, soil, fertilizer and so on is identified with a number, but numbers are reused by each category - that is, soil `123` and fertilizer `123` aren't necessarily related to each other.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
seeds: 79 14 55 13
|
||||
|
||||
seed-to-soil map:
|
||||
50 98 2
|
||||
52 50 48
|
||||
|
||||
soil-to-fertilizer map:
|
||||
0 15 37
|
||||
37 52 2
|
||||
39 0 15
|
||||
|
||||
fertilizer-to-water map:
|
||||
49 53 8
|
||||
0 11 42
|
||||
42 0 7
|
||||
57 7 4
|
||||
|
||||
water-to-light map:
|
||||
88 18 7
|
||||
18 25 70
|
||||
|
||||
light-to-temperature map:
|
||||
45 77 23
|
||||
81 45 19
|
||||
68 64 13
|
||||
|
||||
temperature-to-humidity map:
|
||||
0 69 1
|
||||
1 0 69
|
||||
|
||||
humidity-to-location map:
|
||||
60 56 37
|
||||
56 93 4
|
||||
|
||||
```
|
||||
|
||||
The almanac starts by listing which seeds need to be planted: seeds `79`, `14`, `55`, and `13`.
|
||||
|
||||
The rest of the almanac contains a list of *maps* which describe how to convert numbers from a *source category* into numbers in a *destination category*. That is, the section that starts with `seed-to-soil map:` describes how to convert a *seed number* (the source) to a *soil number* (the destination). This lets the gardener and his team know which soil to use with which seeds, which water to use with which fertilizer, and so on.
|
||||
|
||||
Rather than list every source number and its corresponding destination number one by one, the maps describe entire *ranges* of numbers that can be converted. Each line within a map contains three numbers: the *destination range start*, the *source range start*, and the *range length*.
|
||||
|
||||
Consider again the example `seed-to-soil map`:
|
||||
|
||||
```
|
||||
50 98 2
|
||||
52 50 48
|
||||
|
||||
```
|
||||
|
||||
The first line has a *destination range start* of `50`, a *source range start* of `98`, and a *range length* of `2`. This line means that the source range starts at `98` and contains two values: `98` and `99`. The destination range is the same length, but it starts at `50`, so its two values are `50` and `51`. With this information, you know that seed number `98` corresponds to soil number `50` and that seed number `99` corresponds to soil number `51`.
|
||||
|
||||
The second line means that the source range starts at `50` and contains `48` values: `50`, `51`, ..., `96`, `97`. This corresponds to a destination range starting at `52` and also containing `48` values: `52`, `53`, ..., `98`, `99`. So, seed number `53` corresponds to soil number `55`.
|
||||
|
||||
Any source numbers that *aren't mapped* correspond to the *same* destination number. So, seed number `10` corresponds to soil number `10`.
|
||||
|
||||
So, the entire list of seed numbers and their corresponding soil numbers looks like this:
|
||||
|
||||
```
|
||||
seed soil
|
||||
0 0
|
||||
1 1
|
||||
... ...
|
||||
48 48
|
||||
49 49
|
||||
50 52
|
||||
51 53
|
||||
... ...
|
||||
96 98
|
||||
97 99
|
||||
98 50
|
||||
99 51
|
||||
|
||||
```
|
||||
|
||||
With this map, you can look up the soil number required for each initial seed number:
|
||||
|
||||
* Seed number `79` corresponds to soil number `81`.
|
||||
* Seed number `14` corresponds to soil number `14`.
|
||||
* Seed number `55` corresponds to soil number `57`.
|
||||
* Seed number `13` corresponds to soil number `13`.
|
||||
|
||||
The gardener and his team want to get started as soon as possible, so they'd like to know the closest location that needs a seed. Using these maps, find *the lowest location number that corresponds to any of the initial seeds*. To do this, you'll need to convert each seed number through other categories until you can find its corresponding *location number*. In this example, the corresponding types are:
|
||||
|
||||
* Seed `79`, soil `81`, fertilizer `81`, water `81`, light `74`, temperature `78`, humidity `78`, *location `82`*.
|
||||
* Seed `14`, soil `14`, fertilizer `53`, water `49`, light `42`, temperature `42`, humidity `43`, *location `43`*.
|
||||
* Seed `55`, soil `57`, fertilizer `57`, water `53`, light `46`, temperature `82`, humidity `82`, *location `86`*.
|
||||
* Seed `13`, soil `13`, fertilizer `52`, water `41`, light `34`, temperature `34`, humidity `35`, *location `35`*.
|
||||
|
||||
So, the lowest location number in this example is `*35*`.
|
||||
|
||||
*What is the lowest location number that corresponds to any of the initial seed numbers?*
|
||||
|
||||
Your puzzle answer was `157211394`.
|
||||
|
||||
The first half of this puzzle is complete! It provides one gold star: \*
|
||||
|
||||
\--- Part Two ---
|
||||
----------
|
||||
|
||||
Everyone will starve if you only plant such a small number of seeds. Re-reading the almanac, it looks like the `seeds:` line actually describes *ranges of seed numbers*.
|
||||
|
||||
The values on the initial `seeds:` line come in pairs. Within each pair, the first value is the *start* of the range and the second value is the *length* of the range. So, in the first line of the example above:
|
||||
|
||||
```
|
||||
seeds: 79 14 55 13
|
||||
```
|
||||
|
||||
This line describes two ranges of seed numbers to be planted in the garden. The first range starts with seed number `79` and contains `14` values: `79`, `80`, ..., `91`, `92`. The second range starts with seed number `55` and contains `13` values: `55`, `56`, ..., `66`, `67`.
|
||||
|
||||
Now, rather than considering four seed numbers, you need to consider a total of *27* seed numbers.
|
||||
|
||||
In the above example, the lowest location number can be obtained from seed number `82`, which corresponds to soil `84`, fertilizer `84`, water `84`, light `77`, temperature `45`, humidity `46`, and *location `46`*. So, the lowest location number is `*46*`.
|
||||
|
||||
Consider all of the initial seed numbers listed in the ranges on the first line of the almanac. *What is the lowest location number that corresponds to any of the initial seed numbers?*
|
||||
|
||||
Answer:
|
||||
|
||||
Although it hasn't changed, you can still [get your puzzle input](5/input).
|
||||
|
||||
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=I%27ve+completed+Part+One+of+%22If+You+Give+A+Seed+A+Fertilizer%22+%2D+Day+5+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F5&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.
|
@ -1,97 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# INCOMPLETE
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
INPUT_FILE="$1"
|
||||
|
||||
gen_maps ()
|
||||
{
|
||||
local map_count paragraph_num lines name
|
||||
map_count=$(awk -v RS= 'END {print NR}' "${INPUT_FILE}")
|
||||
map_count=$((map_count-1)) # one paragraph in file is seeds
|
||||
for ((i=1; i<=map_count; i++)); do
|
||||
paragraph_num=$((i+1)) # number of paragraph in input file
|
||||
lines="$(awk -v RS= "{if(NR == ${paragraph_num}) print}" "${INPUT_FILE}"| tail -n +2)"
|
||||
name="$(awk -v RS= "{if(NR == ${paragraph_num}) print}" "${INPUT_FILE}" | head -n 1 | cut -d ' ' -f 1 | tr - _)"
|
||||
declare -n array="${name}"
|
||||
while read -r line; do
|
||||
array+=("${line}")
|
||||
done <<< "${lines}"
|
||||
maps+=("${name}")
|
||||
done
|
||||
}
|
||||
|
||||
gen_seed_pairs ()
|
||||
{
|
||||
local seed_count pair_count i_start i_length start length end
|
||||
IFS=" " read -r -a seeds <<< "$(grep seeds "${INPUT_FILE}" | cut -d ' ' -f 2-)"
|
||||
seed_count="${#seeds[@]}"
|
||||
pair_count=$((seed_count/2))
|
||||
for ((i=0; i<pair_count; i++)); do
|
||||
i_start=$((i*2))
|
||||
i_length=$((i*2+1))
|
||||
start=${seeds[${i_start}]}
|
||||
length=${seeds[${i_length}]}
|
||||
end=$((start+length-1))
|
||||
seed_pairs+=("${start},${end}")
|
||||
done
|
||||
}
|
||||
|
||||
get_lowest ()
|
||||
{
|
||||
local dest_start source_start length dest_end source_end
|
||||
for n in "${maps[@]}"; do
|
||||
declare -a new_pairs=()
|
||||
declare -n map="${n}"
|
||||
for line in "${map[@]}"; do
|
||||
dest_start="$(cut -d ' ' -f 1 <<< "${line}")"
|
||||
source_start="$(cut -d ' ' -f 2 <<< "${line}")"
|
||||
length="$(cut -d ' ' -f 3 <<< "${line}")"
|
||||
dest_end=$((dest_start+length-1))
|
||||
source_end=$((source_start+length-1))
|
||||
if [[ ${#new_pairs[@]} -eq 0 ]]; then
|
||||
declare -n source_pairs="seed_pairs"
|
||||
else
|
||||
declare -n source_pairs="new_pairs"
|
||||
fi
|
||||
for ((i=0; i<${#source_pairs[@]}; i++)); do
|
||||
interim_pairs+=(source)
|
||||
seed_start="$(cut -d ',' -f 1 <<< "${source_pairs[${i}]}")"
|
||||
seed_end="$(cut -d ',' -f 2 <<< "${source_pairs[${i}]}")"
|
||||
done
|
||||
done
|
||||
done
|
||||
declare -a new_pairs
|
||||
seed_pairs=("${new_pairs[@]}")
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
declare -a maps=()
|
||||
declare -a seed_pairs=() # start,end
|
||||
gen_maps
|
||||
gen_seed_pairs
|
||||
get_lowest
|
||||
|
||||
echo "${#seed_pairs[@]}"
|
||||
for i in "${seed_pairs[@]}"; do
|
||||
echo "$i"
|
||||
done
|
||||
|
||||
# for map in "${maps[@]}"; do
|
||||
# declare -n array="${map}"
|
||||
# echo "printing ${map} ${#array[@]}"
|
||||
# for ((i=0; i<${#array[@]}; i++)); do
|
||||
# echo "${array[${i}]}"
|
||||
# done
|
||||
# done
|
||||
}
|
||||
|
||||
main
|
@ -1,2 +0,0 @@
|
||||
Time: 53 83 72 88
|
||||
Distance: 333 1635 1289 1532
|
@ -1,55 +0,0 @@
|
||||
\--- Day 6: Wait For It ---
|
||||
----------
|
||||
|
||||
The ferry quickly brings you across Island Island. After asking around, you discover that there is indeed normally a large pile of sand somewhere near here, but you don't see anything besides lots of water and the small island where the ferry has docked.
|
||||
|
||||
As you try to figure out what to do next, you notice a poster on a wall near the ferry dock. "Boat races! Open to the public! Grand prize is an all-expenses-paid trip to *Desert Island*!" That must be where the sand comes from! Best of all, the boat races are starting in just a few minutes.
|
||||
|
||||
You manage to sign up as a competitor in the boat races just in time. The organizer explains that it's not really a traditional race - instead, you will get a fixed amount of time during which your boat has to travel as far as it can, and you win if your boat goes the farthest.
|
||||
|
||||
As part of signing up, you get a sheet of paper (your puzzle input) that lists the *time* allowed for each race and also the best *distance* ever recorded in that race. To guarantee you win the grand prize, you need to make sure you *go farther in each race* than the current record holder.
|
||||
|
||||
The organizer brings you over to the area where the boat races are held. The boats are much smaller than you expected - they're actually *toy boats*, each with a big button on top. Holding down the button *charges the boat*, and releasing the button *allows the boat to move*. Boats move faster if their button was held longer, but time spent holding the button counts against the total race time. You can only hold the button at the start of the race, and boats don't move until the button is released.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
Time: 7 15 30
|
||||
Distance: 9 40 200
|
||||
|
||||
```
|
||||
|
||||
This document describes three races:
|
||||
|
||||
* The first race lasts 7 milliseconds. The record distance in this race is 9 millimeters.
|
||||
* The second race lasts 15 milliseconds. The record distance in this race is 40 millimeters.
|
||||
* The third race lasts 30 milliseconds. The record distance in this race is 200 millimeters.
|
||||
|
||||
Your toy boat has a starting speed of *zero millimeters per millisecond*. For each whole millisecond you spend at the beginning of the race holding down the button, the boat's speed increases by *one millimeter per millisecond*.
|
||||
|
||||
So, because the first race lasts 7 milliseconds, you only have a few options:
|
||||
|
||||
* Don't hold the button at all (that is, hold it for *`0` milliseconds*) at the start of the race. The boat won't move; it will have traveled *`0` millimeters* by the end of the race.
|
||||
* Hold the button for *`1` millisecond* at the start of the race. Then, the boat will travel at a speed of `1` millimeter per millisecond for 6 milliseconds, reaching a total distance traveled of *`6` millimeters*.
|
||||
* Hold the button for *`2` milliseconds*, giving the boat a speed of `2` millimeters per millisecond. It will then get 5 milliseconds to move, reaching a total distance of *`10` millimeters*.
|
||||
* Hold the button for *`3` milliseconds*. After its remaining 4 milliseconds of travel time, the boat will have gone *`12` millimeters*.
|
||||
* Hold the button for *`4` milliseconds*. After its remaining 3 milliseconds of travel time, the boat will have gone *`12` millimeters*.
|
||||
* Hold the button for *`5` milliseconds*, causing the boat to travel a total of *`10` millimeters*.
|
||||
* Hold the button for *`6` milliseconds*, causing the boat to travel a total of *`6` millimeters*.
|
||||
* Hold the button for *`7` milliseconds*. That's the entire duration of the race. You never let go of the button. The boat can't move until you let go of the button. Please make sure you let go of the button so the boat gets to move. *`0` millimeters*.
|
||||
|
||||
Since the current record for this race is `9` millimeters, there are actually `*4*` different ways you could win: you could hold the button for `2`, `3`, `4`, or `5` milliseconds at the start of the race.
|
||||
|
||||
In the second race, you could hold the button for at least `4` milliseconds and at most `11` milliseconds and beat the record, a total of `*8*` different ways to win.
|
||||
|
||||
In the third race, you could hold the button for at least `11` milliseconds and no more than `19` milliseconds and still beat the record, a total of `*9*` ways you could win.
|
||||
|
||||
To see how much margin of error you have, determine the *number of ways you can beat the record* in each race; in this example, if you multiply these values together, you get `*288*` (`4` \* `8` \* `9`).
|
||||
|
||||
Determine the number of ways you could beat the record in each race. *What do you get if you multiply these numbers together?*
|
||||
|
||||
To begin, [get your puzzle input](6/input).
|
||||
|
||||
Answer:
|
||||
|
||||
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Wait+For+It%22+%2D+Day+6+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F6&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.
|
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
INPUT="$1"
|
||||
|
||||
main ()
|
||||
{
|
||||
IFS=' ' read -r -a times <<< "$(grep Time ${INPUT} | awk '{$1=""; print $0}')"
|
||||
IFS=' ' read -r -a distances <<< "$(grep Distance ${INPUT} | awk '{$1=""; print $0}')"
|
||||
declare -a winning_counts=()
|
||||
records="${#times[@]}"
|
||||
for ((i=0; i<records; i++)); do
|
||||
t_record="${times[${i}]}"
|
||||
d_record="${distances[${i}]}"
|
||||
for ((t=1; t<=t_record; t++)); do
|
||||
t_remaining=$((t_record-t))
|
||||
distance=$((t*t_remaining))
|
||||
if [[ ${distance} -gt ${d_record} ]]; then
|
||||
first_winning="${t}"
|
||||
last_winning=$((t_record-first_winning))
|
||||
winning=$((last_winning-first_winning+1))
|
||||
break
|
||||
fi
|
||||
done
|
||||
winning_counts+=("${winning}")
|
||||
done
|
||||
product=1
|
||||
for i in "${winning_counts[@]}"; do
|
||||
product=$((product*i))
|
||||
done
|
||||
echo "${product}"
|
||||
}
|
||||
|
||||
main
|
@ -1,2 +0,0 @@
|
||||
Time: 53 83 72 88
|
||||
Distance: 333 1635 1289 1532
|
@ -1,86 +0,0 @@
|
||||
\--- Day 6: Wait For It ---
|
||||
----------
|
||||
|
||||
The ferry quickly brings you across Island Island. After asking around, you discover that there is indeed normally a large pile of sand somewhere near here, but you don't see anything besides lots of water and the small island where the ferry has docked.
|
||||
|
||||
As you try to figure out what to do next, you notice a poster on a wall near the ferry dock. "Boat races! Open to the public! Grand prize is an all-expenses-paid trip to *Desert Island*!" That must be where the sand comes from! Best of all, the boat races are starting in just a few minutes.
|
||||
|
||||
You manage to sign up as a competitor in the boat races just in time. The organizer explains that it's not really a traditional race - instead, you will get a fixed amount of time during which your boat has to travel as far as it can, and you win if your boat goes the farthest.
|
||||
|
||||
As part of signing up, you get a sheet of paper (your puzzle input) that lists the *time* allowed for each race and also the best *distance* ever recorded in that race. To guarantee you win the grand prize, you need to make sure you *go farther in each race* than the current record holder.
|
||||
|
||||
The organizer brings you over to the area where the boat races are held. The boats are much smaller than you expected - they're actually *toy boats*, each with a big button on top. Holding down the button *charges the boat*, and releasing the button *allows the boat to move*. Boats move faster if their button was held longer, but time spent holding the button counts against the total race time. You can only hold the button at the start of the race, and boats don't move until the button is released.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
Time: 7 15 30
|
||||
Distance: 9 40 200
|
||||
|
||||
```
|
||||
|
||||
This document describes three races:
|
||||
|
||||
* The first race lasts 7 milliseconds. The record distance in this race is 9 millimeters.
|
||||
* The second race lasts 15 milliseconds. The record distance in this race is 40 millimeters.
|
||||
* The third race lasts 30 milliseconds. The record distance in this race is 200 millimeters.
|
||||
|
||||
Your toy boat has a starting speed of *zero millimeters per millisecond*. For each whole millisecond you spend at the beginning of the race holding down the button, the boat's speed increases by *one millimeter per millisecond*.
|
||||
|
||||
So, because the first race lasts 7 milliseconds, you only have a few options:
|
||||
|
||||
* Don't hold the button at all (that is, hold it for *`0` milliseconds*) at the start of the race. The boat won't move; it will have traveled *`0` millimeters* by the end of the race.
|
||||
* Hold the button for *`1` millisecond* at the start of the race. Then, the boat will travel at a speed of `1` millimeter per millisecond for 6 milliseconds, reaching a total distance traveled of *`6` millimeters*.
|
||||
* Hold the button for *`2` milliseconds*, giving the boat a speed of `2` millimeters per millisecond. It will then get 5 milliseconds to move, reaching a total distance of *`10` millimeters*.
|
||||
* Hold the button for *`3` milliseconds*. After its remaining 4 milliseconds of travel time, the boat will have gone *`12` millimeters*.
|
||||
* Hold the button for *`4` milliseconds*. After its remaining 3 milliseconds of travel time, the boat will have gone *`12` millimeters*.
|
||||
* Hold the button for *`5` milliseconds*, causing the boat to travel a total of *`10` millimeters*.
|
||||
* Hold the button for *`6` milliseconds*, causing the boat to travel a total of *`6` millimeters*.
|
||||
* Hold the button for *`7` milliseconds*. That's the entire duration of the race. You never let go of the button. The boat can't move until you let go of the button. Please make sure you let go of the button so the boat gets to move. *`0` millimeters*.
|
||||
|
||||
Since the current record for this race is `9` millimeters, there are actually `*4*` different ways you could win: you could hold the button for `2`, `3`, `4`, or `5` milliseconds at the start of the race.
|
||||
|
||||
In the second race, you could hold the button for at least `4` milliseconds and at most `11` milliseconds and beat the record, a total of `*8*` different ways to win.
|
||||
|
||||
In the third race, you could hold the button for at least `11` milliseconds and no more than `19` milliseconds and still beat the record, a total of `*9*` ways you could win.
|
||||
|
||||
To see how much margin of error you have, determine the *number of ways you can beat the record* in each race; in this example, if you multiply these values together, you get `*288*` (`4` \* `8` \* `9`).
|
||||
|
||||
Determine the number of ways you could beat the record in each race. *What do you get if you multiply these numbers together?*
|
||||
|
||||
Your puzzle answer was `140220`.
|
||||
|
||||
\--- Part Two ---
|
||||
----------
|
||||
|
||||
As the race is about to start, you realize the piece of paper with race times and record distances you got earlier actually just has very bad [kerning](https://en.wikipedia.org/wiki/Kerning). There's really *only one race* - ignore the spaces between the numbers on each line.
|
||||
|
||||
So, the example from before:
|
||||
|
||||
```
|
||||
Time: 7 15 30
|
||||
Distance: 9 40 200
|
||||
|
||||
```
|
||||
|
||||
...now instead means this:
|
||||
|
||||
```
|
||||
Time: 71530
|
||||
Distance: 940200
|
||||
|
||||
```
|
||||
|
||||
Now, you have to figure out how many ways there are to win this single race. In this example, the race lasts for *`71530` milliseconds* and the record distance you need to beat is *`940200` millimeters*. You could hold the button anywhere from `14` to `71516` milliseconds and beat the record, a total of `*71503*` ways!
|
||||
|
||||
*How many ways can you beat the record in this one much longer race?*
|
||||
|
||||
Your puzzle answer was `39570185`.
|
||||
|
||||
Both parts of this puzzle are complete! They provide two gold stars: \*\*
|
||||
|
||||
At this point, you should [return to your Advent calendar](/2023) and try another puzzle.
|
||||
|
||||
If you still want to see it, you can [get your puzzle input](6/input).
|
||||
|
||||
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=I%27ve+completed+%22Wait+For+It%22+%2D+Day+6+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F6&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.
|
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
INPUT="$1"
|
||||
|
||||
main ()
|
||||
{
|
||||
time_record=$(grep Time "${INPUT}" | cut -d : -f 2 | tr -d ' ')
|
||||
distance_record=$(grep Distance "${INPUT}" | cut -d : -f 2 | tr -d ' ')
|
||||
for ((t=1; t<time_record; t++)); do
|
||||
t_remaining=$((time_record-t))
|
||||
distance=$((t*t_remaining))
|
||||
if [[ ${distance} -gt ${distance_record} ]]; then
|
||||
first_winning="${t}"
|
||||
last_winning=$((time_record-first_winning))
|
||||
winning=$((last_winning-first_winning+1))
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo "${winning}"
|
||||
}
|
||||
|
||||
main
|
Reference in New Issue
Block a user