Horribly inefficient day 5 solution

This commit is contained in:
Riley Apeldoorn 2021-12-05 12:57:25 +01:00
parent ff171b3e02
commit b3834afba9
4 changed files with 1085 additions and 0 deletions

500
5/calli.txt Normal file
View file

@ -0,0 +1,500 @@
911,808 -> 324,221
161,890 -> 808,243
174,59 -> 174,760
983,983 -> 10,10
321,12 -> 870,12
66,936 -> 941,61
670,141 -> 670,550
783,935 -> 496,648
973,651 -> 635,989
535,47 -> 535,154
355,183 -> 754,582
172,111 -> 892,111
353,66 -> 907,620
741,960 -> 741,805
113,895 -> 946,895
777,280 -> 563,280
679,815 -> 626,815
651,848 -> 651,673
205,834 -> 205,599
895,118 -> 82,931
685,303 -> 93,895
973,38 -> 62,949
867,23 -> 867,300
784,947 -> 784,47
96,168 -> 755,827
909,321 -> 909,716
59,881 -> 692,881
964,19 -> 69,914
752,869 -> 67,184
974,877 -> 138,41
432,389 -> 137,684
458,822 -> 458,402
818,852 -> 308,342
882,484 -> 441,925
82,959 -> 976,65
117,487 -> 117,429
214,673 -> 429,673
72,955 -> 72,829
587,109 -> 587,368
576,17 -> 576,872
685,102 -> 685,905
563,394 -> 716,394
966,145 -> 150,961
555,582 -> 555,385
453,31 -> 453,207
639,815 -> 547,723
431,869 -> 431,811
646,938 -> 599,938
215,513 -> 900,513
809,82 -> 798,82
768,344 -> 244,868
39,962 -> 39,601
675,186 -> 61,186
861,967 -> 28,967
860,550 -> 538,550
283,740 -> 571,740
72,297 -> 72,645
727,801 -> 727,526
799,519 -> 799,497
915,24 -> 174,765
795,943 -> 136,943
518,971 -> 599,971
594,676 -> 594,461
850,799 -> 363,799
958,575 -> 958,231
752,576 -> 398,576
891,433 -> 398,433
524,126 -> 397,126
10,890 -> 796,104
57,228 -> 168,228
168,521 -> 338,691
230,83 -> 777,83
865,677 -> 640,452
866,821 -> 825,821
17,143 -> 17,596
113,916 -> 113,601
268,187 -> 551,470
794,167 -> 220,167
459,17 -> 459,931
211,31 -> 526,31
680,57 -> 756,57
926,190 -> 926,800
85,284 -> 63,284
44,988 -> 44,701
110,941 -> 176,941
480,163 -> 480,112
574,538 -> 574,371
584,473 -> 69,473
303,621 -> 303,380
762,652 -> 762,89
286,195 -> 276,185
957,87 -> 217,827
561,858 -> 561,437
384,55 -> 81,55
19,977 -> 981,15
454,747 -> 938,263
425,836 -> 425,617
860,135 -> 775,50
633,131 -> 633,651
904,912 -> 242,250
880,177 -> 480,577
470,162 -> 964,656
585,376 -> 585,470
696,760 -> 594,862
534,225 -> 534,717
258,816 -> 258,847
990,244 -> 990,93
463,462 -> 463,533
434,928 -> 537,825
813,734 -> 533,734
498,673 -> 395,673
564,312 -> 55,312
280,550 -> 939,550
591,247 -> 396,52
127,516 -> 127,235
850,425 -> 552,127
894,428 -> 894,598
366,960 -> 592,960
579,488 -> 170,488
775,92 -> 775,586
49,909 -> 930,28
856,113 -> 284,685
263,175 -> 120,175
332,592 -> 276,592
920,157 -> 141,157
349,776 -> 316,776
187,863 -> 279,863
218,872 -> 83,872
465,430 -> 410,430
710,218 -> 857,218
797,314 -> 184,314
387,327 -> 49,665
950,812 -> 205,67
803,133 -> 803,682
125,972 -> 545,552
353,901 -> 840,414
936,843 -> 202,109
11,904 -> 856,59
725,757 -> 954,986
227,697 -> 345,697
187,520 -> 187,441
860,262 -> 135,987
700,95 -> 976,371
86,946 -> 869,163
898,806 -> 461,806
717,796 -> 717,195
882,127 -> 835,127
133,48 -> 133,191
521,51 -> 521,927
384,806 -> 957,233
570,139 -> 570,842
949,819 -> 949,350
592,230 -> 283,230
315,856 -> 741,856
870,674 -> 549,353
857,306 -> 857,889
428,217 -> 267,217
47,93 -> 898,944
636,238 -> 665,238
202,910 -> 202,737
246,432 -> 617,803
985,24 -> 48,961
965,876 -> 956,867
618,650 -> 810,458
292,356 -> 575,356
394,585 -> 910,585
137,453 -> 137,178
509,737 -> 509,665
193,350 -> 531,688
805,219 -> 107,219
975,506 -> 907,506
435,303 -> 435,380
344,83 -> 344,224
47,66 -> 47,115
570,516 -> 857,516
162,91 -> 926,91
759,417 -> 759,460
445,942 -> 445,699
421,340 -> 421,743
590,590 -> 434,434
453,38 -> 453,327
865,134 -> 865,773
842,609 -> 18,609
662,282 -> 62,882
489,32 -> 344,32
135,496 -> 93,454
552,211 -> 421,211
620,678 -> 642,678
782,158 -> 585,355
733,509 -> 733,574
932,383 -> 369,946
843,705 -> 843,725
747,414 -> 676,343
294,218 -> 962,886
844,175 -> 844,420
255,489 -> 531,213
555,532 -> 821,532
533,15 -> 533,161
631,778 -> 631,401
75,282 -> 468,282
903,838 -> 903,957
46,293 -> 543,790
30,834 -> 30,948
591,720 -> 591,965
624,36 -> 339,36
425,323 -> 425,442
234,939 -> 234,963
482,912 -> 968,912
228,614 -> 189,614
969,472 -> 969,692
871,494 -> 871,172
101,624 -> 848,624
424,918 -> 69,563
929,671 -> 93,671
81,187 -> 707,813
348,923 -> 348,924
921,524 -> 921,828
678,454 -> 678,364
904,227 -> 904,596
163,344 -> 609,790
206,180 -> 206,59
145,519 -> 145,717
317,679 -> 317,417
503,724 -> 221,724
353,448 -> 413,448
363,643 -> 837,643
594,54 -> 359,54
866,117 -> 45,938
939,210 -> 284,865
410,556 -> 410,801
905,111 -> 673,111
983,167 -> 574,167
595,758 -> 97,758
785,10 -> 437,10
517,414 -> 517,734
691,567 -> 186,62
842,51 -> 31,862
36,199 -> 282,199
864,758 -> 864,610
639,918 -> 951,918
245,516 -> 245,474
951,203 -> 557,203
176,728 -> 176,171
322,217 -> 387,217
149,208 -> 836,895
661,298 -> 609,298
46,47 -> 981,982
769,45 -> 769,610
988,932 -> 988,459
901,97 -> 901,908
195,395 -> 121,395
197,403 -> 327,533
159,456 -> 857,456
480,981 -> 881,580
86,958 -> 962,82
375,198 -> 763,198
950,381 -> 341,381
504,679 -> 504,598
756,659 -> 680,583
146,328 -> 886,328
930,412 -> 492,850
954,54 -> 954,940
790,498 -> 790,305
83,270 -> 83,242
939,268 -> 939,563
423,756 -> 916,263
583,756 -> 583,34
957,639 -> 614,639
484,523 -> 521,560
497,809 -> 497,419
76,17 -> 979,920
49,39 -> 943,933
110,289 -> 110,247
874,868 -> 874,172
576,127 -> 53,650
871,879 -> 12,20
436,711 -> 592,711
132,285 -> 225,285
245,147 -> 514,147
158,882 -> 956,84
21,984 -> 937,68
42,275 -> 219,275
877,143 -> 889,143
593,841 -> 508,756
414,289 -> 132,289
687,655 -> 767,655
453,981 -> 459,987
635,433 -> 635,324
671,347 -> 170,848
412,579 -> 915,579
269,677 -> 269,596
587,121 -> 367,341
153,883 -> 153,709
524,580 -> 508,580
541,232 -> 651,232
93,948 -> 284,757
168,745 -> 872,41
831,657 -> 925,563
908,389 -> 442,389
462,445 -> 234,445
735,493 -> 895,493
274,624 -> 296,646
153,130 -> 153,160
466,214 -> 466,769
474,499 -> 686,711
540,428 -> 788,676
858,215 -> 959,215
788,91 -> 788,410
552,505 -> 988,505
978,312 -> 978,202
108,321 -> 616,829
903,359 -> 903,770
480,331 -> 480,769
503,842 -> 34,842
613,732 -> 323,442
767,949 -> 654,949
514,589 -> 386,589
38,554 -> 284,308
689,268 -> 689,711
860,66 -> 190,736
253,865 -> 622,865
87,658 -> 698,47
506,892 -> 829,569
680,910 -> 594,824
824,603 -> 958,603
576,802 -> 562,802
67,27 -> 67,489
969,461 -> 517,913
674,763 -> 674,226
223,955 -> 218,955
147,540 -> 569,962
455,703 -> 596,703
746,899 -> 746,403
516,476 -> 756,476
897,674 -> 373,150
120,395 -> 120,49
722,443 -> 722,244
724,924 -> 724,39
809,930 -> 109,930
822,816 -> 874,816
796,539 -> 895,539
340,88 -> 560,88
223,158 -> 593,158
779,977 -> 856,900
617,461 -> 973,817
515,62 -> 515,140
12,586 -> 724,586
870,50 -> 391,50
308,123 -> 308,696
119,164 -> 863,908
755,599 -> 448,599
129,526 -> 633,526
478,668 -> 102,668
237,637 -> 237,743
270,102 -> 72,300
115,470 -> 115,427
948,233 -> 948,731
983,135 -> 468,650
748,439 -> 748,642
62,862 -> 352,572
765,901 -> 660,901
917,807 -> 917,587
55,81 -> 116,81
954,972 -> 102,120
340,503 -> 294,549
970,661 -> 522,213
618,92 -> 618,247
688,965 -> 965,965
94,241 -> 94,292
15,132 -> 15,492
979,927 -> 488,927
509,26 -> 984,26
840,530 -> 840,95
55,956 -> 849,162
297,297 -> 297,472
338,780 -> 369,780
487,292 -> 37,292
122,117 -> 206,201
66,807 -> 564,309
643,242 -> 906,242
909,833 -> 909,441
129,128 -> 818,817
406,42 -> 406,297
53,20 -> 967,934
235,285 -> 601,285
275,625 -> 275,539
199,732 -> 430,963
639,187 -> 639,265
549,740 -> 549,824
603,140 -> 603,748
35,455 -> 176,455
888,611 -> 888,271
134,154 -> 484,154
694,820 -> 694,814
535,584 -> 187,932
642,510 -> 642,249
191,886 -> 268,886
918,353 -> 881,390
977,13 -> 343,13
380,243 -> 271,134
410,758 -> 410,670
613,551 -> 519,645
963,84 -> 124,923
702,252 -> 821,252
405,237 -> 405,22
21,139 -> 21,510
548,499 -> 132,499
196,104 -> 196,680
739,145 -> 476,145
751,746 -> 91,746
975,628 -> 975,847
935,520 -> 935,450
803,372 -> 803,393
872,77 -> 872,373
339,130 -> 339,103
226,886 -> 226,45
794,647 -> 794,257
90,922 -> 889,123
615,971 -> 615,574
26,278 -> 26,719
838,88 -> 806,88
263,691 -> 804,150
309,721 -> 910,721
510,496 -> 960,946
195,236 -> 46,236
610,143 -> 610,610
891,412 -> 891,268
714,21 -> 156,579
320,935 -> 320,96
240,782 -> 449,782
754,472 -> 48,472
105,481 -> 529,57
451,301 -> 451,965
796,638 -> 796,185
908,553 -> 771,553
98,543 -> 490,935
481,159 -> 762,159
593,527 -> 419,353
86,391 -> 216,521
260,716 -> 42,716
734,538 -> 375,179
24,974 -> 975,23
402,466 -> 787,851
344,409 -> 262,327
803,443 -> 685,443
986,152 -> 249,152
125,738 -> 90,773
184,772 -> 184,746
729,829 -> 729,340
226,527 -> 226,375
936,231 -> 222,945
254,333 -> 254,167
451,234 -> 451,273
915,790 -> 568,443
869,794 -> 504,429
11,878 -> 836,53
821,231 -> 522,530
285,419 -> 732,866
191,272 -> 191,679
41,651 -> 225,651
30,13 -> 879,862
980,488 -> 20,488
27,187 -> 27,348
53,238 -> 53,514
778,306 -> 379,705
425,399 -> 425,60
162,859 -> 57,859
652,926 -> 652,589
962,489 -> 555,896
197,378 -> 436,617
310,190 -> 310,760
678,20 -> 678,713
390,653 -> 985,58
938,351 -> 656,69
881,39 -> 18,902
313,681 -> 323,681
910,907 -> 288,907
739,977 -> 739,132
856,479 -> 154,479
893,785 -> 761,785
405,247 -> 405,901
58,933 -> 808,183
643,156 -> 676,189
149,773 -> 357,773
479,518 -> 434,518
389,518 -> 556,685
858,449 -> 533,774
503,133 -> 409,133
340,315 -> 219,194
183,701 -> 183,242
810,151 -> 195,151
446,686 -> 446,912
968,482 -> 49,482
203,20 -> 203,667
493,516 -> 647,516
900,91 -> 634,91
660,554 -> 119,13
964,864 -> 964,919
871,293 -> 344,293
895,258 -> 972,258

