Mercurial > hg > aoc
comparison 2017/day24/problem @ 34:049fb8e56025
Add problem statements and inputs
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 09 Jan 2018 21:51:44 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
33:bc652fa0a645 | 34:049fb8e56025 |
---|---|
1 --- Day 24: Electromagnetic Moat --- | |
2 | |
3 The CPU itself is a large, black building surrounded by a bottomless | |
4 pit. Enormous metal tubes extend outward from the side of the building | |
5 at regular intervals and descend down into the void. There's no way to | |
6 cross, but you need to get inside. | |
7 | |
8 No way, of course, other than building a bridge out of the magnetic | |
9 components strewn about nearby. | |
10 | |
11 Each component has two ports, one on each end. The ports come in all | |
12 different types, and only matching types can be connected. You take an | |
13 inventory of the components by their port types (your puzzle input). | |
14 Each port is identified by the number of pins it uses; more pins mean | |
15 a stronger connection for your bridge. A 3/7 component, for example, | |
16 has a type-3 port on one side, and a type-7 port on the other. | |
17 | |
18 Your side of the pit is metallic; a perfect surface to connect a | |
19 magnetic, zero-pin port. Because of this, the first port you use must | |
20 be of type 0. It doesn't matter what type of port you end with; your | |
21 goal is just to make the bridge as strong as possible. | |
22 | |
23 The strength of a bridge is the sum of the port types in each | |
24 component. For example, if your bridge is made of components 0/3, 3/7, | |
25 and 7/4, your bridge has a strength of 0+3 + 3+7 + 7+4 = 24. | |
26 | |
27 For example, suppose you had the following components: | |
28 | |
29 0/2 | |
30 2/2 | |
31 2/3 | |
32 3/4 | |
33 3/5 | |
34 0/1 | |
35 10/1 | |
36 9/10 | |
37 | |
38 With them, you could make the following valid bridges: | |
39 | |
40 0/1 | |
41 0/1--10/1 | |
42 0/1--10/1--9/10 | |
43 0/2 | |
44 0/2--2/3 | |
45 0/2--2/3--3/4 | |
46 0/2--2/3--3/5 | |
47 0/2--2/2 | |
48 0/2--2/2--2/3 | |
49 0/2--2/2--2/3--3/4 | |
50 0/2--2/2--2/3--3/5 | |
51 | |
52 (Note how, as shown by 10/1, order of ports within a component doesn't | |
53 matter. However, you may only use each port on a component once.) | |
54 | |
55 Of these bridges, the strongest one is 0/1--10/1--9/10; it has a | |
56 strength of 0+1 + 1+10 + 10+9 = 31. | |
57 | |
58 What is the strength of the strongest bridge you can make with the | |
59 components you have available? | |
60 | |
61 Your puzzle answer was 1695. | |
62 | |
63 --- Part Two --- | |
64 | |
65 The bridge you've built isn't long enough; you can't jump the rest of | |
66 the way. | |
67 | |
68 In the example above, there are two longest bridges: | |
69 | |
70 0/2--2/2--2/3--3/4 | |
71 0/2--2/2--2/3--3/5 | |
72 | |
73 Of them, the one which uses the 3/5 component is stronger; its | |
74 strength is 0+2 + 2+2 + 2+3 + 3+5 = 19. | |
75 | |
76 What is the strength of the longest bridge you can make? If you can | |
77 make multiple bridges of the longest length, pick the strongest one. | |
78 | |
79 Your puzzle answer was 1673. | |
80 | |
81 Both parts of this puzzle are complete! They provide two gold stars: ** |