generated from public/aoc_template
problem 3
This commit is contained in:
parent
aed206e1e1
commit
ab587caee4
100
inputs/input3
Normal file
100
inputs/input3
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
767-985 184-500
|
||||||
|
133-257 182-404
|
||||||
|
394-791 372-386
|
||||||
|
719-791 824-828
|
||||||
|
409-945 792-865
|
||||||
|
92-988 500-507
|
||||||
|
437-710 467-641
|
||||||
|
122-181 177-551
|
||||||
|
594-740 637-735
|
||||||
|
838-965 953-998
|
||||||
|
124-237 254-773
|
||||||
|
66-921 466-540
|
||||||
|
878-990 868-870
|
||||||
|
159-709 221-886
|
||||||
|
492-870 531-603
|
||||||
|
639-646 646-799
|
||||||
|
280-488 430-683
|
||||||
|
424-739 512-955
|
||||||
|
713-795 804-960
|
||||||
|
117-653 157-547
|
||||||
|
614-721 680-722
|
||||||
|
781-968 630-968
|
||||||
|
861-927 312-328
|
||||||
|
772-934 615-688
|
||||||
|
498-864 582-920
|
||||||
|
106-121 112-922
|
||||||
|
208-362 290-680
|
||||||
|
485-648 542-677
|
||||||
|
183-984 466-471
|
||||||
|
965-987 964-987
|
||||||
|
557-628 628-856
|
||||||
|
377-721 435-584
|
||||||
|
409-797 19-95
|
||||||
|
513-821 361-765
|
||||||
|
95-557 610-674
|
||||||
|
54-693 281-608
|
||||||
|
829-910 434-881
|
||||||
|
778-963 885-939
|
||||||
|
395-452 577-987
|
||||||
|
175-373 258-764
|
||||||
|
777-821 642-838
|
||||||
|
338-847 255-261
|
||||||
|
75-199 949-969
|
||||||
|
419-734 453-834
|
||||||
|
340-493 586-849
|
||||||
|
274-555 871-967
|
||||||
|
613-618 842-989
|
||||||
|
777-817 812-823
|
||||||
|
270-294 637-800
|
||||||
|
827-940 364-638
|
||||||
|
32-69 688-848
|
||||||
|
85-226 162-678
|
||||||
|
579-885 657-730
|
||||||
|
161-246 238-819
|
||||||
|
269-437 400-736
|
||||||
|
176-615 355-655
|
||||||
|
452-923 481-571
|
||||||
|
649-965 175-431
|
||||||
|
368-748 994-999
|
||||||
|
179-883 467-623
|
||||||
|
286-856 768-833
|
||||||
|
106-1000 490-682
|
||||||
|
689-965 176-945
|
||||||
|
259-632 622-644
|
||||||
|
41-485 194-212
|
||||||
|
923-963 945-964
|
||||||
|
593-944 286-483
|
||||||
|
596-897 798-813
|
||||||
|
874-938 896-985
|
||||||
|
121-372 998-999
|
||||||
|
982-995 985-990
|
||||||
|
636-763 741-798
|
||||||
|
716-937 804-940
|
||||||
|
83-740 614-694
|
||||||
|
257-358 268-993
|
||||||
|
271-431 420-561
|
||||||
|
727-900 890-901
|
||||||
|
327-342 328-376
|
||||||
|
852-880 161-349
|
||||||
|
421-794 535-643
|
||||||
|
88-416 404-553
|
||||||
|
272-767 546-750
|
||||||
|
607-908 624-635
|
||||||
|
536-910 788-934
|
||||||
|
252-869 840-882
|
||||||
|
892-965 940-985
|
||||||
|
508-616 67-752
|
||||||
|
179-895 216-900
|
||||||
|
79-795 95-570
|
||||||
|
183-614 846-862
|
||||||
|
311-400 317-967
|
||||||
|
31-238 43-808
|
||||||
|
329-731 342-590
|
||||||
|
42-157 109-651
|
||||||
|
427-492 939-999
|
||||||
|
870-931 890-937
|
||||||
|
878-881 880-904
|
||||||
|
862-864 711-990
|
||||||
|
233-256 255-838
|
||||||
|
225-879 289-978
|
||||||
6
inputs/input3_test
Normal file
6
inputs/input3_test
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
8-9 9-10
|
||||||
|
7-8 8-10
|
||||||
|
9-10 5-10
|
||||||
|
3-10 9-10
|
||||||
|
4-8 7-9
|
||||||
|
9-10 2-7
|
||||||
32
problem3.py
Normal file
32
problem3.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
my_input = open("inputs/input3", "r").read().splitlines()
|
||||||
|
|
||||||
|
p1 = 0
|
||||||
|
p2 = 0
|
||||||
|
p3 = 0
|
||||||
|
last_boxes = set()
|
||||||
|
for line in my_input:
|
||||||
|
left, right = line.split(" ")
|
||||||
|
l_low, l_high = map(int, left.split("-"))
|
||||||
|
r_low, r_high = map(int, right.split("-"))
|
||||||
|
p1 += l_high - l_low + 1
|
||||||
|
p1 += r_high - r_low + 1
|
||||||
|
|
||||||
|
if r_low < l_low:
|
||||||
|
l_low, l_high, r_low, r_high = r_low, r_high, l_low, l_high
|
||||||
|
|
||||||
|
if l_high < r_low:
|
||||||
|
this_box_set = set(range(l_low, l_high + 1))
|
||||||
|
this_box_set |= set(range(r_low, r_high + 1))
|
||||||
|
else:
|
||||||
|
this_box_set = set(range(min(l_low, r_low), max(l_high, r_high) + 1))
|
||||||
|
|
||||||
|
p2 += len(this_box_set)
|
||||||
|
if len(this_box_set | last_boxes) > p3:
|
||||||
|
p3 = len(this_box_set | last_boxes)
|
||||||
|
|
||||||
|
last_boxes = this_box_set
|
||||||
|
|
||||||
|
print(p1)
|
||||||
|
print(p2)
|
||||||
|
print(p3)
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user