Skip to content

Commit 37af808

Browse files
authored
Merge pull request #3 from romellem/day-3
Day 3
2 parents 1ea2449 + 9a26522 commit 37af808

File tree

5 files changed

+1408
-0
lines changed

5 files changed

+1408
-0
lines changed

3/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Answers
2+
3+
| Part 1 | Part 2 |
4+
|--------|--------|
5+
| 101196 | 243 |
6+
7+
## --- Day 3: No Matter How You Slice It ---
8+
9+
The Elves managed to locate the chimney-squeeze prototype fabric for Santa's suit (thanks to someone who helpfully wrote its box IDs on the wall of the warehouse in the middle of the night). Unfortunately, anomalies are still affecting them - nobody can even agree on how to _cut_ the fabric.
10+
11+
The whole piece of fabric they're working on is a very large square - at least `1000` inches on each side.
12+
13+
Each Elf has made a _claim_ about which area of fabric would be ideal for Santa's suit. All claims have an ID and consist of a single rectangle with edges parallel to the edges of the fabric. Each claim's rectangle is defined as follows:
14+
15+
* The number of inches between the left edge of the fabric and the left edge of the rectangle.
16+
* The number of inches between the top edge of the fabric and the top edge of the rectangle.
17+
* The width of the rectangle in inches.
18+
* The height of the rectangle in inches.
19+
20+
A claim like `#123 @ 3,2: 5x4` means that claim ID `123` specifies a rectangle `3` inches from the left edge, `2` inches from the top edge, `5` inches wide, and `4` inches tall. Visually, it claims the square inches of fabric represented by `#` (and ignores the square inches of fabric represented by `.`) in the diagram below:
21+
22+
...........
23+
...........
24+
...#####...
25+
...#####...
26+
...#####...
27+
...#####...
28+
...........
29+
...........
30+
...........
31+
32+
33+
The problem is that many of the claims _overlap_, causing two or more claims to cover part of the same areas. For example, consider the following claims:
34+
35+
#1 @ 1,3: 4x4
36+
#2 @ 3,1: 4x4
37+
#3 @ 5,5: 2x2
38+
39+
40+
Visually, these claim the following areas:
41+
42+
........
43+
...2222.
44+
...2222.
45+
.11XX22.
46+
.11XX22.
47+
.111133.
48+
.111133.
49+
........
50+
51+
52+
The four square inches marked with `X` are claimed by _both `1` and `2`_. (Claim `3`, while adjacent to the others, does not overlap either of them.)
53+
54+
If the Elves all proceed with their own plans, none of them will have enough fabric. _How many square inches of fabric are within two or more claims?_
55+
56+
-----------------
57+
58+
## --- Part Two ---
59+
60+
Amidst the chaos, you notice that exactly one claim doesn't overlap by even a single square inch of fabric with any other claim. If you can somehow draw attention to it, maybe the Elves will be able to make Santa's suit after all!
61+
62+
For example, in the claims above, only claim `3` is intact after all claims are made.
63+
64+
_What is the ID of the only claim that doesn't overlap?_

0 commit comments

Comments
 (0)