A => .gitignore +2 -0
@@ 1,2 @@
+day1/target
+day2/target
A => day1/Cargo.lock +7 -0
@@ 1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "day1"
+version = "0.1.0"
A => day1/Cargo.toml +8 -0
@@ 1,8 @@
+[package]
+name = "day1"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
A => day1/input.txt +2250 -0
@@ 1,2250 @@
+9609
+7601
+7142
+5278
+9374
+6815
+1050
+6329
+8016
+
+12477
+28601
+
+1056
+5037
+1660
+3786
+2611
+6689
+3159
+2973
+5286
+2401
+6231
+7460
+
+3689
+3909
+9254
+5704
+10307
+10173
+9336
+4586
+
+5476
+16022
+9109
+11504
+6746
+
+1006
+1685
+2688
+4776
+6234
+5807
+4943
+4944
+4982
+1731
+3196
+5573
+5269
+1266
+
+12097
+15573
+1113
+8920
+14145
+
+4723
+2428
+3864
+4657
+5046
+5135
+5104
+1867
+5130
+1751
+6029
+4551
+1924
+4998
+4255
+
+2706
+5595
+10508
+3676
+11580
+6061
+7902
+
+2523
+11236
+1915
+15774
+7639
+
+2996
+3656
+4491
+4493
+6136
+3112
+7342
+3600
+6111
+4229
+7548
+
+4200
+8635
+1003
+1223
+3096
+10734
+8319
+3772
+
+7063
+3538
+4856
+1250
+1917
+4852
+4792
+7407
+3413
+7326
+7378
+1778
+
+1659
+3390
+2802
+3226
+3993
+9583
+6504
+3296
+5998
+
+1800
+1144
+2569
+4426
+5871
+4988
+1309
+2330
+3236
+3217
+3778
+2636
+3116
+2300
+1428
+
+69249
+
+6905
+2506
+2429
+3904
+2960
+1420
+2687
+7150
+1368
+4253
+3584
+1302
+
+9585
+34214
+
+5442
+8217
+2320
+6864
+1354
+5791
+5492
+4979
+1760
+7753
+
+18036
+11876
+1936
+4605
+
+10819
+13733
+13726
+10233
+
+5450
+4315
+3008
+3419
+5434
+1601
+6834
+2144
+3943
+3573
+6366
+6680
+1197
+
+3681
+4233
+3461
+1646
+5161
+3542
+5489
+4635
+1776
+4811
+3026
+4858
+4207
+5716
+4751
+
+3271
+5205
+7916
+7618
+8354
+4445
+4604
+
+2489
+7439
+6911
+5378
+7363
+2207
+7303
+4757
+5989
+4902
+6889
+5074
+
+4451
+34499
+
+6519
+7439
+2225
+1237
+2167
+2041
+3403
+8289
+3545
+2936
+
+25613
+23988
+15999
+
+10278
+9240
+8736
+10445
+5005
+9339
+9059
+9198
+
+14821
+8000
+15113
+10430
+11981
+
+2745
+6427
+3564
+3822
+1674
+6615
+4817
+5026
+6243
+5295
+4027
+4861
+6554
+
+24901
+7628
+
+10299
+8153
+3359
+5982
+5207
+4491
+5267
+5364
+
+7962
+12190
+1998
+10722
+2890
+
+27425
+19199
+
+5347
+3738
+2833
+12747
+6505
+3476
+
+2360
+6688
+11640
+13899
+
+5152
+4272
+7284
+3491
+4225
+3271
+7751
+6376
+2695
+
+8227
+7171
+3366
+1663
+4466
+2444
+7239
+3673
+5321
+6363
+
+6362
+4237
+7358
+1723
+7514
+5741
+2621
+4413
+5502
+5875
+
+13451
+12610
+8672
+2841
+
+1956
+3310
+3011
+2938
+5046
+4571
+3326
+2013
+5980
+5145
+3226
+5073
+3676
+2763
+4542
+
+4200
+9203
+6238
+9501
+3972
+6776
+2730
+6126
+
+13151
+2622
+2592
+10013
+10227
+4677
+
+3151
+2107
+7564
+3219
+1353
+7924
+7287
+3273
+2117
+4211
+
+6914
+1354
+3517
+1835
+1694
+4044
+2569
+4755
+6720
+1104
+
+10704
+2576
+2773
+9002
+3321
+9443
+8346
+9054
+
+4584
+2075
+3303
+2156
+1250
+4717
+1391
+2977
+3845
+1433
+3112
+5675
+6058
+1451
+5500
+
+8712
+8235
+2732
+5337
+11076
+9434
+1593
+
+27831
+3385
+
+1497
+7378
+3442
+1957
+2620
+2208
+3808
+1793
+1306
+6721
+4098
+5050
+
+3197
+1377
+2289
+7534
+8484
+5831
+3671
+2524
+6756
+
+24827
+5119
+
+1701
+5156
+3625
+2469
+5728
+5698
+4538
+1505
+1475
+3934
+3758
+5405
+1549
+5019
+1433
+
+12606
+14593
+14761
+12375
+
+9284
+16208
+6022
+5550
+
+8956
+1473
+10077
+2220
+7314
+3561
+6013
+
+1064
+1538
+3292
+3854
+3882
+6008
+5364
+4326
+1958
+4712
+3389
+4496
+5501
+2181
+1666
+
+2424
+5342
+11963
+1108
+6698
+7440
+4334
+
+7167
+3677
+4923
+9204
+4469
+5934
+6071
+8355
+
+4457
+2779
+5014
+6156
+7431
+1879
+2349
+4038
+7353
+1453
+6980
+1890
+
+1348
+8892
+13667
+2877
+9049
+8967
+
+7904
+6871
+7301
+7952
+5953
+7562
+3289
+6654
+
+13903
+9705
+11858
+7619
+12963
+5629
+
+31307
+5533
+
+1431
+5521
+3430
+4972
+4077
+1771
+2134
+2614
+1464
+1882
+1471
+2024
+4789
+4419
+
+8927
+9768
+1070
+12640
+3597
+5034
+
+4369
+5821
+4181
+2802
+6503
+2530
+1530
+1047
+3537
+2732
+5169
+4156
+4348
+1831
+
+9491
+6837
+3855
+2320
+1689
+3393
+6974
+5192
+9255
+
+2791
+3416
+2183
+2919
+3732
+3010
+5213
+7927
+4855
+4468
+
+7089
+36535
+
+9669
+2139
+10069
+7918
+9942
+1446
+
+4381
+3053
+3216
+4395
+2710
+3329
+2837
+1395
+3310
+1598
+1620
+6310
+3405
+4005
+
+3639
+1485
+5221
+5767
+2415
+5401
+4011
+3377
+2977
+6529
+1921
+5012
+4426
+
+4202
+17425
+
+1350
+1077
+4747
+1735
+4362
+6110
+5006
+8519
+7785
+
+10393
+3532
+4113
+8856
+11626
+7552
+11220
+
+8925
+8081
+2340
+2296
+9558
+6452
+3604
+8601
+1958
+
+4519
+2675
+1343
+4853
+5372
+2362
+4274
+4636
+3144
+5231
+4867
+5533
+1505
+5978
+1649
+
+4955
+6133
+6469
+5120
+4257
+3936
+3661
+4995
+6040
+2616
+5863
+6886
+1653
+
+4106
+1467
+2641
+1772
+4588
+1750
+1333
+4312
+4852
+1508
+5620
+4535
+3888
+4007
+2194
+
+27508
+
+10203
+6474
+2054
+11285
+12800
+
+10249
+7004
+6396
+1990
+5883
+9275
+4687
+
+22359
+8260
+9536
+
+2657
+6895
+4538
+4635
+1259
+1819
+2679
+3703
+6127
+4197
+4009
+4652
+2708
+
+49278
+
+16243
+33427
+
+5219
+3052
+4510
+9946
+5429
+5163
+2653
+
+4676
+5247
+6267
+2648
+1257
+2335
+3737
+1443
+2726
+2361
+2134
+1952
+1021
+1753
+
+4671
+7281
+8217
+6170
+1182
+8778
+5289
+5035
+
+6067
+3461
+7448
+2117
+8702
+2849
+9659
+1410
+9402
+
+10607
+5652
+3127
+5594
+2423
+2591
+
+2138
+4007
+6383
+5597
+3074
+5811
+2178
+6220
+2212
+4271
+5410
+6677
+
+5313
+5507
+7753
+5492
+5041
+4967
+7644
+10538
+
+2062
+7568
+1439
+1621
+8216
+4952
+4358
+3391
+4776
+
+4015
+4854
+2935
+5177
+2131
+5192
+3300
+3337
+5223
+6469
+6101
+3917
+3492
+3986
+
+8942
+9447
+6152
+2764
+6196
+3116
+6478
+9334
+9346
+
+10560
+5894
+12105
+4239
+4573
+
+1752
+6751
+3684
+2236
+6195
+11108
+5450
+
+32451
+29152
+
+13915
+7001
+11778
+2626
+3026
+12725
+
+6410
+4265
+10923
+9587
+7411
+
+4943
+5272
+2453
+7324
+3815
+6049
+2936
+5905
+3187
+3675
+3860
+7143
+
+58413
+
+6544
+11733
+11746
+3288
+5411
+5555
+3796
+
+4852
+6567
+1494
+4644
+6183
+2444
+5145
+1015
+5088
+7905
+6491
+
+3550
+5679
+4312
+2128
+2262
+3597
+2249
+2472
+4758
+3927
+5369
+2278
+
+1399
+3791
+4817
+13948
+10037
+6154
+
+7877
+16900
+10571
+18965
+
+4836
+5457
+6380
+4241
+4969
+3635
+4160
+5451
+6164
+5334
+
+4961
+2514
+1620
+2494
+6373
+4040
+7544
+2595
+2330
+6927
+7906
+
+8023
+6672
+3565
+9038
+7154
+5236
+
+4297
+3122
+4779
+3937
+3165
+5012
+1298
+5405
+6175
+3862
+3469
+3533
+5411
+6349
+
+36291
+32851
+
+7992
+4095
+4841
+6728
+2275
+1549
+8143
+8494
+7144
+5800
+
+3064
+1314
+4224
+5969
+2913
+2622
+4833
+3113
+3663
+5351
+5102
+2930
+6048
+5658
+4773
+
+1771
+9851
+9844
+4001
+1343
+6124
+3826
+7647
+
+8488
+7700
+19028
+2822
+
+4541
+6311
+6499
+1043
+5888
+2631
+3824
+3137
+6957
+1372
+1755
+5852
+4944
+
+7010
+7705
+7380
+5693
+6466
+2388
+4584
+1309
+5295
+4232
+
+8997
+11222
+12715
+13341
+
+3389
+5375
+6730
+1723
+4179
+6599
+8482
+9599
+8903
+
+1774
+6964
+3739
+6345
+4881
+5381
+2415
+7900
+8778
+
+10638
+20181
+4651
+
+11271
+3243
+11634
+2919
+8121
+9706
+7354
+
+2675
+2809
+5554
+4439
+1626
+4173
+4273
+2551
+2302
+4167
+1929
+
+2641
+1264
+2074
+8265
+1089
+5010
+2591
+5610
+4610
+
+8082
+11994
+3820
+2770
+9252
+3948
+7731
+
+9429
+7117
+13052
+8925
+1844
+11783
+
+1288
+5874
+3708
+4770
+6241
+1823
+2081
+4040
+1675
+3309
+
+6185
+5449
+1262
+4549
+5293
+4790
+1854
+4853
+1727
+5514
+5256
+4148
+5514
+
+6609
+15270
+13973
+10316
+
+8083
+8381
+4788
+1606
+5118
+1520
+8152
+2433
+2999
+1784
+
+1178
+5284
+8781
+5156
+6160
+1957
+3163
+5129
+
+6123
+8854
+2776
+8899
+1728
+1459
+6248
+1676
+6804
+
+11240
+11672
+1993
+12007
+
+11441
+8463
+3348
+3292
+6021
+
+3765
+7412
+2551
+3571
+2806
+3018
+7255
+4727
+1812
+5666
+
+1111
+7513
+4547
+8423
+6838
+8520
+5818
+7891
+7659
+1029
+
+21630
+17117
+
+4790
+2925
+1959
+7089
+5283
+6020
+2522
+2052
+1519
+1591
+
+6012
+10136
+10443
+7841
+6019
+1279
+3540
+9068
+
+3937
+12491
+9763
+7498
+1701
+
+11876
+9043
+4713
+2987
+8774
+11370
+
+4885
+5614
+2665
+7454
+1350
+1832
+8687
+9477
+
+10654
+8624
+6594
+13129
+10246
+
+25357
+10959
+23864
+
+2554
+4768
+6464
+2757
+1927
+1861
+2175
+2322
+4198
+4037
+4752
+2082
+6003
+5328
+
+1820
+4090
+7653
+2160
+3455
+2144
+12128
+
+29265
+30377
+
+2359
+3949
+6123
+2235
+4210
+5808
+2377
+6678
+2039
+1324
+2104
+5407
+
+1955
+4478
+3696
+6486
+2206
+3083
+2843
+5454
+4294
+3972
+2556
+5795
+3319
+2315
+
+6188
+1383
+3880
+3153
+5842
+3400
+5504
+1353
+1257
+3639
+
+5550
+5255
+4095
+3951
+3104
+2344
+4580
+3980
+1482
+2521
+2764
+1607
+5699
+2350
+1175
+
+3326
+5681
+5905
+7268
+6083
+1407
+1434
+3186
+5744
+6268
+5533
+2245
+
+2994
+1141
+10449
+6013
+5210
+8014
+3136
+8434
+
+28983
+19936
+
+4560
+8754
+6220
+12071
+5989
+2858
+6333
+
+1928
+22562
+
+3804
+7720
+6499
+7651
+1860
+1193
+8243
+2693
+2515
+4517
+
+2762
+1303
+5390
+4371
+2424
+5039
+5875
+1354
+4039
+1883
+1398
+5544
+3698
+
+1312
+5037
+2534
+3404
+3494
+5859
+7520
+3173
+4187
+5593
+4094
+
+1938
+4558
+3961
+8752
+6733
+8402
+2351
+7059
+
+4650
+5453
+5251
+2503
+7601
+6322
+7193
+3568
+6734
+1254
+7263
+
+15442
+18712
+
+2671
+34633
+
+8092
+6200
+3593
+12427
+11897
+5342
+
+12145
+20778
+25515
+
+4318
+7326
+6324
+3726
+6176
+2530
+4017
+5504
+2930
+4978
+1941
+3893
+
+7431
+2579
+2463
+5818
+2616
+7477
+8840
+2943
+
+28974
+26077
+
+4317
+2950
+2298
+4360
+2323
+5028
+6040
+1223
+2836
+5338
+6002
+4551
+4505
+1046
+5007
+
+5979
+1142
+5901
+4646
+5486
+5184
+6255
+1473
+6420
+5358
+2502
+4997
+6331
+5529
+
+3641
+1705
+3924
+3952
+3856
+4687
+4962
+3754
+2049
+5361
+5286
+4157
+5753
+2937
+1996
+
+9825
+2077
+12304
+8296
+
+5576
+4979
+5746
+3423
+1339
+5466
+2956
+3201
+4612
+5538
+4957
+3095
+3211
+
+6162
+6797
+12282
+3848
+14760
+
+8520
+6433
+5529
+5617
+4572
+2395
+3228
+6012
+
+36432
+12115
+
+3396
+3826
+2514
+5297
+5768
+4673
+6134
+2153
+4533
+5530
+2289
+3910
+3429
+6315
+
+9288
+7564
+2801
+7672
+3580
+6425
+5047
+9141
+
+6455
+4624
+7937
+6151
+9671
+2857
+
+5789
+7291
+3051
+4587
+4527
+5970
+5863
+
+7496
+2170
+3522
+1108
+4284
+1214
+5981
+4240
+4880
+2816
+3638
+
+1458
+4890
+4046
+5337
+6192
+3705
+1362
+3330
+3593
+1036
+3842
+6485
+2170
+1176
+
+4669
+7457
+3290
+1471
+1471
+4983
+8120
+3964
+2012
+
+12196
+12907
+1360
+2359
+4034
+12061
+
+2023
+2376
+4602
+2529
+2091
+7266
+3696
+4104
+7007
+4183
+2551
+4913
+
+12264
+2297
+16633
+19219
+
+5963
+5584
+1534
+6499
+5988
+1160
+5186
+4313
+4579
+2978
+6075
+5821
+3288
+
+2456
+1103
+2492
+1484
+3089
+2519
+2596
+3462
+4707
+2403
+5042
+2345
+1841
+3924
+3674
+
+15955
+14482
+19975
+7828
+
+7686
+33030
+
+9367
+6387
+4450
+1301
+6652
+
+2436
+8020
+9634
+1189
+
+13768
+4937
+6445
+2333
+8688
+2282
+
+2632
+2386
+1540
+1313
+5560
+3191
+3768
+6455
+1771
+5707
+6503
+3702
+2690
+6410
+
+4254
+9381
+10720
+6622
+4502
+3229
+
+10702
+25975
+21218
+
+1824
+3787
+1017
+3211
+1954
+3263
+1654
+5116
+5383
+6081
+5917
+3708
+3770
+3332
+1564
+
+8659
+
+1918
+13752
+13443
+2032
+8928
+
+8167
+4650
+4066
+8487
+5484
+2973
+1974
+8716
+3918
+6829
+
+8569
+4604
+3930
+4567
+15587
+
+8510
+8686
+2757
+10057
+2681
+7895
+6610
+10350
+
+27009
+
+3554
+8125
+6661
+1517
+1293
+6747
+3910
+4998
+3100
+
+58602
+
+2960
+5646
+4133
+3192
+5660
+3224
+4699
+6106
+4147
+4855
+1950
+1195
+5861
+3613
+5095
+
+2481
+11509
+
+9922
+2887
+1722
+10604
+6329
+6330
+3934
+5424
+
+7492
+6265
+3838
+8041
+6266
+4794
+2524
+6684
+2734
+7338
+
+6263
+8780
+6447
+20087
+
+6388
+9789
+4219
+6199
+1753
+7765
+2130
+5475
+
+6043
+4380
+7928
+3807
+5877
+1736
+6191
+4348
+5699
+2381
+
+2683
+4364
+6323
+2128
+3828
+1657
+3885
+3426
+6137
+4427
+2592
+6245
+6142
+5680
+
+4812
+8631
+7556
+6549
+4494
+7671
+2664
+3702
+3551
+1289
+
+8546
+
+5793
+8055
+4733
+3781
+4359
+1127
+5052
+7333
+1533
+3232
+6713
+
+9850
+
+6386
+8256
+12527
+10704
+11625
+6314
+
+36312
+9909
+
+2500
+5131
+12716
+2449
+10252
+2989
+
+10080
+7372
+4650
+4148
+1543
+7025
+4075
+5975
+
+6493
+1969
+3498
+5752
+5231
+5688
+3805
+2245
+3355
+7015
+2001
+1980
+
+5498
+10487
+6072
+5136
+4464
+1645
+
+5765
+1637
+4963
+3317
+2151
+4765
+4234
+4268
+3791
+1371
+5906
+5800
+4684
+5872
+1032
+
+7693
+5165
+3321
+7593
+6652
+4856
+7244
+3238
+5442
+6728
+
+8940
+2746
+4620
+4575
+1794
+8580
+6018
+1198
+2470
+
+10302
+5070
+4341
+2533
+4345
+11497
+
+11333
+1604
+6233
+6784
+5614
+10283
+5386
+
+2715
+3782
+4739
+5782
+3541
+3544
+3591
+4748
+7392
+3361
+5764
+6413
+
+9117
+1201
+6914
+1214
+3645
+3711
+1825
+10249
+
+4719
+8388
+1460
+4555
+1038
+8967
+2147
+2943
+
+3372
+3381
+3607
+5180
+2115
+1071
+2218
+5102
+3133
+5809
+3920
+2758
+1729
+2132
+
+1332
+6802
+5791
+3281
+6624
+1692
+5105
+5160
+3082
+6840
+1613
+4749
+
+5211
+2825
+6050
+2913
+2542
+2466
+2411
+2101
+5822
+1972
+3409
+2738
+5032
+5715
+
+8421
+5749
+1746
+1424
+4398
+5048
+1450
+2122
+7937
+4488
+
+17962
+
+1415
+5018
+11466
+17007
+
+8818
+9115
+4789
+1919
+8398
+3807
+
+13697
+10141
+5675
+2146
+1954
+6312
+
+8363
+2872
+1505
+7354
+1868
+3313
+6657
+3468
+7434
+
+2157
+2904
+3745
+6707
+4194
+2956
+5377
+3130
+7664
+7595
+7477
+
+22149
+
+5662
+4865
+5971
+6008
+6761
+5764
+4321
+1546
+1705
+6056
+3990
+3953
+
+7794
+1246
+5418
+2460
+7858
+6992
+5897
+3459
+2915
+2227
+1517
+
+7873
+3664
+6050
+9000
+8922
+8817
+4514
+
+20975
+
+4983
+11133
+4400
+6751
+2763
+2781
+11806
A => day1/src/main.rs +39 -0
@@ 1,39 @@
+use std::collections::BinaryHeap;
+use std::fs::File;
+use std::io::{self, BufRead};
+use std::path::Path;
+
+fn main() {
+ let mut current_count = 0;
+ let mut heap = BinaryHeap::new();
+
+ if let Ok(lines) = read_lines("./input.txt") {
+ for line in lines.into_iter().flatten() {
+ match line.parse::<i32>() {
+ Ok(calories) => {
+ // Sum consecutive lines
+ current_count += calories;
+ }
+ Err(_) => {
+ // Empty line, push the sum to the heap
+ heap.push(current_count);
+ current_count = 0;
+ }
+ }
+ }
+ }
+
+ let max = heap.peek().expect("Failure peeking the heap");
+ println!("Elve carrying the most calories: {}", max);
+
+ let max3: i32 = heap.into_sorted_vec().into_iter().rev().take(3).sum();
+ println!("Top three elves carrying the most: {}", max3);
+}
+
+fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
+where
+ P: AsRef<Path>,
+{
+ let file = File::open(filename)?;
+ Ok(io::BufReader::new(file).lines())
+}