commit f0770a13ca209e4de08ea6392e587e81a16496ae (patch)
parent 93b22b966fd2a01eb109b7f8791568a77965be45
Author: Alex Karle <alex@alexkarle.com>
Date: Mon, 2 Dec 2024 01:41:57 +0100
2024: Add day 1 in Python
Diffstat:
4 files changed, 1040 insertions(+), 0 deletions(-)
diff --git a/2024/01/1.py b/2024/01/1.py
@@ -0,0 +1,18 @@
+import sys
+
+l1 = []
+l2 = []
+
+for l in sys.stdin:
+ l = [int(x) for x in l.split()]
+ l1.append(l[0])
+ l2.append(l[1])
+
+l1.sort()
+l2.sort()
+
+s = 0
+for i in range(len(l1)):
+ s += abs(l1[i] - l2[i])
+
+print(s)
diff --git a/2024/01/2.py b/2024/01/2.py
@@ -0,0 +1,16 @@
+import sys
+from collections import defaultdict
+
+l1 = []
+l2 = defaultdict(int)
+
+for l in sys.stdin:
+ l = [int(x) for x in l.split()]
+ l1.append(l[0])
+ l2[l[1]] += 1
+
+s = 0
+for i in range(len(l1)):
+ s += l1[i] * l2[l1[i]]
+
+print(s)
diff --git a/2024/01/input.txt b/2024/01/input.txt
@@ -0,0 +1,1000 @@
+69214 60950
+83241 49638
+37930 31308
+50722 94914
+93164 82798
+80918 72850
+17490 79421
+64372 87820
+89659 98375
+91555 95812
+48924 93602
+38031 64096
+57853 20530
+88521 43214
+68331 14770
+32767 19574
+95030 92579
+80448 10870
+27268 86384
+18742 65926
+50258 95193
+88830 17352
+73007 82798
+95145 42403
+58976 17352
+22476 68379
+21785 17811
+21560 90827
+82909 37527
+55371 69778
+73607 32404
+88276 44965
+86274 46099
+61163 63445
+52231 27046
+84647 20530
+37515 57298
+44394 99003
+58258 74954
+56060 34105
+79808 73814
+96748 51318
+87301 46022
+93991 44642
+45674 96969
+10870 49159
+13175 23840
+12881 86704
+11425 89064
+71044 92543
+70247 88369
+97814 73317
+78003 44160
+45779 14598
+95915 46875
+51055 99003
+14500 19574
+40956 23840
+64791 99735
+95406 51318
+18800 72878
+85004 33238
+16723 31504
+14333 69398
+40419 10870
+81499 79136
+31696 24276
+71897 55421
+63928 46875
+46875 33198
+40086 76959
+67622 29550
+63819 88369
+74694 35769
+63615 20200
+88828 58414
+58917 20414
+86066 24696
+84677 47814
+87339 89616
+30182 36007
+71811 63762
+26364 18927
+45435 54026
+65473 83062
+40764 12795
+86131 19574
+46984 71532
+94658 36666
+34864 85172
+74271 85172
+37126 63381
+26701 91608
+11846 99003
+91698 44394
+19986 17352
+31279 82252
+25542 10870
+43023 98869
+25001 25208
+39137 44758
+75796 94436
+93491 42015
+16837 69895
+78167 59486
+56738 17811
+66303 49575
+91100 33987
+99100 41554
+46126 41472
+31826 20530
+61208 20200
+98875 49776
+89960 23840
+87445 88369
+90701 59605
+48604 24766
+49830 60581
+32422 32404
+48321 49338
+91545 51318
+30591 23840
+76791 25366
+47653 64300
+70447 10870
+96337 10870
+40822 99003
+50985 36666
+45600 58520
+78539 21021
+11792 39770
+89999 23840
+22229 24252
+79514 31414
+93645 99874
+39916 12567
+63722 87301
+85209 12845
+78460 94436
+79669 33420
+89396 36762
+12518 91072
+70992 20530
+92482 51318
+50977 39809
+59666 93602
+69358 24889
+30774 85209
+50495 88117
+74843 68135
+64043 93602
+42690 14598
+95474 99003
+31999 10870
+77935 30381
+86471 46022
+82671 23840
+21996 17352
+25301 68950
+45903 49209
+88433 15186
+18897 13349
+23742 38006
+29440 44394
+77679 19534
+67503 19006
+22862 87523
+68125 36752
+32102 85209
+57298 32444
+44985 10870
+76984 88369
+96974 44648
+22496 17352
+19906 88369
+53085 69481
+49762 39320
+23508 13349
+73366 19574
+39420 85172
+21487 20200
+49538 31279
+58985 33747
+78834 86304
+83207 77460
+26624 39320
+33276 87130
+62119 15410
+72488 72850
+69108 46022
+28383 64125
+45283 60950
+56242 88580
+47120 46022
+20917 12845
+91088 67959
+30625 92579
+81302 98117
+14883 22568
+45215 46818
+36185 72873
+47369 19661
+39320 48658
+35775 60950
+20573 66758
+92168 46875
+85925 23570
+83017 28941
+88673 62352
+85790 46022
+40389 17811
+13925 14598
+65265 98819
+21058 70060
+81605 36401
+49669 63107
+58410 60950
+20993 32404
+89320 36606
+93679 89908
+24396 66724
+26960 82887
+35749 98507
+67814 60950
+95966 99777
+45832 90281
+21396 69067
+70924 77174
+51921 31279
+86430 41554
+60703 76733
+55109 86032
+64568 34984
+61181 39320
+76019 80530
+93405 35718
+40732 73310
+27676 56302
+46615 12644
+94412 32659
+42651 46875
+22911 88369
+37891 61401
+39505 19574
+30551 99381
+52001 99003
+94890 77236
+12845 10870
+60037 99735
+17811 93480
+39461 52563
+70835 99003
+26239 32404
+21199 53413
+29427 61865
+99745 52578
+58368 85172
+32844 17811
+25356 61341
+55087 39124
+73711 94153
+23878 15193
+19011 15821
+55522 76895
+25442 85172
+43553 23840
+79059 51318
+45546 85172
+18253 46875
+13486 98333
+85621 78640
+94812 14598
+35976 22851
+95446 35811
+68679 86540
+35048 32404
+32404 58367
+54639 82218
+46890 99735
+54797 64140
+58043 28678
+38310 78102
+96824 19574
+82010 90281
+44558 88560
+25947 55410
+39754 90281
+85172 77816
+38409 72850
+93847 79705
+70670 31866
+66466 72850
+14378 85172
+10594 82798
+88488 36494
+80919 90281
+15539 60764
+76757 20530
+73014 80854
+10103 28777
+63011 51318
+97931 72850
+11511 23511
+90999 46778
+10581 17352
+24639 84344
+12573 87301
+94628 73454
+68709 60950
+69611 36666
+77840 32404
+56046 43452
+64975 36666
+35086 27046
+21044 63339
+27003 32404
+99990 41554
+92558 76384
+10676 51318
+79869 34929
+41478 23840
+40010 17811
+57724 13349
+36886 20530
+52799 39658
+74618 28890
+37677 39602
+25056 19780
+37249 60950
+16420 21533
+92579 91814
+32467 76018
+50446 40645
+20800 27046
+25367 93602
+20200 50429
+67153 82421
+99387 85172
+99003 99003
+21079 68678
+21496 45196
+10244 85172
+60317 96967
+89792 64416
+66971 28760
+48409 49209
+87836 13036
+94588 25049
+19574 80163
+43975 90281
+54578 22870
+24412 17352
+66935 85209
+75103 46748
+99675 13318
+63283 86570
+38622 17811
+76156 12554
+18868 31279
+95097 28731
+87940 25307
+31588 20683
+86721 51679
+40662 60665
+61441 46875
+95742 96428
+12500 48663
+69704 83722
+52150 52130
+94648 71064
+34905 72850
+90241 81541
+22820 88917
+84893 82798
+35291 13349
+91607 69674
+91250 89186
+12934 76205
+50355 10870
+11918 93561
+11981 87504
+90011 97792
+19160 99003
+38536 95219
+47433 72254
+71173 20241
+58871 49592
+99297 46875
+14256 36666
+42700 92579
+65952 26453
+38344 17352
+31939 66675
+88319 31279
+48532 69055
+54160 37364
+51367 98234
+63774 67948
+91398 52760
+19606 98639
+15722 27046
+11670 27046
+11752 90281
+57229 24766
+92900 82069
+35472 17352
+11762 10464
+52327 51318
+49806 24252
+83152 27046
+66672 11070
+13349 20530
+10860 67520
+34902 74641
+36500 14208
+90699 24766
+65392 68056
+67360 23840
+20770 12845
+27579 17811
+52424 20530
+88044 70562
+82234 32404
+38116 23840
+71095 60884
+35234 10870
+74397 36937
+59605 79377
+33516 82798
+83961 17811
+17934 81965
+58619 60950
+24784 46183
+60415 32404
+33999 62356
+70899 42550
+71992 61565
+31607 48168
+82993 27705
+98377 72447
+19236 97390
+69248 97543
+12305 39320
+12750 72850
+67143 47302
+51085 13713
+21283 84586
+58438 20530
+61450 84960
+77223 87301
+40730 18648
+61388 92620
+10697 95051
+29817 46022
+44526 85172
+42126 23970
+91131 24766
+53762 23485
+99711 24766
+41168 12845
+89661 97679
+19509 87301
+46491 87301
+82876 90281
+57530 99003
+30070 12845
+37182 33467
+98660 94041
+53088 49209
+23056 33662
+59488 88369
+27659 76043
+85486 46875
+33558 87301
+64995 54418
+58406 20530
+52353 12845
+52674 84792
+97158 41554
+36966 65903
+96617 15049
+17881 23393
+38135 27655
+35640 10870
+75976 78468
+54361 85172
+70827 74733
+23840 16180
+93190 51318
+75051 18196
+64409 85172
+20040 48165
+92938 97826
+43465 51609
+11298 78526
+99421 92903
+21674 62444
+68613 17352
+40038 68779
+90984 49209
+72223 99735
+99618 84903
+96274 37409
+54840 85533
+77678 96379
+79087 33036
+27866 23840
+94127 87366
+83829 46731
+21118 27046
+54767 58444
+31592 39320
+84251 80340
+16359 47980
+33404 86692
+30167 53720
+54633 57298
+64214 85172
+65936 94436
+26779 72257
+56981 16995
+88384 14598
+16954 12845
+19265 34877
+20882 10870
+24268 37193
+73896 73107
+17491 64788
+34135 96478
+97863 20530
+33458 41554
+87234 13349
+17021 43950
+43735 46022
+41413 51318
+23370 27518
+40859 52659
+20847 55643
+78780 46875
+89412 44659
+44732 85942
+15416 41554
+20026 13573
+20447 20530
+92208 27046
+22919 47883
+19025 66716
+78537 94436
+21990 13835
+57022 47578
+23379 27046
+10223 40352
+70096 99003
+27889 86884
+73766 50077
+17352 59737
+18766 53132
+85353 82798
+16699 76756
+18043 80464
+67635 32404
+89066 32404
+96095 36666
+80193 17352
+83111 24567
+82714 51318
+15568 62699
+46071 88369
+24766 17393
+24252 51318
+90799 65043
+45593 42548
+42434 88369
+76708 19788
+44049 17352
+26070 23840
+89487 60950
+75405 50409
+61151 50949
+55659 87976
+97690 10769
+23955 41554
+51413 44394
+93303 74623
+88340 46875
+36666 86119
+68983 36666
+97452 18100
+77775 28288
+93498 85175
+35180 73788
+88369 40289
+60950 89290
+80469 99735
+44830 26094
+56953 12845
+14598 32404
+48010 43254
+51318 16119
+70157 59605
+29536 27046
+97148 24766
+88940 99003
+94267 12845
+80689 82798
+51360 63373
+22949 85172
+61037 87301
+12068 65294
+29715 85209
+90504 28648
+31564 88812
+33933 82995
+29523 72320
+77893 80865
+55688 78887
+24079 24766
+13322 32095
+89943 48334
+29072 58704
+53586 12845
+23918 14598
+56128 88548
+66658 69626
+10133 67845
+99815 85172
+68216 99003
+46022 15395
+83063 21232
+62075 23840
+53883 14598
+66467 32404
+47896 69944
+71785 51318
+84153 16006
+29778 85209
+31766 24766
+16108 35318
+45369 94436
+40723 88485
+65628 31279
+22238 45332
+91501 92579
+17080 83343
+27106 17811
+52006 13517
+10554 96843
+42902 54855
+78074 59112
+76079 19574
+66574 37842
+30704 87301
+61970 72591
+75806 89415
+65083 36666
+44142 88369
+89309 18398
+14755 24252
+31582 10397
+71879 12845
+50300 19574
+55843 62837
+70241 67656
+13864 12845
+56863 36666
+28825 19574
+93845 22897
+20530 17811
+44137 13349
+47611 49209
+76632 71061
+96396 85003
+21784 28828
+10465 28473
+76247 12845
+90281 62295
+68036 85383
+98495 49331
+66489 17352
+73992 89989
+27262 24766
+46644 88369
+27046 58715
+68306 32404
+56759 84611
+59597 99003
+35807 11412
+81247 66456
+28886 94970
+93602 74875
+28876 50501
+83548 98501
+42548 74927
+17737 60997
+39564 95234
+38730 39320
+15305 62977
+64475 20570
+88203 27046
+49209 46875
+58403 94223
+33211 79621
+12588 80687
+38930 17322
+57720 87301
+70408 29585
+35638 23840
+97473 19574
+79297 10870
+82229 27046
+86569 17352
+25113 78295
+16476 24791
+75345 94436
+15696 12845
+24138 49905
+82572 27046
+88539 39320
+59729 87301
+20283 39331
+31336 21205
+93878 31692
+69846 72850
+54419 91006
+82798 84255
+49394 40818
+69345 52987
+39250 60950
+26399 87538
+32384 19159
+97484 43143
+63090 32208
+76597 23840
+14020 32404
+62045 75497
+18689 32404
+52623 31279
+52491 98683
+87906 85172
+82114 99003
+26961 70112
+17367 46022
+98279 88369
+71505 25937
+19537 25375
+21670 28451
+56125 19574
+60764 46875
+77962 17811
+91463 54069
+47556 59029
+83067 87301
+55521 80404
+51846 52594
+34746 10952
+41554 91631
+87263 59965
+22625 42548
+44644 80377
+66676 31212
+10499 11321
+70675 99003
+40581 51732
+87994 39961
+94436 46875
+97737 62666
+79484 41644
+53333 41554
+42911 19574
+37210 96788
+12286 93469
+86302 78835
+89841 90378
+79773 45455
+91417 19811
+61800 38053
+23495 95310
+31663 12652
+26644 88369
+46904 97345
+26299 32404
+81023 72850
+20782 94436
+48451 85172
+42895 83143
+53844 46875
+49912 17811
+86234 53747
+98733 85172
+90395 51318
+87860 36666
+62319 36666
+81832 87028
+96801 48785
+34060 94915
+19206 46022
+61175 74300
+38749 61982
+35243 89642
+94052 22838
+68544 23840
+38895 31279
+13279 49209
+47468 46826
+94318 87301
+71918 17811
+86789 41554
+83931 71452
+71126 88369
+16125 55867
+39086 95213
+16328 12845
+71229 20530
+79671 67001
+91145 23840
+53528 48955
+23966 39867
+36677 77019
+77291 20530
+32335 93201
+94998 17586
+16372 41181
+99014 80727
+61040 99055
+93576 82718
+92791 61735
+79499 80967
+71009 12845
+16657 20530
+75219 41824
+49208 87301
+65336 94436
+39833 67725
+39788 22450
+15097 96722
+13674 82562
+35721 69206
+46963 17811
+90463 24766
+78488 41554
+78916 60727
+59443 90281
+43680 13349
+36601 60950
+41176 94271
+43717 80804
+37766 20530
+82109 88369
+17559 32947
+28284 49209
+22341 88369
+31223 60082
+39647 82580
+64525 13349
+29368 12845
+98386 28932
+64817 77829
+46178 39365
+95082 92579
+70089 81861
+72539 51350
+11579 42548
+63864 77114
+13611 87301
+71054 84124
+49549 56474
+98626 76586
+21372 87832
+42043 32404
+51898 88369
+29323 22433
+64305 30520
+70362 18267
+26501 73191
+10172 41554
+19438 36666
+17316 20200
+13127 51318
+11331 23840
+37354 22773
+34872 20249
+48467 85209
+36745 10870
+97478 88369
+29324 10246
+24179 63888
+24371 39320
+61932 45220
+55020 10320
+64150 36160
+68372 52644
+10714 64027
+68990 57768
+72825 40811
+85765 77880
+32558 20200
+78846 93936
+71711 85172
+90337 94436
+32298 76808
+86944 38430
+36174 29108
+53613 72165
+79549 43129
+43539 44170
+61122 88369
+30084 56992
+49969 39320
+38272 86708
+11594 30429
+69508 70293
+21588 68766
+97316 76575
+97425 41520
+62763 31254
+63345 23840
+43015 93602
+52670 82798
+58251 48255
+33771 20530
+12901 25496
+42101 41554
+43970 67658
+90983 88369
+33538 93514
+89043 26380
+65451 82798
+73769 28981
+78129 70224
+84083 78572
+72978 28610
+81230 47914
+97477 75916
+96888 42548
+24917 39320
+97486 78173
+13312 51318
+27167 93602
+76762 20600
+72850 47594
+24623 58718
+99735 87301
+92737 39670
+33120 59605
+63398 20200
+38385 98299
+81987 53969
+62260 51318
+67235 63713
+85100 42047
+27762 90281
+13906 51318
+85558 36666
+42148 12845
+88468 20200
+92033 32404
+39309 32404
+99521 99391
+80929 17352
+28236 46875
+83442 20530
+50329 10870
+75224 47197
+71764 99003
+22012 82219
+89620 28881
+60052 88379
+98379 44694
+47207 94436
+47361 40762
+96159 17352
+61549 84760
+36863 80773
+28638 90281
+28879 24766
+24022 55460
+25334 10870
+25095 46875
+14190 63285
+66088 70993
+36470 50008
+47970 87301
+35396 17811
+24123 47037
+26462 52299
+49162 12845
+88098 87301
+53920 59862
+84177 10870
+18969 36666
+55280 11340
+14058 68145
+13245 14598
+23434 46622
+56966 78829
+77060 71967
+25997 57796
+41947 82348
+52576 12845
+91921 51318
diff --git a/2024/01/sample.txt b/2024/01/sample.txt
@@ -0,0 +1,6 @@
+3 4
+4 3
+2 5
+1 3
+3 9
+3 3