10
5/example.txt Normal file
View file

@ -0,0 +1,10 @@
0,9 -> 5,9
8,0 -> 0,8
9,4 -> 3,4
2,2 -> 2,1
7,0 -> 7,4
6,4 -> 2,0
0,9 -> 2,9
3,4 -> 1,4
0,0 -> 8,8
5,5 -> 8,2

500
5/riley.txt Normal file
View file

@ -0,0 +1,500 @@
405,945 -> 780,945
253,100 -> 954,801
518,300 -> 870,300
775,848 -> 20,848
586,671 -> 469,671
598,20 -> 900,20
51,975 -> 438,588
561,456 -> 67,456
353,135 -> 882,664
357,873 -> 407,873
480,247 -> 774,247
230,895 -> 230,709
590,738 -> 644,792
696,821 -> 696,198
501,461 -> 85,461
884,88 -> 884,922
140,780 -> 146,780
795,208 -> 273,208
256,185 -> 256,525
282,196 -> 282,85
701,133 -> 18,133
623,548 -> 623,573
734,895 -> 29,190
212,944 -> 934,944
948,504 -> 948,502
551,613 -> 551,27
62,54 -> 452,54
915,851 -> 915,290
924,843 -> 924,145
662,412 -> 422,172
465,87 -> 247,87
391,91 -> 326,91
267,572 -> 267,306
84,505 -> 594,505
453,383 -> 80,10
737,891 -> 784,891
599,339 -> 40,898
868,962 -> 31,125
153,661 -> 705,661
760,74 -> 339,495
972,72 -> 972,714
579,636 -> 169,226
365,218 -> 118,465
128,906 -> 767,267
733,165 -> 121,165
877,99 -> 105,871
176,917 -> 754,917
14,14 -> 981,981
170,958 -> 170,859
861,25 -> 96,790
128,143 -> 128,49
874,367 -> 334,367
373,434 -> 373,747
799,946 -> 439,586
17,923 -> 814,126
734,192 -> 734,632
267,280 -> 877,890
457,500 -> 457,26
525,679 -> 525,22
985,64 -> 85,964
312,411 -> 312,287
554,860 -> 600,860
209,163 -> 628,163
47,30 -> 917,900
870,948 -> 625,703
965,980 -> 53,68
874,631 -> 874,41
770,29 -> 770,882
950,988 -> 411,449
766,900 -> 904,900
77,23 -> 923,869
528,151 -> 528,96
785,468 -> 218,468
150,932 -> 333,932
908,846 -> 654,846
467,220 -> 588,220
303,437 -> 219,437
617,71 -> 899,353
116,311 -> 116,816
251,165 -> 316,165
126,897 -> 854,169
254,473 -> 818,473
817,265 -> 98,984
660,492 -> 558,492
562,117 -> 64,615
857,808 -> 857,311
39,641 -> 39,703
256,981 -> 988,249
923,175 -> 923,902
372,800 -> 503,800
48,339 -> 48,156
852,476 -> 852,397
874,190 -> 248,816
509,629 -> 503,629
246,17 -> 246,341
903,961 -> 568,626
405,740 -> 975,740
25,10 -> 982,967
761,287 -> 254,794
21,514 -> 21,111
772,350 -> 219,903
61,56 -> 275,270
608,197 -> 608,719
275,30 -> 275,145
712,601 -> 850,739
173,205 -> 173,667
93,644 -> 519,218
60,48 -> 911,899
21,975 -> 980,16
333,602 -> 634,602
899,374 -> 96,374
283,209 -> 963,889
22,20 -> 987,985
494,66 -> 70,490
836,876 -> 37,77
151,530 -> 472,851
459,531 -> 127,199
564,489 -> 315,240
193,341 -> 361,341
639,680 -> 511,680
855,217 -> 855,352
88,909 -> 920,77
948,318 -> 452,814
957,967 -> 957,297
741,172 -> 140,773
785,528 -> 467,528
135,658 -> 458,658
821,653 -> 821,633
932,137 -> 415,137
858,638 -> 858,696
494,495 -> 649,495
586,261 -> 478,369
18,680 -> 571,680
872,233 -> 872,823
715,935 -> 861,935
85,251 -> 206,372
42,972 -> 940,74
587,955 -> 66,955
393,466 -> 771,466
759,744 -> 36,21
694,90 -> 195,589
210,456 -> 857,456
656,476 -> 177,955
391,224 -> 902,735
929,802 -> 69,802
548,395 -> 892,395
576,838 -> 671,838
402,412 -> 899,412
567,601 -> 800,834
106,386 -> 907,386
848,349 -> 848,869
209,392 -> 785,392
28,105 -> 853,930
395,432 -> 795,432
582,570 -> 582,514
48,410 -> 211,573
248,617 -> 248,848
695,174 -> 941,420
215,651 -> 215,124
419,555 -> 112,555
358,975 -> 169,975
732,247 -> 732,573
132,983 -> 132,845
476,110 -> 476,196
852,437 -> 640,437
973,42 -> 109,906
954,797 -> 337,180
544,233 -> 134,233
412,150 -> 93,150
140,296 -> 140,407
485,875 -> 395,875
600,942 -> 931,942
235,677 -> 235,431
841,745 -> 148,52
265,803 -> 265,140
369,597 -> 230,736
788,745 -> 788,422
29,677 -> 75,677
590,669 -> 590,638
24,23 -> 24,438
279,476 -> 770,967
342,186 -> 57,186
50,49 -> 350,349
968,40 -> 28,980
101,101 -> 978,101
897,48 -> 27,918
595,232 -> 595,211
813,982 -> 335,504
624,41 -> 261,41
743,102 -> 530,102
234,814 -> 234,527
597,242 -> 492,242
36,84 -> 339,84
685,729 -> 398,729
506,733 -> 506,150
140,788 -> 816,112
775,816 -> 316,357
934,394 -> 301,394
635,983 -> 750,983
128,29 -> 128,712
347,348 -> 724,725
836,367 -> 390,367
60,718 -> 620,718
476,786 -> 476,870
318,490 -> 192,490
736,608 -> 736,926
14,79 -> 14,777
913,245 -> 344,814
876,775 -> 72,775
109,273 -> 109,416
376,64 -> 376,592
988,11 -> 22,977
544,602 -> 453,602
703,585 -> 703,602
147,976 -> 147,512
887,681 -> 657,451
36,913 -> 36,321
184,723 -> 252,655
523,905 -> 523,610
626,106 -> 653,106
703,211 -> 703,376
770,175 -> 770,765
387,628 -> 233,628
69,890 -> 877,82
608,751 -> 699,751
379,958 -> 572,958
556,555 -> 276,835
890,681 -> 234,25
937,792 -> 589,444
842,296 -> 547,296
488,638 -> 488,434
455,823 -> 484,823
488,610 -> 488,948
58,829 -> 931,829
453,481 -> 17,917
629,473 -> 629,53
584,512 -> 345,512
150,92 -> 283,92
663,692 -> 911,692
243,835 -> 243,600
28,26 -> 987,985
422,388 -> 385,388
534,798 -> 736,798
635,394 -> 799,394
155,895 -> 82,968
124,926 -> 968,82
142,431 -> 645,934
201,977 -> 601,977
169,322 -> 775,322
207,251 -> 652,696
989,975 -> 25,11
131,89 -> 131,864
981,989 -> 100,108
114,84 -> 114,434
98,713 -> 689,713
944,262 -> 548,262
481,568 -> 481,904
734,883 -> 734,605
716,687 -> 737,666
228,155 -> 702,155
847,675 -> 896,675
33,121 -> 33,865
58,211 -> 134,211
577,154 -> 659,236
415,958 -> 504,958
984,359 -> 55,359
215,22 -> 357,22
518,232 -> 406,232
264,950 -> 264,672
891,549 -> 891,45
785,328 -> 498,328
496,815 -> 664,815
138,55 -> 406,55
38,823 -> 38,383
467,184 -> 553,98
248,794 -> 864,178
415,561 -> 415,148
665,726 -> 665,236
767,777 -> 547,777
453,860 -> 453,196
23,645 -> 755,645
611,985 -> 559,985
33,978 -> 952,59
772,36 -> 889,36
626,521 -> 781,521
722,502 -> 722,30
978,946 -> 174,142
224,901 -> 655,470
924,142 -> 135,931
505,171 -> 365,171
303,888 -> 663,888
716,838 -> 255,377
494,390 -> 563,459
213,595 -> 516,595
264,436 -> 921,436
785,749 -> 785,78
50,50 -> 979,979
96,72 -> 96,564
647,278 -> 647,460
452,656 -> 452,487
686,145 -> 78,753
900,973 -> 728,973
545,137 -> 572,164
245,211 -> 726,211
550,606 -> 550,41
447,25 -> 447,197
941,581 -> 597,581
299,486 -> 484,486
789,67 -> 55,801
489,842 -> 489,228
716,452 -> 627,452
114,735 -> 329,950
810,157 -> 905,157
575,397 -> 568,404
414,221 -> 779,221
698,363 -> 745,363
976,498 -> 271,498
186,324 -> 519,324
105,777 -> 105,491
241,58 -> 241,102
126,883 -> 894,115
890,853 -> 731,694
760,713 -> 735,713
309,409 -> 61,161
365,263 -> 365,763
425,591 -> 623,591
224,233 -> 645,233
669,872 -> 669,594
112,773 -> 718,167
966,168 -> 966,223
982,527 -> 982,40
439,688 -> 668,688
537,685 -> 357,685
607,164 -> 127,164
192,894 -> 192,987
130,196 -> 130,311
847,987 -> 847,708
354,66 -> 354,260
660,441 -> 983,441
868,282 -> 868,962
915,272 -> 239,948
960,970 -> 26,36
595,837 -> 11,253
258,533 -> 258,209
664,802 -> 664,948
683,117 -> 448,117
961,104 -> 961,231
517,427 -> 134,427
233,451 -> 853,451
978,412 -> 978,496
222,71 -> 794,71
80,343 -> 604,867
209,104 -> 987,882
271,232 -> 711,232
754,329 -> 301,329
560,937 -> 716,937
653,194 -> 441,406
655,506 -> 655,671
599,336 -> 720,457
709,895 -> 468,895
538,432 -> 885,779
72,231 -> 471,231
694,131 -> 694,610
380,37 -> 380,673
46,921 -> 721,921
126,823 -> 343,823
771,617 -> 771,645
356,734 -> 356,406
710,504 -> 710,277
507,65 -> 510,65
292,913 -> 292,944
816,640 -> 913,640
101,132 -> 101,96
180,21 -> 743,584
548,231 -> 453,231
459,248 -> 498,248
567,637 -> 242,962
471,418 -> 471,601
104,822 -> 911,15
802,583 -> 459,583
330,681 -> 253,604
10,431 -> 209,431
220,776 -> 908,88
458,508 -> 458,697
87,803 -> 885,803
636,372 -> 324,372
891,528 -> 891,489
70,274 -> 70,268
255,587 -> 976,587
498,69 -> 498,250
783,838 -> 48,838
864,344 -> 968,240
323,734 -> 234,734
657,347 -> 657,410
661,682 -> 48,682
344,815 -> 344,132
137,878 -> 503,878
927,975 -> 982,920
753,964 -> 16,227
539,957 -> 539,48
314,651 -> 698,651
925,653 -> 271,653
861,518 -> 967,518
846,126 -> 41,931
103,409 -> 118,394
327,185 -> 874,732
716,930 -> 716,40
315,702 -> 246,702
130,377 -> 268,377
845,978 -> 39,172
147,977 -> 147,725
762,660 -> 606,660
871,186 -> 132,186
388,320 -> 388,584
302,410 -> 15,410
336,234 -> 336,673
331,208 -> 225,208
95,565 -> 315,785
843,563 -> 843,640
521,378 -> 118,378
963,17 -> 95,885
862,487 -> 974,487
874,402 -> 703,402
692,689 -> 692,237
947,635 -> 331,635
540,417 -> 737,220
770,161 -> 224,161
721,831 -> 721,424
10,411 -> 10,87
11,985 -> 986,10
465,972 -> 873,972
844,753 -> 676,753
181,27 -> 181,105
450,675 -> 333,558
578,286 -> 578,509
87,363 -> 274,363
892,119 -> 346,665
363,331 -> 363,22
508,424 -> 508,53
371,145 -> 669,145
109,761 -> 343,761
328,804 -> 328,570
411,741 -> 411,269
30,139 -> 915,139
912,736 -> 44,736
555,884 -> 672,884
433,427 -> 19,841
793,796 -> 505,508
737,554 -> 312,979
726,231 -> 568,231
954,479 -> 255,479
33,365 -> 262,365
677,608 -> 401,608
245,620 -> 828,37
295,274 -> 295,10
906,106 -> 906,263
682,719 -> 118,155
208,859 -> 634,859
739,103 -> 323,103
360,142 -> 13,489
131,553 -> 859,553
483,308 -> 483,124
776,720 -> 776,259
528,327 -> 651,450
423,223 -> 794,223
898,698 -> 898,315
488,824 -> 48,824
164,971 -> 773,362
975,850 -> 687,850
504,810 -> 795,810
562,281 -> 29,814
639,574 -> 684,529
417,800 -> 404,800
335,844 -> 335,907
17,41 -> 824,848
644,220 -> 470,220
304,944 -> 947,944
122,807 -> 122,257
308,553 -> 308,819
22,672 -> 22,386
837,675 -> 275,113
716,650 -> 482,650
212,350 -> 212,105
213,594 -> 213,119
431,375 -> 528,278
499,741 -> 58,741
600,291 -> 600,955
905,205 -> 326,205
584,152 -> 584,871
49,153 -> 883,987
818,822 -> 69,822
938,286 -> 938,832
75,380 -> 956,380
986,424 -> 450,960
736,470 -> 736,853
872,988 -> 371,988
102,203 -> 102,123
518,338 -> 518,360
819,263 -> 328,754
952,242 -> 178,242

