aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-12-01 17:21:32 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-12-01 17:21:32 +0100
commit9ad233e4d967f7c134a1d6c50965bcdb722432ab (patch)
tree5e1807631bc41d2be760ceda8b8c0f23520003b5
parentfdba09c1c6c67c9081cf470cd6b3c4e8b7670cf6 (diff)
Add solutions for 2024 day 1
-rw-r--r--2024/01/input1000
-rwxr-xr-x2024/01/puzzle-1.awk18
-rwxr-xr-x2024/01/puzzle-2.awk12
3 files changed, 1030 insertions, 0 deletions
diff --git a/2024/01/input b/2024/01/input
new file mode 100644
index 0000000..515f1a2
--- /dev/null
+++ b/2024/01/input
@@ -0,0 +1,1000 @@
+18102 93258
+34171 50404
+48236 60718
+10441 41669
+63428 45329
+42451 56834
+74881 39407
+32801 36101
+52771 79895
+41513 78731
+81076 52363
+87623 35520
+15259 96330
+57319 78241
+42758 41144
+80744 20357
+28199 55267
+22505 35520
+74707 74819
+67725 96130
+13883 35520
+87486 55267
+25070 30977
+10199 74819
+91803 75066
+60122 78266
+17884 61488
+41073 81666
+24778 15223
+46587 87276
+75477 82771
+78585 59630
+23143 20028
+67975 13674
+33304 70802
+19939 50051
+35520 52616
+73263 19938
+89352 99541
+65187 80938
+41347 35520
+64416 57744
+86648 22827
+91435 47131
+96712 38412
+89053 76476
+68596 31155
+22661 30518
+87094 22104
+10403 46003
+41029 68410
+62486 54054
+24752 47138
+59331 80259
+83839 84471
+19771 87508
+68258 73947
+69907 93126
+36611 87565
+69633 35520
+19461 20361
+43869 86799
+88115 13167
+27925 21142
+75724 33150
+14715 66772
+46237 88588
+22390 57154
+90584 66789
+89982 55267
+98196 93258
+83394 28441
+68840 50490
+21728 36730
+83742 60945
+43346 38412
+79097 84471
+13016 35520
+28401 41164
+18245 81634
+99352 39461
+33202 36444
+88303 14489
+95205 90462
+80929 97718
+18847 78535
+36538 10273
+40204 76019
+52395 80344
+62145 55267
+29945 74391
+99218 14416
+92009 42686
+83998 36730
+50338 81796
+43724 90026
+86537 33172
+89079 44444
+32728 41669
+60742 67245
+35894 42369
+66329 16357
+42434 19057
+65046 13593
+41778 42363
+62183 46290
+37564 10310
+46436 94358
+58111 74819
+13914 85272
+67992 46429
+42766 46993
+97620 79909
+12930 36101
+14208 62020
+41890 36730
+81680 21444
+84864 64563
+29905 72690
+35753 52398
+73868 35520
+17253 29006
+72538 88588
+77189 89503
+81736 18206
+33322 31658
+48157 79144
+28398 45304
+51735 83365
+42009 59880
+25466 41416
+52459 99199
+57747 36730
+12226 12617
+41445 33884
+15088 42664
+21076 99403
+24923 36730
+47057 87695
+14281 76662
+58163 75603
+41046 88588
+25315 52616
+88847 31193
+25550 35520
+37785 54965
+42166 81663
+36739 55267
+13289 58788
+95744 62866
+23230 41669
+89299 88513
+94591 57796
+19517 78347
+38689 71550
+55241 41669
+80752 85442
+24799 84471
+13063 55267
+27395 80539
+78086 41669
+49641 13167
+60112 63395
+57026 15781
+34007 29172
+49274 72405
+14926 96924
+54717 58045
+16315 22728
+90753 82631
+99446 13167
+51171 81263
+65577 51430
+59152 40932
+98558 41284
+60772 88588
+89469 93258
+78257 51498
+17794 63128
+17963 99564
+10250 12980
+11455 64655
+89464 78241
+68825 20389
+18793 81458
+78236 41669
+54490 94531
+16188 51392
+17889 41669
+88466 55267
+30083 84471
+83012 57306
+70675 81796
+13694 84854
+58909 38592
+40234 94238
+51671 81883
+91196 49891
+86378 92193
+81435 83848
+52846 38940
+96254 85424
+28810 35155
+57295 68573
+56262 94606
+70230 29354
+22599 10175
+42130 30343
+52701 99403
+62915 12166
+76676 88588
+92756 55926
+85607 84471
+59730 67890
+32152 56550
+83584 12212
+91305 52052
+92411 62866
+30000 24317
+48046 39809
+53235 93258
+58381 30343
+81243 39857
+46414 37480
+14203 19491
+94671 53889
+25932 74714
+15761 95661
+41032 87276
+95383 12977
+63041 37164
+62397 38420
+31632 80344
+73259 63756
+39665 53750
+80475 32801
+71036 88588
+72272 79144
+60444 94808
+62938 98520
+91946 39934
+65936 81849
+46418 56506
+75068 97162
+39001 52616
+41161 30343
+15026 35598
+42469 41669
+56940 80344
+14981 79323
+18795 70311
+51498 79144
+18298 39857
+57977 95908
+99404 90175
+16709 94746
+52847 17022
+19595 32739
+75552 54475
+56206 73676
+21473 79204
+92226 37522
+77631 41409
+32460 39212
+68228 89367
+93156 51665
+43009 54778
+14468 63363
+38918 43492
+63144 83443
+64474 99403
+59151 68155
+74740 84352
+46043 66174
+19176 79144
+80639 36730
+12346 18866
+32789 35520
+30312 13167
+90241 34021
+61418 95707
+52839 52960
+59507 11557
+51774 80344
+72851 31658
+21231 52129
+17825 67968
+48685 80344
+90363 14286
+32135 81656
+89692 93229
+71792 84471
+24754 91630
+15559 17945
+73777 62866
+73826 93258
+61029 10131
+21893 79844
+72680 80344
+54635 80344
+46537 96585
+28015 51978
+80768 99403
+52593 31658
+15701 83366
+97543 45838
+33327 55267
+60326 10669
+71666 68499
+68900 91751
+27686 40337
+39616 62866
+51033 37907
+25015 14676
+41682 19585
+79008 36730
+49472 47063
+98674 62202
+33282 84471
+59585 75619
+86450 58477
+14432 87276
+67623 18866
+84033 69700
+13957 40073
+55400 21005
+13167 36730
+34835 15933
+71718 58623
+95411 97681
+57118 94831
+41944 62866
+88120 62866
+11752 32137
+85462 36211
+85424 46228
+79713 80344
+16019 62866
+17655 38412
+26672 17352
+82553 76385
+23188 71537
+56490 39857
+46951 13167
+85961 13877
+51560 77830
+94957 52616
+27650 74995
+70629 73120
+25129 32171
+62148 48774
+44331 87276
+69734 37018
+21661 51261
+13612 82993
+90689 13167
+92312 86533
+98598 80344
+68752 41669
+30190 35520
+36730 50595
+52267 64296
+59707 65310
+80349 62885
+63683 45682
+74727 82966
+86012 81529
+39964 88805
+16119 69720
+33146 70138
+90376 97651
+22904 98429
+87159 29634
+23078 18154
+23361 32845
+71970 63128
+10411 92866
+31178 88588
+50980 27848
+45078 77661
+91447 42358
+71418 32868
+76636 78241
+30598 93258
+28434 38738
+40660 79275
+62848 99403
+28084 38612
+12699 59071
+59263 81796
+26439 62866
+17391 78241
+93530 45014
+45542 97173
+69388 13423
+80066 28361
+63149 95510
+27861 81796
+62609 28829
+78241 64755
+98783 53082
+21987 31658
+31758 18211
+21749 79144
+70377 52464
+65877 97679
+74993 57174
+53846 78241
+67812 39783
+32323 63362
+18461 91739
+38165 31920
+80422 39857
+43219 31658
+84785 30343
+54985 88562
+18275 62866
+54638 78780
+76547 55267
+15874 41010
+86965 36101
+97038 74819
+13828 44487
+21733 79144
+84471 16719
+26596 15857
+16529 28650
+25443 35348
+15059 43502
+81770 36730
+81309 78241
+35589 69602
+94630 35179
+53197 76827
+29523 66364
+46055 30993
+85203 60814
+39329 53071
+18663 32233
+50108 99922
+41019 98673
+89169 76809
+93556 52782
+69891 54164
+40270 51225
+82965 46304
+22455 40010
+41669 32801
+71630 15002
+48390 61558
+44783 78241
+59867 32801
+36112 31658
+81101 91237
+54551 96109
+20993 92021
+50680 38412
+63128 84471
+94509 80344
+10577 99239
+25724 84471
+17317 20799
+39300 76645
+76421 67643
+43817 20959
+75711 58027
+34480 35520
+64585 64739
+64685 99403
+43062 58999
+81760 88588
+63083 40045
+39425 36730
+17622 80859
+64617 36051
+59190 85424
+81175 97509
+93869 51498
+62866 61413
+26396 71626
+87276 98001
+79144 48463
+23812 31658
+31923 47911
+87102 81796
+40295 85346
+92002 66371
+62557 65288
+73197 53046
+68891 80787
+39756 37172
+19915 60878
+43089 32558
+30343 31658
+50332 66707
+26000 58109
+67720 82142
+41227 56943
+97647 47831
+76020 38412
+40485 84471
+16962 53016
+30066 28740
+31118 54102
+41928 99913
+82656 38412
+94155 34933
+52515 48131
+48519 45948
+64922 51902
+73451 81796
+31917 93734
+96992 56765
+60790 48526
+68218 75199
+80344 59642
+94057 47998
+74830 99403
+70462 56217
+76371 18624
+56899 90796
+92898 66333
+34979 72161
+37736 80344
+41607 32801
+48181 41716
+72333 26215
+13666 78112
+91781 85424
+77373 83784
+94719 94693
+65491 41669
+88464 47980
+98595 56821
+16665 57249
+42861 81712
+38767 65492
+31642 39581
+54565 86820
+51346 74706
+38258 81796
+35980 77859
+13015 61175
+79811 14561
+29887 12736
+48972 31658
+43907 40337
+15478 45373
+97895 52030
+93779 15247
+19906 88588
+69778 98196
+66203 63897
+91035 39857
+27450 63128
+11710 77533
+61760 31658
+50614 74819
+89099 87276
+75125 46470
+55904 39857
+76167 37911
+94908 47677
+58478 18866
+20475 37504
+21737 13167
+90464 99403
+12941 84669
+48793 62866
+60186 84471
+11894 39857
+55293 21637
+33993 76974
+47080 64256
+73306 62866
+95473 74936
+35272 59929
+20187 36730
+48764 59657
+65430 16092
+79522 28419
+98586 21238
+11131 97814
+15190 32801
+14978 39857
+83286 78490
+40748 81839
+25325 20040
+24813 58230
+52110 79030
+75599 95523
+23138 63833
+63416 65152
+13853 98184
+60874 80344
+32281 88588
+80353 72102
+24683 84471
+42421 38412
+75909 86850
+22940 36074
+80544 96507
+62292 58866
+98462 38182
+46560 56050
+87289 79144
+88955 15573
+70992 25439
+81256 38412
+28446 29484
+83121 95224
+16108 74352
+34016 37646
+55211 29561
+20806 87737
+17271 99403
+35249 76966
+25159 67894
+40337 58440
+60006 32338
+60866 38412
+66540 93258
+90000 58211
+57957 38113
+54883 80382
+65202 41669
+56318 22865
+43827 39813
+81395 40970
+69790 86084
+17754 55267
+92786 31658
+98085 88588
+50334 48963
+35482 58393
+32883 70992
+62378 14433
+99609 73135
+35356 36730
+78375 68903
+37024 13132
+24204 27308
+72637 38412
+17428 58766
+80886 18866
+66117 59583
+77402 72213
+66620 23574
+37470 26120
+56642 97207
+16039 99994
+23520 59100
+39995 75647
+31430 77373
+59277 16018
+77197 21617
+93312 84197
+81972 60483
+99910 79880
+83510 34604
+52934 99403
+60313 32544
+86206 62733
+32957 53708
+18748 59570
+34408 63137
+64561 95075
+89324 88588
+86562 99403
+34014 98669
+52477 54060
+82112 91468
+46837 51376
+42855 89033
+76285 10788
+48498 11016
+87628 95461
+25039 23870
+44726 84471
+36316 17593
+55475 12512
+40885 61324
+55982 41669
+28353 93258
+90070 87664
+92571 50972
+64040 77373
+66045 44321
+76075 47585
+69898 35520
+31897 78241
+45288 77373
+61402 40079
+43939 79476
+83915 87612
+51714 70302
+55728 61718
+19212 48853
+50471 15323
+11253 36730
+36282 61657
+99765 88588
+40255 84064
+65591 31658
+88588 30358
+53096 62672
+32485 52616
+90637 35520
+23957 55267
+15301 74819
+99304 38412
+42581 99633
+89403 78241
+88697 46405
+23646 81942
+82798 41669
+19417 72825
+99035 54991
+99372 77622
+49134 11067
+41732 49561
+69058 51302
+85817 52817
+80628 47979
+98869 18345
+21540 44446
+36075 62399
+74841 16533
+29826 68948
+74966 33155
+76789 33664
+42909 76884
+61686 93258
+65851 98787
+38529 64090
+64968 58698
+99647 70935
+49851 13167
+88523 38412
+92200 35520
+21926 55267
+85918 78241
+35092 80344
+39857 33948
+80393 59217
+97911 43227
+90571 35520
+48736 83686
+77924 63128
+18866 80344
+21299 74597
+81796 45742
+93562 96860
+89376 36730
+68027 75225
+13032 79144
+28892 57468
+96012 72691
+96357 90025
+93590 76769
+39169 81796
+69505 83140
+27406 79144
+45575 25412
+10640 69420
+42859 67773
+54319 76647
+36900 89641
+16622 73504
+55267 10781
+60719 75932
+63099 36730
+14798 31658
+89944 22601
+40221 55267
+75498 35601
+91475 36563
+23362 39524
+56739 81796
+57452 80344
+60950 97510
+78516 99403
+27941 62443
+27521 66529
+33707 88588
+93324 91799
+57954 78745
+10142 96525
+93400 79144
+10246 51708
+96780 80879
+90160 28886
+75452 68015
+51405 30788
+30558 43844
+80443 56573
+53073 55181
+23213 60714
+86395 98419
+26118 38412
+77828 81796
+83431 19529
+66085 56790
+87013 80344
+78095 27229
+92609 32801
+97658 96068
+97452 49425
+63195 95504
+22526 79144
+40153 79144
+77603 88145
+21804 26067
+70021 27010
+39030 20686
+44696 30343
+98142 54162
+18276 69052
+61036 14279
+89542 91528
+36218 99403
+59135 87980
+44366 61548
+73468 40559
+30939 26766
+66589 83054
+39929 63975
+25239 79144
+74819 40299
+77393 87276
+89793 74480
+70491 56646
+13636 99403
+58152 87276
+30693 19897
+31134 61607
+12324 35941
+67104 22474
+89552 84471
+96869 36730
+61641 42507
+92835 28786
+51442 41669
+40162 84338
+92491 16076
+11753 35520
+95247 79627
+11256 30343
+93258 41669
+24504 25813
+85713 41965
+19158 81796
+50458 41669
+48386 22205
+68720 90932
+36101 79144
+57165 78241
+22469 31658
+99737 14211
+58884 65158
+29461 98196
+86864 72295
+91962 77373
+93672 51538
+89453 83913
+86350 90636
+42288 98263
+17267 18583
+30518 55555
+76868 62866
+55662 44542
+31658 98196
+99589 31658
+64736 36101
+16281 62886
+32687 66131
+77273 83572
+52616 71835
+35719 12817
+87282 36101
+49495 17763
+41116 56436
+65977 31658
+87148 66523
+71950 99639
+93432 41570
+47256 24165
+60388 58593
+52721 87348
+46321 27970
+31533 64362
+82098 35520
+60520 98196
+62425 65803
+90692 57775
+29160 99403
+28072 65721
+29207 40337
+96928 11960
+88074 55022
+11262 31658
+70439 12630
+46426 40192
+97124 96336
+97733 79144
+60902 82128
+20406 18866
+49465 24075
+92723 84471
+82785 49899
+85690 84471
+46301 60801
+70543 39158
+77397 13167
+78434 89992
+43358 22650
+38412 60568
+54633 45527
+27215 93385
+98736 65619
+12981 48333
+79201 61358
+71849 25687
+27785 40337
+57013 13427
+99403 88588
+22632 26830
+12033 77373
+66675 16445
+23066 67354
+80100 31674
+77822 43658
+70694 18628
+38583 97566
+29014 39095
+71974 78640
+44442 94472
+89670 92693
+58205 52583
+26610 32340
+50111 36267
+81769 55267
+80727 15549
+54969 41669
+88744 81796
+66642 43640
+38035 81796
+86110 74184
+74806 38412
+26849 66673
+27007 93396
+80555 78794
+64197 32236
+88661 18331
+16011 32801
+18265 19847
+73365 46289
+71259 84471
+53163 80344
+67421 42238
+61567 39797
+78176 12791
+68680 99109
+83969 59805
+99427 65563
+64286 88588
+69259 49401
+65989 60112
+74866 55267
+91571 70365
+61137 72545
+86810 99342
+91215 74819
+57984 84471
+64054 45167
+25371 93258
+56931 97531
+42448 58600
+77910 41669
+27234 23987
+55971 67247
+53910 23754
+59015 16842
+36568 18866
+93228 92940
+38858 21883
+37570 41669
+43634 48654
+61671 36109
+14455 39324
+69564 61102
+75007 36730
+83030 35520
+27889 41669
+90946 41125
+12614 70263
+61381 18549
+90763 45873
+13117 44089
+13363 84471 \ No newline at end of file
diff --git a/2024/01/puzzle-1.awk b/2024/01/puzzle-1.awk
new file mode 100755
index 0000000..ff361aa
--- /dev/null
+++ b/2024/01/puzzle-1.awk
@@ -0,0 +1,18 @@
+#!/usr/bin/awk -f
+
+function abs(n) {
+ return n < 0 ? -n : n
+}
+
+{
+ xs[++i] = $1
+ ys[i] = $2
+}
+
+END {
+ asort(xs)
+ asort(ys)
+ for (i in xs)
+ d += abs(xs[i] - ys[i])
+ print d
+} \ No newline at end of file
diff --git a/2024/01/puzzle-2.awk b/2024/01/puzzle-2.awk
new file mode 100755
index 0000000..8400a16
--- /dev/null
+++ b/2024/01/puzzle-2.awk
@@ -0,0 +1,12 @@
+#!/usr/bin/awk -f
+
+{
+ xs[++i] = $1
+ ys[$2]++
+}
+
+END {
+ for (i in xs)
+ d += xs[i] * ys[xs[i]]
+ print d
+} \ No newline at end of file