-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-1-instructions.txt
69 lines (42 loc) · 1.74 KB
/
3-1-instructions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--- Day 3: No Matter How You Slice It ---
**How many square inches of fabric are within two or more claims?** (the puzzle answer)
Nobody can even agree on how to cut the fabric.
The whole piece of fabric they're working on is a very large square - at least 1000 inches on each side.
Each Elf has made a claim about an area of the fabric.
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:
The distance (inches) between the left edge of the fabric and the left edge of the rectangle.
The distance (inches) between the top edge of the fabric and the top edge of the rectangle.
The width of the rectangle (inches).
The height of the rectangle (inches).
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 (so origin of rectangle is 3,2)
, 5 inches wide (x = 5),
and 4 inches tall (y = 4).
Visually, it claims the square inches of fabric represented by # (and ignores the square inches of fabric represented by .) in the diagram below:
...........
...........
...#####...
...#####...
...#####...
...#####...
...........
...........
...........
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:
#1 @ 1,3: 4x4
#2 @ 3,1: 4x4
#3 @ 5,5: 2x2
Visually, these claim the following areas:
........
...2222.
...2222.
.11XX22.
.11XX22.
.111133.
.111133.
........
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.)
If the Elves all proceed with their own plans, none of them will have enough fabric.