75
5/solution.hs Normal file
View file

@ -0,0 +1,75 @@
import Data.List
import Control.Monad (join)
import Control.Concurrent
main :: IO ()
main = readFile "5/riley.txt" >>= print . solve . parse . lines
parse :: [String] -> [(Point,Point)]
parse = map (parseLine . words)
parseLine :: [String] -> (Point,Point)
parseLine [ s, "->", e ] = (a, b)
where a = parseCoord s
b = parseCoord e
toRange :: (Point,Point) -> [Point]
toRange (a @ (xa,ya), b @ (xb,yb))
| diagonal (a,b) = makeDiagonal a b
| otherwise = [ (x,y) | x <- [ x1 .. x2 ], y <- [ y1 .. y2 ] ]
where
x1 = min xa xb
x2 = max xa xb
y1 = min ya yb
y2 = max ya yb
parseCoord :: String -> (Int,Int)
parseCoord l = (head n, last n)
where
n = map read $ words [ if c == ',' then ' ' else c | c <- l ]
solve :: [(Point,Point)] -> (Int,Int)
solve i = (f i, g i)
where f = length . nub . overlapping . filter (not . diagonal)
g = length . nub . overlapping
overlapping :: [(Point, Point)] -> [Point]
overlapping [_] = []
overlapping (p:ps) = overlapping' p ps ++ overlapping ps
overlapping' :: (Point, Point) -> [(Point, Point)] -> [Point]
overlapping' _ [] = []
overlapping' p1 (p2:ps) = overlap p1 p2 ++ overlapping' p1 ps
diagonal :: (Point,Point) -> Bool
diagonal (a,b) = xof a /= xof b && yof a /= yof b
type Point = (Int,Int)
xof :: Point -> Int
xof = fst
yof :: Point -> Int
yof = snd
overlap :: (Point,Point) -> (Point,Point) -> [Point]
overlap a @ (sa,ea) b @ (sb,eb)
| x && y = toRange a `intersect` toRange b
| otherwise = []
where
x = xof sa >= xof sb || xof sa <= xof sb
y = yof sa >= yof sb || yof sa <= yof sb
makeDiagonal :: (Int, Int) -> (Int, Int) -> [(Int, Int)]
makeDiagonal (a, b) (c, d)
| (a > c && b > d) || (a < c && b < d) =
let x1 = min a c
x2 = max a c
y1 = min b d
in [(x1 + i, y1 + i) | i <- [0..(x2 - x1)]]
| otherwise =
let x1 = min a c
x2 = max a c
y1 = max b d
in [(x1 + i, y1 - i) | i <- [0..(x2 - x1)]]