aoc-2018-python

Advent of Code 2018 Solutions in Python
git clone https://git.sinitax.com/sinitax/aoc-2018-python
Log | Files | Refs | README | sfeed.txt

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 cut 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 claim 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 overlap, 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 both 1 and 2. (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. How many square
     61inches of fabric are within two or more claims?
     62
     63