part1 (2053B)
1--- Day 3: No Matter How You Slice It --- 2 3The Elves managed to locate the chimney-squeeze prototype fabric for Santa's suit (thanks to someone 4who helpfully wrote its box IDs on the wall of the warehouse in the middle of the night). 5Unfortunately, anomalies are still affecting them - nobody can even agree on how to [1m[97mcut[0m the fabric. 6 7The whole piece of fabric they're working on is a very large square - at least 1000 inches on each 8side. 9 10Each Elf has made a [1m[97mclaim[0m about which area of fabric would be ideal for Santa's suit. All claims 11have an ID and consist of a single rectangle with edges parallel to the edges of the fabric. Each 12claim's rectangle is defined as follows: 13 14 15 - The number of inches between the left edge of the fabric and the left edge of the rectangle. 16 17 - The number of inches between the top edge of the fabric and the top edge of the rectangle. 18 19 - The width of the rectangle in inches. 20 21 - The height of the rectangle in inches. 22 23 24A claim like #123 @ 3,2: 5x4 means that claim ID 123 specifies a rectangle 3 inches from the left 25edge, 2 inches from the top edge, 5 inches wide, and 4 inches tall. Visually, it claims the square 26inches of fabric represented by # (and ignores the square inches of fabric represented by .) in the 27diagram below: 28 29........... 30........... 31...#####... 32...#####... 33...#####... 34...#####... 35........... 36........... 37........... 38 39The problem is that many of the claims [1m[97moverlap[0m, causing two or more claims to cover part of the same 40areas. For example, consider the following claims: 41 42#1 @ 1,3: 4x4 43#2 @ 3,1: 4x4 44#3 @ 5,5: 2x2 45 46Visually, these claim the following areas: 47 48........ 49...2222. 50...2222. 51.11XX22. 52.11XX22. 53.111133. 54.111133. 55........ 56 57The four square inches marked with X are claimed by [1m[97mboth 1 and 2[0m. (Claim 3, while adjacent to the 58others, does not overlap either of them.) 59 60If the Elves all proceed with their own plans, none of them will have enough fabric. [1m[97mHow many square 61inches of fabric are within two or more claims?[0m 62 63