From af21ad12cc4061173778689b3fcc121f2c6137cb Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Wed, 14 Dec 2022 21:26:18 -0800 Subject: [PATCH] day 15 python part 1 --- day15/input | 23 +++++++++++++++++++++++ day15/sample | 14 ++++++++++++++ day15/sol.py | 24 ++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 day15/input create mode 100644 day15/sample create mode 100644 day15/sol.py diff --git a/day15/input b/day15/input new file mode 100644 index 0000000..f7e996c --- /dev/null +++ b/day15/input @@ -0,0 +1,23 @@ +Sensor at x=325337, y=2568863: closest beacon is at x=-518661, y=2000000 +Sensor at x=3988825, y=837820: closest beacon is at x=4305648, y=2127118 +Sensor at x=1611311, y=2053174: closest beacon is at x=2827226, y=1579510 +Sensor at x=101890, y=3940049: closest beacon is at x=955472, y=3457514 +Sensor at x=3962702, y=2558425: closest beacon is at x=4226981, y=2604726 +Sensor at x=2957890, y=2160813: closest beacon is at x=2827226, y=1579510 +Sensor at x=3907456, y=3325610: closest beacon is at x=3696221, y=3226373 +Sensor at x=3354177, y=3435919: closest beacon is at x=3696221, y=3226373 +Sensor at x=3997379, y=3071868: closest beacon is at x=3696221, y=3226373 +Sensor at x=145143, y=1714962: closest beacon is at x=-518661, y=2000000 +Sensor at x=611563, y=3148864: closest beacon is at x=955472, y=3457514 +Sensor at x=3080405, y=3904777: closest beacon is at x=3696221, y=3226373 +Sensor at x=644383, y=10732: closest beacon is at x=364635, y=-294577 +Sensor at x=3229566, y=1694167: closest beacon is at x=2827226, y=1579510 +Sensor at x=1600637, y=3984884: closest beacon is at x=955472, y=3457514 +Sensor at x=2959765, y=2820860: closest beacon is at x=2491502, y=2897876 +Sensor at x=2235330, y=3427797: closest beacon is at x=2491502, y=2897876 +Sensor at x=2428996, y=210881: closest beacon is at x=2827226, y=1579510 +Sensor at x=369661, y=687805: closest beacon is at x=364635, y=-294577 +Sensor at x=3558476, y=2123614: closest beacon is at x=4305648, y=2127118 +Sensor at x=3551529, y=2825104: closest beacon is at x=3696221, y=3226373 +Sensor at x=64895, y=3577: closest beacon is at x=364635, y=-294577 +Sensor at x=3079531, y=1538659: closest beacon is at x=2827226, y=1579510 diff --git a/day15/sample b/day15/sample new file mode 100644 index 0000000..a612424 --- /dev/null +++ b/day15/sample @@ -0,0 +1,14 @@ +Sensor at x=2, y=18: closest beacon is at x=-2, y=15 +Sensor at x=9, y=16: closest beacon is at x=10, y=16 +Sensor at x=13, y=2: closest beacon is at x=15, y=3 +Sensor at x=12, y=14: closest beacon is at x=10, y=16 +Sensor at x=10, y=20: closest beacon is at x=10, y=16 +Sensor at x=14, y=17: closest beacon is at x=10, y=16 +Sensor at x=8, y=7: closest beacon is at x=2, y=10 +Sensor at x=2, y=0: closest beacon is at x=2, y=10 +Sensor at x=0, y=11: closest beacon is at x=2, y=10 +Sensor at x=20, y=14: closest beacon is at x=25, y=17 +Sensor at x=17, y=20: closest beacon is at x=21, y=22 +Sensor at x=16, y=7: closest beacon is at x=15, y=3 +Sensor at x=14, y=3: closest beacon is at x=15, y=3 +Sensor at x=20, y=1: closest beacon is at x=15, y=3 diff --git a/day15/sol.py b/day15/sol.py new file mode 100644 index 0000000..d07f30b --- /dev/null +++ b/day15/sol.py @@ -0,0 +1,24 @@ +data = [] +for line in open("input"): + words = line.replace(":", "").replace(",","").split() + coords = [int(w[w.index('=')+1:]) for w in words if '=' in w] + data.append(coords) +#print(data) + +none = set() + +Y = 10 +Y = 2000000 + +for sx,sy,bx,by in data: + dx = abs(sx-bx) + dy = abs(sy-by) + dist = dx+dy + y = Y-sy + for x in range(-dist,dist+1): + if abs(x)+abs(y) <= dist: + p = (sx+x, sy+y) + if p != (bx,by): + none.add(sx+x) + +print(len(none))