aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Linares <matias@deprecated.org>2023-12-03 15:11:37 -0300
committerMatias Linares <matias@deprecated.org>2023-12-03 15:11:37 -0300
commitd073dcaa66567e58d6f9a36b15c9e54b91ed8c54 (patch)
treeb26480988df75847eba75892bdf33089ec08bcd7
parent129ac460f73972097700ad2def6b4c36d6ebe6e1 (diff)
downloadadvent-of-code-d073dcaa66567e58d6f9a36b15c9e54b91ed8c54.tar.gz
Add 2022 and 2023
-rw-r--r--.gitignore3
-rw-r--r--2022/day1.rb48
-rw-r--r--2022/day1.txt2244
-rw-r--r--2022/day2-test.txt3
-rw-r--r--2022/day2.rb116
-rw-r--r--2022/day2.txt2500
-rw-r--r--2022/day3.rb63
-rw-r--r--2022/day3.txt300
-rw-r--r--2022/day4-test.txt6
-rw-r--r--2022/day4.rb36
-rw-r--r--2022/day4.txt1000
-rw-r--r--2022/day5.rb43
-rw-r--r--2022/utils.rb10
-rw-r--r--2023/day-01/Cargo.lock7
-rw-r--r--2023/day-01/Cargo.toml8
-rw-r--r--2023/day-01/src/bin/input.txt1000
-rw-r--r--2023/day-01/src/bin/part1.rs44
-rw-r--r--2023/day-01/src/bin/part2.rs86
18 files changed, 7516 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 546cb48..8f39b4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-.precomp \ No newline at end of file
+.precomp
+target/ \ No newline at end of file
diff --git a/2022/day1.rb b/2022/day1.rb
new file mode 100644
index 0000000..f7a7c24
--- /dev/null
+++ b/2022/day1.rb
@@ -0,0 +1,48 @@
+
+
+TEST_S = <<-TEST
+1000
+2000
+3000
+
+4000
+
+5000
+6000
+
+7000
+8000
+9000
+
+10000
+TEST
+
+def elves_food(input_str)
+ return input_str.split(/^$/).map do
+ |elf_rations|
+ elf_rations.strip.split("\n").map(&:to_i)
+ end
+end
+
+def calories_by_elf(input_str)
+ elves_food(input_str).map(&:sum)
+end
+
+def max_calories(input_str)
+ calories_by_elf(input_str).max
+end
+
+def top_3_calories(input_str)
+ calories_by_elf(input_str).sort.reverse.take(3).sum
+end
+
+def day1
+ File.open('day1.txt') do |f|
+ input_str = f.read
+ puts "part1: #{max_calories(input_str)}"
+ puts "part2: #{top_3_calories(input_str)}"
+ end
+end
+
+day1()
+#puts elves_food(TEST_S)
diff --git a/2022/day1.txt b/2022/day1.txt
new file mode 100644
index 0000000..29d80bf
--- /dev/null
+++ b/2022/day1.txt
@@ -0,0 +1,2244 @@
+5474
+4920
+5381
+8650
+11617
+7193
+8161
+
+10747
+5855
+13827
+6294
+13437
+8125
+
+6913
+6443
+3431
+5357
+1579
+3590
+4471
+4971
+4055
+4937
+2514
+1679
+2917
+
+4203
+4433
+8798
+5838
+2031
+8765
+5107
+6055
+2482
+6266
+
+4646
+4705
+5183
+1707
+3676
+2042
+4140
+3321
+1899
+3055
+3327
+3944
+3879
+2981
+
+59238
+
+11748
+22005
+
+6389
+4630
+1443
+14530
+9588
+
+10578
+8843
+10344
+6289
+10444
+7615
+9510
+
+9351
+3942
+5896
+4692
+10110
+4125
+1161
+8261
+
+22239
+
+5485
+1528
+1288
+4749
+3742
+5861
+2418
+5901
+5201
+1695
+4640
+4609
+3717
+5597
+4183
+
+6675
+4543
+3795
+2873
+6364
+2320
+4087
+5536
+7235
+2206
+6179
+4316
+
+2755
+6991
+3129
+7988
+3124
+4657
+6947
+4511
+3345
+4043
+6322
+
+8053
+5068
+3647
+8695
+6724
+8679
+6974
+4379
+6785
+
+7345
+3825
+3850
+4237
+2168
+5866
+2329
+3006
+2966
+3778
+1635
+4083
+
+8997
+7386
+3721
+6526
+9222
+2248
+1079
+4470
+2870
+
+3780
+4795
+6084
+3682
+4147
+4840
+1603
+3949
+7023
+3175
+
+3438
+2545
+2816
+6367
+6068
+1782
+2026
+5115
+5648
+5239
+3530
+5553
+3809
+1891
+
+6970
+4195
+3109
+3953
+9504
+5121
+6159
+3932
+
+5045
+22725
+
+2633
+6392
+4433
+4789
+4593
+3043
+2935
+6540
+7966
+6176
+7759
+
+6551
+7220
+2325
+6230
+2058
+6931
+7107
+3393
+4448
+2157
+7172
+2699
+
+43804
+
+9649
+
+4126
+3911
+4619
+13049
+
+4094
+5564
+6038
+1736
+2035
+7064
+5449
+3542
+6245
+5280
+4870
+3181
+
+5699
+4317
+2871
+3784
+6855
+5389
+3538
+1374
+7930
+6761
+6756
+
+8427
+4122
+1938
+8024
+1572
+4399
+1371
+1945
+1475
+5936
+
+4158
+8074
+3978
+12335
+4192
+1983
+
+7331
+3052
+5007
+7331
+6303
+3832
+4584
+6628
+4574
+3994
+6504
+7166
+
+5045
+1220
+6070
+1942
+2263
+3916
+1936
+1557
+4652
+3224
+2866
+1448
+1261
+5803
+
+8695
+10505
+8608
+11934
+9221
+3064
+9944
+
+3497
+6215
+4573
+6966
+3312
+7874
+5739
+2775
+7394
+1896
+
+8484
+6106
+7125
+10399
+4310
+3978
+8000
+3698
+
+2462
+4167
+5607
+2518
+2013
+5458
+5439
+4152
+4061
+2246
+1349
+5429
+4122
+3370
+1401
+
+6994
+5598
+4181
+11620
+7973
+2680
+
+16039
+23774
+
+3915
+1933
+2725
+5159
+5433
+5165
+5447
+1291
+1851
+5476
+3464
+3070
+
+3511
+10497
+2941
+9581
+10220
+9369
+3517
+8319
+
+11067
+4795
+9788
+6321
+9229
+5678
+3344
+
+7639
+7865
+2566
+9034
+1333
+4160
+9017
+5958
+
+7565
+5227
+7692
+6780
+2290
+10189
+3257
+6345
+
+3910
+8187
+7800
+4521
+1055
+6494
+6879
+6508
+3778
+2576
+
+1160
+7168
+7118
+7138
+5054
+2319
+1581
+5235
+6430
+2877
+2511
+2595
+
+5449
+1604
+8598
+8992
+5251
+7608
+2606
+2404
+
+4494
+1614
+12591
+
+4105
+6805
+2299
+1368
+6970
+2029
+2567
+2055
+4073
+3090
+5666
+3796
+
+11914
+10997
+7550
+5656
+
+18298
+5479
+
+4700
+1779
+6303
+4671
+2275
+3101
+1835
+3928
+2480
+3402
+4974
+5518
+1507
+5891
+
+17354
+19903
+19827
+
+6309
+4879
+4247
+4723
+1826
+3124
+6153
+4359
+5103
+5449
+3834
+4751
+5939
+3534
+
+8210
+14642
+3626
+8654
+7933
+
+12463
+2202
+9518
+5869
+5003
+
+21437
+
+1303
+5025
+7398
+2518
+6070
+7001
+8240
+4130
+4486
+2590
+
+2211
+4296
+6216
+5870
+6871
+3508
+2504
+2898
+3048
+3381
+3879
+6604
+3057
+
+2476
+4145
+8294
+5106
+9531
+5254
+1495
+1765
+
+4592
+1366
+5153
+5189
+5896
+5331
+5104
+2438
+1725
+4846
+1744
+2251
+2769
+4181
+1189
+
+8345
+13849
+7806
+11279
+
+2950
+4805
+1549
+4468
+5550
+5136
+1311
+3073
+3482
+1175
+5151
+2011
+4116
+4405
+3581
+
+2616
+6472
+4229
+2306
+1079
+1132
+5062
+6279
+2972
+1437
+5100
+2270
+3377
+1256
+
+7703
+4334
+3700
+3586
+2980
+8040
+5481
+6456
+2284
+2481
+7518
+
+7767
+3145
+1131
+6374
+2591
+1952
+2915
+6288
+
+17556
+1308
+2244
+11329
+
+5138
+18453
+24805
+
+4253
+2926
+5747
+2324
+5486
+4747
+6081
+3244
+1015
+3443
+2086
+2016
+1409
+5915
+1805
+
+5662
+3866
+4336
+3394
+2257
+4012
+2404
+4649
+4156
+3460
+4337
+5928
+2710
+
+1811
+4065
+4708
+1579
+1360
+7071
+3771
+4071
+3152
+1427
+4361
+5013
+
+52242
+
+6035
+2981
+1824
+4305
+1253
+3804
+3713
+5411
+4316
+5945
+1503
+4619
+3873
+1063
+
+8966
+2393
+5007
+2992
+8306
+2947
+10127
+6760
+
+5101
+6156
+6344
+1093
+6575
+6010
+1179
+2699
+8234
+8433
+
+25118
+27329
+
+9532
+10745
+11456
+5346
+3371
+8674
+6338
+
+11164
+6281
+6275
+3805
+3989
+3109
+10478
+
+15795
+14646
+
+9248
+4268
+13365
+6711
+5210
+3359
+
+4367
+5811
+1444
+2920
+5074
+4213
+5135
+1109
+4701
+2615
+3108
+3748
+4670
+3620
+5180
+
+1743
+2512
+4737
+6125
+6136
+2268
+2643
+1225
+6937
+3774
+2550
+1160
+
+4159
+10506
+17904
+
+1183
+3045
+2677
+3989
+5062
+1507
+5918
+5291
+3473
+3949
+4145
+4949
+4775
+3148
+
+6473
+6375
+1013
+6653
+6193
+4437
+2192
+2663
+
+3145
+9517
+5339
+7768
+10803
+5365
+
+1120
+3384
+5420
+6699
+7252
+1922
+6063
+6993
+7110
+1062
+5206
+3326
+
+3235
+3681
+3647
+2771
+1608
+1299
+1037
+2665
+2285
+6054
+3787
+6019
+1867
+2501
+
+2116
+2641
+6185
+2165
+5765
+1674
+4516
+3426
+4773
+6586
+1914
+6492
+6193
+
+2417
+5222
+2764
+3045
+1511
+3873
+5328
+4941
+4189
+5083
+2969
+2534
+1666
+1733
+5940
+
+7351
+4465
+13541
+2200
+12798
+11321
+
+32442
+
+17392
+2823
+10314
+3495
+
+4737
+4570
+3856
+2588
+3135
+3661
+3884
+5635
+5842
+1983
+2290
+5140
+2252
+4826
+5424
+
+1666
+8670
+6408
+8258
+2038
+11212
+
+7026
+7262
+5520
+7613
+10233
+4683
+9874
+5205
+
+6451
+1335
+16980
+1986
+
+7472
+10701
+3953
+3512
+9189
+5675
+5285
+1085
+
+6673
+4260
+7698
+1171
+5686
+4966
+4824
+2941
+3847
+3968
+
+2927
+6876
+6839
+1336
+6843
+5907
+1013
+6284
+2354
+2037
+4355
+4735
+2470
+
+11642
+3298
+7526
+8973
+1752
+9609
+9415
+
+7862
+24260
+
+13115
+12552
+9965
+9011
+4189
+10063
+
+4678
+5279
+1173
+4347
+1102
+1067
+7067
+7598
+5114
+3247
+
+11741
+9531
+5821
+3624
+1064
+6312
+3099
+
+17369
+
+2453
+6099
+2945
+5136
+3273
+2295
+4925
+5956
+1280
+
+1443
+1787
+2042
+8898
+3387
+2391
+6857
+5622
+
+6594
+3937
+1178
+4172
+7356
+7296
+7497
+2169
+1673
+3993
+5546
+
+25269
+15637
+21519
+
+10437
+4102
+6545
+
+2996
+4277
+2063
+2577
+3304
+3240
+5948
+3754
+3940
+4706
+4258
+5636
+2857
+4082
+4082
+
+18222
+19780
+10272
+
+5915
+
+5612
+2789
+2367
+5086
+5148
+5115
+7196
+2378
+1394
+2072
+3440
+4135
+
+35104
+
+3238
+1135
+1210
+2747
+5793
+7097
+3327
+3438
+6990
+3218
+6635
+2945
+
+2247
+5037
+2112
+3768
+1817
+4538
+3236
+1070
+2146
+1813
+1567
+6025
+2533
+1134
+1320
+
+2305
+4606
+4812
+3568
+4712
+4459
+4131
+4079
+4008
+3131
+1264
+1684
+5296
+2945
+
+1255
+1633
+4774
+5707
+1349
+1660
+1549
+3965
+3511
+1791
+3535
+2568
+6598
+
+4756
+7488
+2222
+2964
+4150
+5175
+4198
+8641
+5103
+
+2689
+16286
+12088
+10520
+
+4714
+21793
+17571
+
+4388
+2535
+3284
+3574
+1322
+3532
+3505
+3713
+6261
+6430
+4673
+1695
+1169
+
+59355
+
+20855
+1036
+20325
+
+3231
+2285
+7377
+4182
+9866
+1502
+7341
+
+3151
+3745
+15911
+4525
+6796
+
+10285
+3489
+6159
+1484
+1735
+5194
+6943
+3763
+
+2654
+4389
+3639
+5386
+2078
+3240
+3504
+8137
+2330
+8406
+
+13627
+7144
+6062
+11288
+
+21671
+15167
+8981
+
+1199
+8578
+5102
+4529
+8070
+7573
+6499
+5155
+5134
+3510
+
+3364
+6004
+3899
+6417
+3007
+5581
+4427
+5193
+1580
+6498
+4366
+3702
+6294
+3007
+
+1086
+8177
+10586
+7787
+6042
+
+4367
+1320
+9290
+7230
+9666
+4239
+8803
+6955
+
+2626
+1542
+1131
+6190
+6719
+2764
+5729
+3631
+3914
+1309
+6531
+5590
+1387
+
+1214
+3796
+4620
+1037
+6851
+2733
+6705
+5377
+5788
+4926
+3923
+1757
+3696
+
+5645
+4859
+1827
+6117
+7432
+2787
+7137
+7504
+4120
+1430
+1522
+
+3825
+6622
+8375
+8555
+1702
+2360
+4444
+1853
+
+20697
+6984
+
+5947
+4046
+6449
+1564
+3754
+5339
+4165
+5954
+4398
+3271
+2567
+1454
+6060
+1108
+
+17518
+10791
+7556
+1902
+
+6547
+1011
+11291
+3886
+
+1673
+5267
+6948
+6577
+7606
+8357
+6414
+9057
+5283
+
+36117
+
+2334
+4192
+2967
+1160
+3335
+5893
+6342
+5954
+2462
+4028
+4035
+3816
+5167
+6094
+
+4025
+5106
+3876
+1689
+2168
+3504
+2819
+6809
+5580
+1549
+4401
+5305
+2889
+
+4919
+4789
+4604
+1647
+2305
+1223
+1621
+5273
+4101
+1318
+1514
+5766
+5749
+3943
+
+18068
+9720
+11242
+
+3190
+1497
+3700
+5345
+5117
+4089
+2584
+3740
+2397
+3541
+4534
+4403
+6257
+
+4822
+7295
+1000
+4766
+9612
+9061
+3549
+8036
+5254
+
+4816
+2187
+7269
+3500
+7150
+2797
+6007
+5651
+4702
+1385
+6393
+5128
+
+2347
+3149
+2773
+3877
+5619
+1646
+3363
+1888
+5203
+5155
+5974
+2030
+2149
+3530
+2745
+
+4694
+12004
+11089
+13235
+
+11269
+
+4700
+2437
+6297
+4951
+3798
+6109
+4249
+5262
+3972
+1493
+
+3293
+3333
+2306
+1234
+6389
+1929
+1012
+1477
+3691
+1235
+3846
+5286
+1164
+5630
+
+17541
+12819
+7368
+11983
+
+14008
+7610
+2321
+4581
+
+5345
+5511
+2483
+6155
+3052
+5151
+4224
+3992
+5566
+5275
+4539
+4762
+4804
+3673
+
+64454
+
+22960
+19989
+1512
+
+6252
+1835
+9984
+5671
+6357
+8737
+7341
+
+5374
+3434
+2008
+4744
+5277
+1394
+4515
+6327
+5656
+2721
+3005
+1197
+5579
+3661
+
+5886
+4591
+5003
+2309
+2703
+5984
+2750
+2332
+1005
+2374
+2945
+2250
+3844
+5665
+5016
+
+3269
+4501
+7712
+12368
+2929
+
+8015
+7817
+9884
+10257
+7097
+1024
+6910
+
+5184
+7911
+3112
+4284
+2879
+6177
+3740
+2243
+7722
+
+4643
+6279
+5081
+3030
+3991
+2642
+7422
+6341
+3712
+6022
+2953
+
+8182
+9540
+18188
+
+9292
+10077
+8619
+2367
+9770
+3540
+10220
+2537
+
+3230
+5748
+3491
+2382
+4803
+4477
+4706
+5688
+3872
+4854
+6934
+7327
+
+16115
+16116
+15926
+6134
+7828
+
+7192
+1734
+4498
+4311
+2682
+6019
+5482
+7073
+1602
+6751
+1106
+2314
+
+6320
+7703
+9059
+12137
+10057
+4961
+
+4306
+2143
+6775
+2805
+3338
+7133
+4619
+1323
+2753
+4504
+4366
+5334
+
+11176
+13348
+13834
+10124
+8084
+6286
+
+10338
+13150
+2090
+2260
+16428
+
+3667
+4251
+5278
+1111
+3667
+6833
+6846
+4346
+2118
+5830
+6642
+3730
+1700
+
+1037
+14507
+24258
+
+22776
+16783
+22796
+
+10555
+1425
+5032
+12069
+1108
+8152
+6623
+
+11535
+11922
+4903
+5397
+13421
+
+9869
+8664
+15110
+12589
+2301
+
+1319
+11885
+12142
+3267
+6484
+1285
+2595
+
+5648
+4703
+4074
+8048
+4128
+2197
+2947
+1737
+4032
+6999
+4374
+
+6043
+2635
+3457
+6893
+1769
+2808
+4858
+5987
+1193
+6061
+1197
+4169
+4939
+
+4043
+5938
+3483
+5056
+5921
+3376
+3972
+1843
+5401
+5469
+2972
+3421
+5129
+2949
+
+12561
+1792
+13583
+12678
+11790
+4781
+
+1868
+3636
+1727
+3229
+4396
+3926
+1960
+4131
+1766
+3644
+6156
+1321
+4685
+2702
+
+6193
+5733
+4709
+2502
+3684
+3363
+5916
+6806
+5483
+3767
+2544
+3000
+5196
+
+4345
+1107
+1363
+5707
+4533
+5183
+3248
+6589
+3008
+4193
+6416
+4727
+1464
+
+16694
+7689
+
+2805
+3717
+5326
+5676
+1663
+1680
+1151
+4131
+1223
+1542
+4191
+2587
+5529
+4681
+3736
+
+10132
+10116
+6576
+4908
+16381
+
+2310
+7296
+
+11429
+16310
+
+3801
+6942
+3366
+3915
+3903
+4342
+2289
+5429
+1211
+4237
+5688
+5023
+3319
+
+1234
+4811
+2311
+2590
+2857
+5111
+5063
+6350
+1887
+1814
+6092
+3694
+2758
+3712
+
+1830
+8120
+18551
+14964
+
+7427
+1702
+4265
+3065
+3409
+3845
+9418
+10394
+
+5947
+6853
+7006
+5538
+6218
+6167
+4825
+2838
+2073
+8061
+7418
+
+3077
+1132
+1171
+3570
+4467
+5666
+3306
+5859
+2191
+2986
+4212
+5046
+3082
+3918
+3539
+
+12352
+4933
+
+11214
+21828
+18790
+
+8150
+8051
+6399
+13321
+
+1077
+7138
+9996
+2474
+7483
+5220
+9358
+
+2352
+7906
+8887
+6549
+9471
+6563
+
+2408
+11061
+2717
+9936
+7232
+
+1143
+26201
+
+8453
+18884
+14705
+
+1102
+4208
+3159
+2913
+2163
+2493
+2202
+4092
+4944
+3844
+4740
+5584
+3073
+2325
+3359
+
+5448
+5487
+5685
+2776
+5432
+2527
+3483
+4295
+7162
+7033
+5512
+4802
+
+8890
+9904
+6114
+1416
+5791
+10383
+2333
+
+5420
+6696
+5120
+3503
+1975
+6025
+1966
+3962
+7988
+3808
+4725
+
+3407
+3897
+6234
+2085
+5141
+6526
+1296
+2371
+4846
+3129
+4258
+4951
+2549
+
+3491
+1833
+7754
+8425
+5132
+1799
+4950
+1499
+1791
+7778
+
+3416
+9251
+6111
+2067
+15697
+
+1560
+4056
+4203
+5915
+1118
+3442
+7843
+1986
+2318
+7247
+
+3266
+6672
+2491
+6089
+2403
+2038
+1581
+5163
+3657
+6090
+2392
+6109
+2091
+
+8674
+5107
+10708
+6044
+5193
+2111
+1706
+5666
+
+5933
+3537
+5456
+6595
+9018
+2113
+3778
+3638
+
+3741
+1940
+1603
+4061
+3986
+3414
+2327
+2173
+5594
+5598
+3974
+5162
+
+4947
+2765
+3017
+2598
+3841
+3663
+4664
+2519
+3969
+3721
+4100
+2463
+4616
+4553
+4986
+
+2809
+6051
+1262
+1163
+6129
+1501
+4798
+7401
+3929
+1077
+6108
+3232
+
+10252
+3877
+5596
+7696
+2683
+3182
+5335
+10338
+
+4390
+7767
+7735
+6771
+2291
+2887
+2884
+6444
+4270
+1721
+
+2939
+5140
+4955
+6308
+2891
+5405
+1775
+2275
+3153
+5569
+3769
+1229
+4394
+
+1677
+2258
+5447
+4017
+1478
+1334
+2354
+5847
+4433
+2973
+3691
+4900
+5785
+3571
+
+3573
+3512
+4014
+5627
+4750
+4273
+1428
+5189
+4971
+6104
+3301
+2558
+4522
+2924
+4828
+
+62151
+
+9293
+11550
+20431
+
+24683
+10913
+
+1939
+1487
+8441
+7821
+12802
+
+19163
+2462
+17788
+
+1390
+8446
+9351
+8697
+2520
+6065
+4574
+9621
+
+3357
+3779
+1786
+7387
+4334
+5856
+1186
+2309
+7374
+3244
+6129
+
+3096
+3130
+3634
+4227
+4453
+7400
+3889
+2310
+5974
+6357
+6352
+4975
+
+4281
+15698
+6045
+16109
+
+7835
+10597
+6334
+10543
+10680
+3210
+2302
+
+2740
+2418
+3629
+1099
+8802
+6407
+4369
+3978
+8454
+3646
+
+2051
+1323
+5425
+1715
+6173
+7524
+5259
+1006
+8445
diff --git a/2022/day2-test.txt b/2022/day2-test.txt
new file mode 100644
index 0000000..db60e36
--- /dev/null
+++ b/2022/day2-test.txt
@@ -0,0 +1,3 @@
+A Y
+B X
+C Z
diff --git a/2022/day2.rb b/2022/day2.rb
new file mode 100644
index 0000000..bc4ade5
--- /dev/null
+++ b/2022/day2.rb
@@ -0,0 +1,116 @@
+TEST_S = <<-EOF
+A Y
+B X
+C Z
+EOF
+
+def score(picked_item, outcome)
+ fail "Wrong picked item '#{picked_item}'" unless picked_item
+ outcome_score = case outcome
+ when :win
+ 6
+ when :draw
+ 3
+ when :lose
+ 0
+ end
+ picked_score = case picked_item
+ when /A|X/
+ 1
+ when /B|Y/
+ 2
+ when /C|Z/
+ 3
+ end
+ #puts "#{outcome_score} + #{picked_score}"
+ return outcome_score + picked_score
+end
+
+def guessed_strategy(line)
+ outcome_map = {
+ 'A X' => :draw,
+ 'A Y' => :win,
+ 'A Z' => :lose,
+ 'B X' => :lose,
+ 'B Y' => :draw,
+ 'B Z' => :win,
+ 'C X' => :win,
+ 'C Y' => :lose,
+ 'C Z' => :draw
+ }
+ return outcome_map[line]
+end
+
+def correct_strategy(item1, item2)
+ return :win if item2 == 'Z'
+ return :draw if item2 == 'Y'
+ return :lose if item2 == 'X'
+end
+
+def what_to_choose(oponent_shape, outcome)
+ case outcome
+ when :draw
+ return oponent_shape
+ when :win
+ case oponent_shape
+ when 'A'
+ return 'B'
+ when 'B'
+ return 'C'
+ when 'C'
+ return 'A'
+ else
+ fail "Don't know this shape '#{oponent_shape}'"
+ end
+ when :lose
+ case oponent_shape
+ when 'A'
+ return 'C'
+ when 'B'
+ return 'A'
+ when 'C'
+ return 'B'
+ else
+ fail "Don't know this shape '#{oponent_shape}'"
+ end
+ else
+ fail "Don't know this outcome '#{outcome}'"
+ end
+end
+
+def part1(filename)
+ score = 0
+ File.open(filename) do |f|
+ scores = f.readlines.map do |line|
+ item1, item2 = line.chomp.split()
+ outcome = guessed_strategy(line.chomp)
+ score(item2, outcome)
+ end
+
+ score = scores.sum
+ end
+ score
+end
+
+def part2(filename)
+ score = 0
+ File.open(filename) do |f|
+ scores = f.readlines.map do |line|
+ item1, item2 = line.chomp.split()
+ outcome = correct_strategy(item1, item2)
+ shape = what_to_choose(item1, outcome)
+ score(shape, outcome)
+ end
+
+ score = scores.sum
+ end
+ score
+end
+
+#puts part1('./day2-test.txt')
+#puts part1('./day2.txt')
+
+
+puts 'Part2'
+puts part2('./day2-test.txt')
+puts part2('./day2.txt')
diff --git a/2022/day2.txt b/2022/day2.txt
new file mode 100644
index 0000000..3914035
--- /dev/null
+++ b/2022/day2.txt
@@ -0,0 +1,2500 @@
+A Z
+A Y
+B X
+B X
+C X
+B X
+A X
+A X
+C X
+A X
+A X
+A Y
+B X
+A Y
+C X
+C X
+A X
+A Y
+C X
+B X
+A X
+B X
+A X
+A X
+B Y
+B Y
+A X
+A X
+A X
+A X
+A X
+A Y
+A X
+B X
+B Y
+A Y
+C Z
+C X
+A X
+A Y
+A X
+A X
+A Y
+A X
+A Y
+A X
+B X
+C X
+A X
+B X
+A X
+C X
+A Y
+B X
+B X
+A X
+A X
+C Y
+B X
+A X
+C X
+B X
+B X
+A X
+A X
+B X
+A Y
+C X
+A Y
+A X
+A X
+A Y
+B X
+A X
+A X
+A X
+B Y
+A X
+A X
+A Y
+A X
+A X
+B Y
+B Y
+B X
+C X
+B Y
+A X
+C X
+C X
+A Y
+A X
+A Z
+B X
+C X
+A Y
+B X
+A X
+A X
+A X
+A Y
+C X
+A X
+A Z
+A X
+A Y
+B Y
+A X
+C X
+B X
+A Y
+B Z
+B X
+C Y
+B X
+B Z
+A Y
+B X
+C X
+C Y
+A X
+A Y
+A X
+B X
+A Y
+B Y
+A X
+C Y
+A Y
+B Y
+A X
+B Y
+B X
+B Y
+A X
+B Y
+A X
+C Z
+A X
+C X
+A Y
+A X
+C X
+A X
+A X
+A X
+C X
+B Z
+A X
+B Y
+B X
+A Y
+A X
+A X
+B Y
+B Y
+A Y
+B X
+A X
+C Y
+A X
+C X
+A X
+A X
+A X
+A X
+A X
+C Z
+C X
+A Z
+C Z
+A X
+A Y
+B X
+C X
+B X
+B Y
+C X
+B X
+A X
+A X
+A X
+A Y
+B X
+B Y
+A X
+C X
+A X
+A X
+A X
+A X
+C Y
+A Z
+C X
+A X
+A Y
+B X
+A Y
+A X
+A Y
+A X
+A X
+A X
+A X
+A Y
+A X
+B X
+A X
+A X
+C Y
+C Y
+A X
+C X
+A X
+A X
+C X
+C X
+B Z
+B X
+B X
+A X
+A Y
+B Y
+A X
+A X
+C X
+C X
+C X
+B X
+C X
+B Y
+A X
+B Y
+B X
+B X
+A X
+B Y
+A Y
+C X
+B X
+C X
+A Y
+B X
+C X
+A X
+C X
+A X
+B Y
+A X
+A X
+B Z
+C X
+B X
+C X
+B X
+A X
+A X
+A X
+A X
+A X
+C X
+C X
+A X
+A Z
+A Y
+A X
+A X
+A X
+A X
+C Y
+C Y
+B Z
+A X
+A X
+B X
+B X
+A Y
+A X
+B Y
+A X
+B Y
+A X
+C Y
+C X
+A Y
+B Y
+C X
+A X
+A X
+A X
+A Y
+A X
+A X
+A X
+B Y
+B X
+C X
+C Y
+A Y
+A Z
+B X
+C X
+B X
+C X
+A X
+B Z
+B Y
+A X
+C X
+A Y
+B X
+B X
+A Y
+A X
+A X
+A Y
+A X
+B X
+A X
+A X
+C Y
+C Y
+A Y
+A Y
+B Y
+B Y
+B Y
+B X
+A X
+A Y
+B Y
+B X
+A Y
+A X
+A Y
+C X
+C X
+B Y
+A Y
+B Y
+A Y
+A X
+B Y
+B X
+C X
+A X
+A X
+A X
+B Y
+B X
+A X
+B Y
+A Y
+A X
+C X
+A X
+B Y
+A X
+A X
+B Y
+A Y
+A X
+C Y
+B Z
+A Y
+C X
+A Y
+A X
+B Y
+A X
+B Y
+B Y
+B X
+B X
+A X
+A X
+C X
+B Y
+B X
+C X
+B Y
+A X
+A X
+A X
+A X
+B Y
+C X
+B X
+A X
+A X
+A Y
+C Y
+A Y
+B X
+A X
+B X
+A X
+A Y
+B Y
+A X
+C X
+C X
+A Y
+B X
+C Y
+A Y
+B X
+A X
+A Y
+C X
+A X
+A X
+B Y
+A Y
+B X
+B Y
+B Y
+A X
+A X
+A X
+B Y
+A Y
+A X
+B X
+A Y
+A Y
+B X
+C Y
+A X
+A Y
+A X
+B X
+A X
+B X
+C Z
+A X
+A X
+B Y
+A X
+A X
+A X
+C Z
+C X
+A Z
+C Y
+B X
+A Y
+B X
+A X
+A Y
+A X
+C X
+A X
+A X
+C Y
+A Z
+C Y
+B Y
+B X
+B X
+A Y
+C X
+B X
+A Z
+A X
+A Z
+C X
+A X
+C Z
+C X
+B Z
+C Y
+B Y
+A X
+B Y
+A X
+A X
+C X
+B X
+A X
+C Z
+B Y
+B Y
+A Y
+B Y
+A X
+A X
+B Y
+A X
+A X
+C Y
+C X
+A X
+C Y
+C X
+B X
+B X
+A X
+B Y
+A Y
+A X
+B Y
+B Y
+B X
+B X
+A X
+B X
+B X
+B Y
+B Y
+C X
+B X
+B X
+A X
+A X
+A X
+A X
+A Y
+C Y
+A X
+A Y
+C Z
+A Y
+C X
+A X
+C Y
+A X
+A X
+A Y
+A Z
+A Y
+A Y
+A X
+A Y
+A Z
+C X
+C Z
+B X
+A X
+A X
+B X
+A X
+A X
+A X
+C X
+A X
+A Y
+A X
+A X
+A Y
+C Z
+C X
+A X
+A X
+A Z
+A X
+C X
+A Y
+C X
+A Y
+C X
+C X
+A X
+A X
+A Y
+B Y
+C X
+C X
+B X
+B Z
+B X
+B X
+A X
+C X
+A Y
+C X
+A Z
+B X
+B Y
+A Y
+A Y
+A X
+A Y
+A X
+A X
+A Y
+A X
+A X
+B Z
+A X
+A X
+A X
+B Y
+B Y
+C Z
+A Y
+A Y
+B Y
+A X
+B X
+C X
+C Y
+C X
+B X
+C X
+A Y
+A X
+A X
+B X
+C X
+B X
+A Y
+B X
+B Z
+A Y
+A X
+A Y
+B X
+B Z
+A X
+A X
+C X
+A X
+A Y
+A X
+B X
+A X
+A X
+A Z
+B X
+B Y
+C Y
+C X
+A Y
+A X
+B Y
+C X
+A X
+C Y
+A X
+A Y
+A Y
+A X
+A X
+C X
+C X
+A Y
+A Y
+C X
+A X
+B X
+C X
+B Y
+C Y
+C X
+B X
+B Y
+C X
+B X
+B Y
+A X
+A X
+B X
+A Y
+A X
+B X
+A X
+C Y
+A X
+B X
+A Y
+C Y
+A X
+A Y
+A Z
+C Z
+A X
+A X
+C X
+A X
+B X
+A X
+C X
+C X
+A Y
+A X
+C Y
+A Y
+A X
+B Y
+A X
+A Y
+A X
+C Z
+C Z
+C X
+A X
+A X
+A X
+A X
+C X
+A X
+C X
+B X
+B X
+A X
+A Y
+B Y
+B X
+B X
+A Y
+A Y
+A X
+A X
+B Y
+B X
+A X
+C X
+B X
+C X
+B Y
+B Z
+B Y
+A X
+A X
+A X
+A X
+A X
+B Y
+A X
+C X
+B Z
+A X
+C Y
+A X
+B X
+C Y
+A X
+A Y
+B X
+A X
+B Y
+B X
+A Y
+C Y
+C X
+A Y
+A X
+A X
+A X
+C X
+B X
+C X
+A Y
+A X
+A Y
+C Z
+C X
+A X
+A Y
+B X
+B X
+B X
+B X
+A X
+B X
+A Z
+B Y
+A X
+A X
+A X
+C Z
+A Y
+A Y
+C X
+C X
+C Y
+B Y
+A Y
+A X
+A X
+C Y
+A X
+C X
+A X
+A X
+C Y
+A Y
+A X
+C X
+A X
+A Y
+C X
+A Y
+A X
+A X
+A X
+B X
+B X
+A X
+B Y
+C Y
+C X
+A Y
+B X
+B X
+B Z
+C X
+B Y
+A Y
+C Z
+B X
+C X
+A X
+A Y
+B Y
+B X
+C Z
+B X
+A X
+C X
+C X
+A X
+A X
+A Y
+B Y
+B X
+A Y
+C Y
+B Y
+B Y
+A X
+A Y
+A X
+B X
+A Y
+A X
+A Y
+A X
+B Z
+B X
+A X
+A Y
+A X
+B Y
+A Y
+A X
+A X
+C X
+A X
+A X
+A X
+A X
+B Y
+B X
+A X
+A X
+C Y
+C X
+A Y
+A X
+B X
+A X
+B X
+B X
+B Y
+A X
+B X
+B Y
+A X
+B X
+C X
+A X
+A X
+C Z
+A X
+B X
+A X
+B X
+B X
+B Y
+A X
+B Y
+C Y
+A X
+C X
+A X
+B X
+B Y
+A X
+C X
+B X
+A X
+C Y
+C X
+B X
+A X
+B X
+A Z
+C Y
+A X
+A X
+B X
+A Y
+B X
+A X
+A Y
+B X
+A X
+C Y
+A X
+C X
+B X
+A X
+C Y
+C X
+A X
+B Y
+B X
+A Y
+B X
+A X
+B X
+A Y
+B X
+A X
+A X
+C X
+A X
+A X
+A X
+A X
+C X
+C X
+B X
+B Y
+B X
+B Z
+A X
+B X
+B Y
+B X
+B X
+A X
+A Z
+A Z
+A X
+B Y
+A X
+B X
+B Y
+A X
+B Y
+B X
+A X
+C X
+C Y
+A X
+A X
+B X
+B X
+B Y
+A X
+C X
+B Y
+A X
+A Z
+A X
+C Y
+A Y
+B X
+C X
+C X
+A X
+B X
+C X
+A Z
+A X
+A X
+B Y
+C X
+A X
+A Y
+C Z
+B X
+A Y
+A X
+A Z
+C Y
+A X
+C X
+A X
+C Y
+B X
+A X
+A X
+B Y
+A X
+B X
+B X
+B X
+C X
+C X
+A X
+C Z
+A X
+C Y
+A X
+C Y
+A Y
+B Y
+B X
+B Y
+B X
+C Y
+B Y
+B Y
+B X
+B Y
+A Y
+A Y
+C Z
+A X
+A X
+A X
+A Z
+B X
+B Y
+B X
+B Y
+A X
+C X
+B X
+A X
+C Y
+B X
+C X
+C Y
+B Y
+A X
+B Y
+B X
+C X
+B X
+C X
+B X
+A X
+C X
+B Z
+B Z
+C X
+A Y
+B X
+A Y
+A X
+B X
+C Y
+C X
+A Y
+C Y
+B Z
+B Y
+B Y
+B Y
+B Z
+B Y
+A X
+A X
+A Y
+B Y
+B Y
+A X
+A Z
+C X
+A X
+A Y
+C X
+A Y
+A X
+B X
+A X
+A X
+C X
+A X
+A X
+C Y
+B Y
+A Y
+A X
+A X
+B Y
+A X
+B X
+A X
+A X
+B X
+B X
+A X
+B Y
+A X
+A Y
+B Y
+A Y
+A X
+C X
+A Y
+A X
+C X
+A X
+A X
+B X
+C Y
+C Y
+B X
+B Z
+A X
+A Y
+A X
+A X
+C Z
+A X
+B X
+A Z
+A X
+A X
+A X
+A X
+A X
+A X
+C X
+B X
+B X
+C X
+A X
+A X
+A X
+A X
+A X
+A X
+B X
+A X
+C X
+A Y
+A X
+A X
+A X
+A X
+B X
+B Y
+A Y
+A X
+A X
+C X
+C X
+A X
+A X
+C X
+A X
+A X
+A X
+A X
+A X
+A X
+C X
+A X
+A X
+A X
+A X
+B X
+A X
+A X
+B Y
+C Y
+A X
+A Y
+C Y
+A X
+B X
+B X
+A X
+A X
+A X
+B X
+A X
+A X
+A X
+A Y
+A X
+B Y
+A Y
+A X
+A Y
+A X
+C X
+A X
+C Y
+B X
+B X
+A X
+A X
+A X
+A X
+A X
+C Y
+A Z
+A X
+B X
+B X
+A X
+A X
+C Z
+A X
+B Z
+B Y
+C Y
+A X
+A X
+C X
+B X
+B X
+B X
+C X
+A X
+A Y
+B Y
+C X
+A X
+B Y
+A X
+C Z
+B X
+A Y
+A X
+A X
+C Y
+A X
+A X
+C X
+A X
+B X
+B Y
+B Y
+B X
+A X
+A Y
+C X
+A X
+A X
+A X
+B X
+C X
+B Y
+A X
+A X
+A Y
+A X
+A X
+B X
+C X
+C X
+A Y
+B X
+A X
+A X
+A X
+B Y
+A X
+B X
+A X
+A X
+A X
+A Y
+A X
+A Z
+C X
+B Y
+B X
+A X
+B X
+C X
+A X
+A X
+B X
+A X
+A X
+A X
+A X
+B X
+A X
+C X
+A Y
+B X
+C X
+A X
+B X
+A X
+B Y
+A X
+C Y
+A X
+C Y
+C X
+B Y
+A Y
+A X
+A X
+B X
+A X
+C X
+A X
+A Z
+B X
+A X
+A X
+A Y
+A X
+A X
+C X
+B Y
+C Z
+A X
+A Y
+B X
+B X
+A X
+B Y
+C X
+A X
+B X
+A Y
+B X
+A X
+A Y
+A X
+A X
+C Y
+B X
+A Y
+C X
+C X
+A Y
+A Y
+A X
+B Z
+A Y
+C X
+C X
+C Y
+A Y
+B X
+B Z
+A X
+B Y
+A X
+A X
+B X
+A Y
+C X
+C Y
+A X
+B Y
+A Y
+A X
+B Z
+B Y
+A X
+B X
+A X
+A X
+B Y
+A Y
+A X
+A X
+A X
+A Y
+A X
+A X
+C X
+A X
+A X
+C X
+A X
+A X
+C Z
+B X
+A Y
+A X
+B Y
+B X
+A X
+A X
+A X
+C Y
+C Y
+B Y
+A X
+C X
+C X
+B X
+A X
+A X
+A X
+A Y
+A X
+A X
+B Z
+C X
+A X
+A X
+A X
+B Y
+B X
+C X
+B X
+A X
+B X
+A X
+C X
+A X
+C X
+A X
+C X
+B Y
+B X
+A X
+A X
+B Y
+B X
+B X
+A X
+B X
+C Y
+A X
+A Y
+A Y
+A Y
+A Z
+B Y
+A X
+A X
+A X
+A X
+A Z
+A X
+A X
+A X
+B Z
+B Y
+C Y
+A X
+A X
+B X
+C X
+A Y
+A X
+B X
+A X
+A X
+B X
+B Y
+A X
+B X
+C X
+B X
+A X
+A X
+A X
+A X
+B X
+B X
+C Y
+B X
+B X
+A X
+B X
+A X
+B Y
+B X
+A X
+A X
+A Y
+B X
+A X
+B Y
+A Y
+B Y
+B X
+A Z
+A X
+B Y
+A X
+B X
+A X
+A X
+A X
+B Y
+B X
+A X
+C Z
+A Y
+A Y
+C X
+B Z
+B X
+C Z
+B X
+B X
+A X
+A X
+B Y
+C X
+A X
+A Z
+B X
+A X
+A X
+B Y
+A X
+A X
+A X
+B Y
+A X
+C Y
+A X
+C Y
+A X
+C Y
+B X
+A Y
+A X
+B X
+A X
+B Y
+A X
+B X
+B X
+A Z
+A X
+C Y
+B Y
+A X
+A X
+C X
+B Y
+C Y
+C X
+A Y
+B Y
+A Y
+A Y
+B X
+A X
+A X
+A X
+A X
+A Y
+A X
+A X
+A X
+B Y
+A X
+A Y
+C X
+A X
+B X
+A X
+A X
+A X
+C Z
+A X
+A Y
+A X
+C Z
+B Y
+B X
+A X
+A Z
+A X
+A X
+A Y
+A X
+A X
+A X
+B Y
+A X
+B X
+A X
+A X
+A X
+A X
+B X
+B Z
+C X
+C X
+C X
+B Y
+A X
+B Y
+B X
+A Y
+B X
+B X
+A X
+C Y
+B X
+A X
+A X
+A X
+A X
+A X
+A X
+B Y
+C Y
+B X
+C Y
+B Y
+C X
+A Y
+C X
+B X
+C X
+B X
+A X
+A X
+B Y
+A X
+C X
+A Y
+C X
+C X
+B Y
+A X
+C X
+C X
+B Z
+A X
+C X
+A Y
+B Y
+A X
+A Y
+A X
+B X
+A X
+A X
+B Y
+A Z
+A X
+B Y
+B X
+A X
+A Y
+B X
+B X
+A X
+A X
+A Y
+A X
+C X
+A X
+B X
+C X
+C X
+C Y
+A X
+B X
+B Y
+A X
+C X
+A X
+B Y
+A X
+B X
+B Z
+A X
+A X
+A X
+B X
+C X
+C X
+B X
+A Y
+A X
+A Y
+A X
+A X
+A X
+A X
+C Y
+B X
+A X
+A X
+A X
+B Y
+A X
+B X
+B Y
+A Z
+A Y
+A X
+A Y
+A X
+A Y
+B Z
+A X
+B Y
+B Z
+B X
+A X
+C X
+C Y
+A X
+A X
+A X
+B X
+A Y
+C X
+A X
+B Y
+A Y
+B X
+B X
+A X
+A Y
+B X
+A Y
+C X
+A X
+C X
+A X
+C X
+A X
+A X
+C X
+A X
+A X
+A Y
+B X
+C X
+B Y
+A Y
+A X
+A X
+A X
+A Z
+B Y
+A X
+A X
+B Y
+A Y
+B Y
+A X
+B Y
+B X
+A X
+A X
+A X
+B X
+B Y
+A X
+C Z
+B Z
+A X
+A X
+A X
+B X
+B Y
+A X
+B Z
+A X
+A Y
+A Y
+A Y
+C X
+B Y
+A X
+A X
+C Y
+B X
+A Y
+A X
+A X
+B Y
+C X
+C X
+C X
+A X
+A X
+A X
+B Z
+A X
+C X
+A X
+A X
+B X
+B X
+A X
+C Y
+A X
+B X
+C X
+B Y
+A X
+B Y
+C X
+A X
+C X
+B Y
+A X
+A Y
+C X
+C Z
+A X
+C X
+A X
+A X
+C X
+A Y
+C X
+B Y
+A X
+C Z
+A X
+B X
+B Y
+A Y
+A X
+A X
+A X
+A X
+A Y
+A Y
+B X
+C X
+A Y
+A X
+C X
+B X
+B Y
+C X
+B X
+A X
+B X
+A X
+C Y
+A X
+A X
+A X
+A X
+C X
+A X
+B X
+A X
+B X
+A X
+A Y
+C X
+C Y
+C X
+A Z
+B X
+A Z
+A X
+B Y
+A Y
+B X
+A X
+B Y
+A Y
+A X
+B Y
+A X
+B X
+A X
+A X
+A X
+A X
+B Y
+A Y
+A X
+A X
+B X
+B Z
+A Y
+A Y
+C Y
+C Y
+A X
+C X
+A X
+B Y
+B X
+B Y
+B X
+C X
+B X
+C X
+A X
+B Y
+A X
+B X
+A X
+B X
+C Y
+B X
+A X
+A Y
+A X
+B Y
+C X
+C X
+A X
+B Z
+A X
+A X
+B Y
+A X
+A X
+B X
+A Y
+C X
+A X
+C Y
+A Y
+C X
+A Y
+A X
+A X
+A X
+A Y
+B X
+B X
+A Y
+C X
+B Y
+A Y
+B X
+B X
+B X
+B X
+A X
+B X
+B X
+A X
+C X
+A X
+C X
+C X
+A X
+C X
+B X
+A Y
+A Z
+A X
+A X
+A X
+A Y
+A X
+A X
+C Z
+A X
+B X
+C X
+A X
+B X
+C X
+C X
+A X
+B Y
+A X
+A X
+A X
+A Y
+B Y
+B Y
+A X
+B X
+A X
+C X
+A X
+B Y
+C Y
+C X
+C X
+B X
+B X
+C X
+A Y
+B X
+A X
+A X
+A X
+A X
+A Y
+B X
+B X
+C Y
+C Y
+B Y
+B X
+A X
+C Y
+A X
+C Z
+C X
+A X
+B Z
+A X
+A Z
+C X
+B Y
+A X
+A Y
+A X
+B X
+A Y
+C X
+C Y
+B X
+B X
+B Y
+B Y
+C X
+B Y
+B Y
+B X
+C X
+C X
+A X
+A X
+A Y
+A X
+A Y
+B X
+A X
+B Y
+B X
+A X
+A X
+A Y
+B X
+B X
+A X
+B X
+C Y
+A Y
+B Y
+C Y
+B Y
+A X
+B Y
+B X
+B Z
+A Y
+A Y
+C Y
+B X
+A X
+A X
+B Y
+A X
+A X
+B X
+A X
+A X
+A X
+B X
+B X
+B Y
+A X
+C X
+A X
+B X
+A X
+A X
+A Y
+B X
+B X
+B X
+C X
+B Y
+C Z
+A X
+C X
+A X
+B X
+A X
+A Y
+B Y
+A Z
+A X
+C X
+A Y
+A X
+A X
+A X
+A X
+A Y
+A X
+C X
+A X
+C Y
+B X
+A X
+A X
+A X
+A X
+A X
+C X
+A X
+B X
+B Y
+B Y
+B X
+C Z
+C X
+B X
+C Y
+A X
+A X
+A X
+A X
+A X
+C X
+A X
+B X
+C X
+C X
+A X
+A X
+B X
+A X
+A X
+A X
+B X
+A X
+C X
+A X
+A Y
+A X
+B Y
+A X
+B X
+A Y
+C X
+B X
+C Y
+C Y
+B X
+A X
+B X
+C X
+A X
+C X
+A X
+C X
+B X
+B X
+C X
+C X
+B X
+B X
+C Y
+B X
+A X
+B X
+B X
+B Y
+A Y
+B X
+A X
+C Y
+A Y
+C Y
+A X
+B Y
+A X
+A X
+A X
+B Y
+B X
+A Y
+A X
+A X
+A Y
+B X
+B Y
+A Y
+B X
+C X
+C Z
+B X
+A Y
+A X
+C X
+A X
+C X
+B Z
+C X
+A Y
+A X
+C X
+B Y
+A Z
+B Y
+A X
+A X
+A Y
+C X
+A Z
+A X
+B Y
+A X
+B X
+A Y
+A Y
+A X
+A X
+A X
+C Y
+B X
+A X
+B X
+B Y
+B Y
+A X
+A X
+A Y
+A X
+C X
+B X
+C X
+B X
+B X
+C Y
+A Y
+B X
+A X
+A X
+A X
+C X
+C X
+A X
+B X
+A X
+A X
+A Z
+A X
+C X
+B X
+A X
+C Y
+A Y
+C Y
+B Y
+B Y
+B Z
+A X
+C X
+A X
+B Y
+B Y
+A X
+B Y
+A X
+B Y
+B X
+B X
+C X
+B Y
+B X
+A X
+A Y
+B X
+A X
+B Z
+A Y
+B X
+B X
+A Y
+C Y
+B X
+B Y
+A X
+B X
+A Y
+A Y
+B X
+B Y
+B X
+A X
+C X
+A X
+A X
+A X
+B Y
+A Y
+B X
+C X
+C Z
+A X
+B Y
+A Y
+A X
+B X
+A X
+A Y
+A X
+A Y
+A X
+A X
+A X
+C X
+A Y
+C Y
+A X
+A X
+C Z
+B X
+A Y
+B X
+B X
+B X
+B X
+B X
+A X
+A X
+B X
+B Y
+A X
+C Y
+C X
+A X
+A X
+A X
+A X
+A X
+A X
+A X
+A Y
+B Y
+A X
+A X
+A Z
+C Y
+C Y
+B X
+C Z
+A X
+A X
+A X
+B Z
+B Y
+A X
+A X
+A X
+B X
+A X
+C X
+C X
+C X
+B X
+A X
+A X
+C Z
+B Z
+C Y
+A X
+A X
+A X
+C Z
+A X
+A X
+C X
+C X
+A X
+C Y
+A X
+A Y
+A X
+A X
+A Z
+C X
+C X
+A Y
+B X
+B X
+A Y
+A X
+B X
+C Y
+A X
+A Y
+B Z
+A X
+C Y
+A X
+B Y
+A X
+A Y
+A X
+C Z
+A X
+B X
+A X
+B Y
+A X
+A X
+A X
+A X
+A X
+B Y
+C X
+A X
+B X
+A X
+A Y
+A Z
+A X
+A X
+B Y
+B X
+C X
+A X
+A X
+B X
+B Y
+B Y
+A Y
+B Z
+B Y
+A X
+A X
+A X
+A X
+B X
+C Y
+A X
+A X
+A X
+A X
+A X
+A X
+A X
+A X
+B Y
+A X
+B X
+C X
+C X
+C X
+C X
+A X
+B Y
+A X
+B X
+B X
+A X
+A X
+C Z
+A X
+B X
+B X
+C X
+A X
+B X
+B X
+B X
+B X
+B Y
+A X
+B X
+A Y
+A X
+A Y
+B Y
+A X
+C Y
+B X
+A X
+A X
+A X
+A Z
+A Y
+A X
+C X
+C X
+B X
+A X
+A X
+B X
+A X
+A Y
+C Z
+A Y
+B X
+B Y
+A X
+C Y
+B Z
diff --git a/2022/day3.rb b/2022/day3.rb
new file mode 100644
index 0000000..5b6b0f7
--- /dev/null
+++ b/2022/day3.rb
@@ -0,0 +1,63 @@
+require 'set'
+
+def split_in_half(s)
+ pivot = s.length/2
+ return [s[0, pivot], s[pivot, s.length]]
+end
+
+def shared_item(s)
+ rucksack1, rucksack2 = split_in_half(s)
+ tmp = (rucksack1.chars.to_set & rucksack2.chars.to_set)
+ puts tmp
+ return tmp.first
+end
+
+def scores_hash
+ a = ('a'..'z').zip((1..26)) + ('A'..'Z').zip((27..52))
+ a.to_h
+end
+
+TEST_S = <<-EOC
+vJrwpWtwJgWrhcsFMMfFFhFp
+jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
+PmmdzqPrVvPwwTWBwg
+wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
+ttgJtRGJQctTZtZT
+CrZsJsPPZsGzwwsLwLmpwMDw
+EOC
+
+def test_1(s)
+ s.lines.map do |line|
+ item = shared_item(line)
+ scores_hash[item]
+ end.sum
+end
+
+def day1
+
+ puts test_1(TEST_S)
+
+ File.open('./day3.txt') do |f|
+ retval = f.readlines.map do |line|
+ item = shared_item(line)
+ scores_hash[item]
+ end
+ puts retval.sum
+ end
+end
+
+require './utils'
+
+def day2
+ badges = []
+ File.open('./day3.txt') do |f|
+
+ f.readlines.each_n(3) do |a,b,c|
+ badge = a.chars.to_set & b.chars.to_set & c.chars.to_set
+ badges << scores_hash[badge.first]
+ end
+ end
+ puts badges.sum
+end
+
+day2()
diff --git a/2022/day3.txt b/2022/day3.txt
new file mode 100644
index 0000000..fec6c82
--- /dev/null
+++ b/2022/day3.txt
@@ -0,0 +1,300 @@
+DsPhSBQQQhqmBDhPDsFwjwsLjlRjlttvjvvtRb
+rNJMNNbrHrtjHLHjvwtg
+fNbNzZdrZnMnMPnQShFPDmnqFm
+QWVCFfQffgQCVZzVVpHsHJBqtpspJFRHqq
+mwDbmnnGNlNcwNDDNRbnNDlJTpBJBtJGtPTLsBGqTqqsqp
+MlSdnScRnnmmDjSdNSdCzvggWzrgzjvfvrgVzW
+gsMljbrjlZlWcWMJrWwTwbmwQbmmLDQQLhwL
+CdgpzdgpgnfThHfFRwhfRf
+SptgpSpnCNpVSGNPvPGSddcMWjMrjqBsJcWqMcBWcVlZ
+JcJLQQFWhQJPJpWcwjHvMQvnnlMvzBHd
+tCtGZrmVRmVGTVTtCfRTCHHNNvdNzmdMvMlNzvwdvw
+CTGGRftfSGtGTGDLbFchSgSWWWcM
+QcMFQrvrQbvtczbVbjbMzZzRpqmDDmqqnNzCDCDC
+SHHfPJssGLPSdHThLhHdRmqNmNssnNmNCNnpjmsn
+LhLJfTdLJwfgPTdfGccrtjcMrccwvcrrFr
+jFLLLqDGjbtqLCChpMMhMBvpwMTmffpZ
+ZnJHRncHHgnrsrZffTdMdMBfmMvfvR
+NWWPnZrVHrZPCDDQtzDCPLCq
+jpFjvBZhDFHZdwcmslcslBLLNl
+dVtTVVCzzfrrMPNLLcnVcPLRns
+CrzWzTqdWtGCzJtbJCrMjjDFHZQjZSpvFGF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7-9
+2-8,3-7
+6-6,4-6
+2-6,4-8
diff --git a/2022/day4.rb b/2022/day4.rb
new file mode 100644
index 0000000..a700986
--- /dev/null
+++ b/2022/day4.rb
@@ -0,0 +1,36 @@
+def range(s)
+ n1, n2 = s.split('-')
+ return n1.to_i .. n2.to_i
+end
+
+def read_pairs(filename)
+ retval = []
+ File.open(filename) do |file|
+ file.readlines.each do |line|
+ elf1, elf2 = line.split(',')
+ retval << [range(elf1), range(elf2)]
+ end
+ end
+ return retval
+end
+
+def range_included(r1, r2)
+ return (r2.include?(r1.first) && r2.include?(r1.last)) || (r1.include?(r2.first) && r1.include?(r2.last))
+end
+
+def range_overlaps(r1, r2)
+ return (r2.include?(r1.first) || r2.include?(r1.last)) || (r1.include?(r2.first) || r1.include?(r2.last))
+end
+
+def part1(filename)
+ read_pairs(filename).map { |pairs|
+ range_included(pairs[0], pairs[1])
+ }.select { |x| x }.count
+end
+
+def part2(filename)
+ read_pairs(filename).map { |pairs|
+ range_overlaps(pairs[0], pairs[1])
+ }.select { |x| x }.count
+
+end
diff --git a/2022/day4.txt b/2022/day4.txt
new file mode 100644
index 0000000..94b2176
--- /dev/null
+++ b/2022/day4.txt
@@ -0,0 +1,1000 @@
+34-82,33-81
+59-59,69-73
+6-96,98-99
+1-94,3-96
+13-92,20-64
+37-75,76-93
+5-98,6-6
+40-65,40-64
+13-63,84-91
+31-75,31-35
+83-96,86-96
+65-85,64-85
+85-85,36-86
+71-73,72-81
+3-91,91-92
+45-72,45-73
+42-70,42-58
+45-45,16-45
+2-59,49-58
+46-59,60-60
+21-21,21-77
+65-72,69-72
+3-77,3-76
+2-91,23-89
+86-92,7-86
+25-86,24-86
+11-62,1-62
+23-30,23-23
+31-94,27-29
+58-90,59-89
+45-70,19-46
+56-56,57-97
+65-84,67-83
+47-77,44-48
+1-68,29-69
+18-18,19-68
+99-99,72-93
+3-60,1-60
+31-31,32-74
+2-2,7-62
+25-83,10-24
+7-96,16-47
+12-71,13-70
+56-57,20-56
+18-24,25-25
+58-89,58-90
+63-68,18-63
+26-70,69-71
+95-98,8-96
+21-94,22-94
+22-91,21-91
+16-22,20-23
+94-95,3-94
+2-20,19-80
+26-94,6-17
+30-82,29-82
+22-73,22-71
+51-62,50-62
+10-65,9-64
+35-36,1-35
+28-90,39-90
+21-22,20-21
+2-35,3-34
+10-79,79-79
+37-80,80-81
+7-93,99-99
+4-7,32-61
+2-37,1-38
+4-91,3-87
+32-92,31-91
+64-64,64-83
+7-87,3-8
+60-91,55-59
+35-41,35-46
+46-87,70-87
+3-14,4-88
+44-60,19-93
+10-31,10-74
+25-87,24-26
+80-97,90-91
+3-15,6-23
+18-83,49-77
+7-45,46-90
+73-91,11-79
+2-4,3-99
+66-98,7-96
+62-63,61-62
+30-97,97-98
+3-79,78-80
+15-32,30-72
+66-85,84-85
+35-76,45-76
+14-65,14-65
+81-82,42-81
+3-90,4-90
+3-4,5-99
+63-99,1-99
+65-66,9-65
+60-84,85-85
+17-17,6-18
+73-75,7-74
+57-98,56-99
+59-59,10-58
+10-18,20-52
+36-78,35-78
+1-99,99-99
+21-88,51-55
+42-97,42-96
+7-79,8-78
+32-71,72-96
+19-35,43-73
+2-12,4-11
+91-91,39-90
+49-86,50-89
+13-19,21-84
+60-81,67-81
+17-26,26-75
+59-95,60-95
+30-70,21-70
+7-60,8-61
+10-95,95-97
+20-22,21-84
+11-98,6-9
+2-24,3-26
+41-50,62-99
+13-25,26-99
+35-43,27-36
+99-99,42-81
+86-86,8-85
+13-46,13-84
+76-88,77-87
+19-77,4-77
+20-54,21-44
+19-91,90-91
+8-67,7-67
+8-74,29-73
+14-16,15-25
+64-70,70-71
+16-99,16-16
+6-94,5-95
+87-98,71-98
+1-60,7-60
+1-76,1-96
+31-92,24-30
+12-81,9-11
+4-85,2-78
+11-84,8-9
+4-4,8-90
+6-11,12-82
+2-96,2-70
+12-91,12-97
+79-89,2-89
+75-75,67-74
+5-81,5-5
+68-74,74-84
+81-82,82-95
+5-78,6-78
+53-87,38-88
+83-94,75-88
+53-79,31-48
+55-57,56-88
+3-69,69-70
+5-54,2-4
+48-85,28-47
+23-78,22-63
+13-20,29-96
+24-45,86-88
+43-64,44-71
+7-84,49-84
+16-89,15-88
+6-73,13-73
+71-71,53-70
+4-12,11-41
+36-53,37-52
+46-91,45-91
+5-58,4-6
+94-94,95-97
+9-55,55-94
+6-49,5-7
+4-99,3-5
+92-93,91-93
+61-83,62-84
+22-82,23-81
+8-94,7-94
+7-9,12-63
+1-51,73-73
+7-66,2-6
+44-45,7-44
+8-94,8-99
+90-97,96-97
+6-72,72-91
+55-60,59-62
+2-40,1-3
+51-75,36-75
+6-8,7-86
+1-1,2-97
+25-88,89-89
+19-94,18-20
+3-3,4-98
+32-68,52-67
+10-54,7-54
+17-69,18-70
+17-75,8-54
+53-65,16-52
+50-88,49-49
+8-63,3-7
+35-38,36-84
+50-54,14-54
+17-17,18-62
+20-26,27-83
+3-3,4-84
+9-25,41-56
+16-72,17-71
+22-89,5-89
+12-30,12-30
+78-94,55-78
+40-83,85-88
+49-84,48-50
+96-98,1-96
+78-78,76-77
+81-82,22-34
+93-94,5-92
+39-70,38-40
+80-84,85-85
+3-73,4-91
+13-49,13-89
+2-94,2-25
+18-72,71-75
+27-69,25-94
+20-78,16-79
+25-29,25-50
+75-95,93-95
+35-65,34-65
+58-91,57-90
+95-95,7-95
+31-31,31-81
+8-88,8-89
+90-90,4-90
+13-66,37-66
+17-17,18-19
+74-74,39-73
+28-30,29-31
+22-95,21-94
+12-16,11-15
+76-89,74-74
+28-91,29-92
+23-23,23-96
+2-99,98-99
+84-90,7-83
+17-19,20-20
+14-99,13-93
+39-81,40-81
+6-55,5-7
+63-63,11-62
+93-93,3-92
+69-79,4-69
+6-99,4-7
+65-87,60-88
+14-98,13-99
+10-58,11-64
+37-95,37-91
+24-95,99-99
+51-94,8-94
+3-61,1-1
+2-94,23-88
+18-86,17-86
+47-96,29-48
+11-79,24-79
+26-87,25-25
+10-70,9-70
+21-72,71-85
+29-69,69-90
+17-64,17-63
+34-83,8-33
+4-52,53-75
+89-99,2-90
+2-89,2-88
+11-34,9-87
+19-95,20-95
+32-67,32-67
+40-99,96-99
+29-87,87-95
+11-61,5-60
+3-96,1-80
+12-87,57-88
+34-93,93-98
+36-76,35-37
+2-70,2-71
+1-5,8-58
+27-91,27-27
+1-60,1-61
+26-80,27-81
+5-91,92-94
+82-82,63-81
+35-99,36-99
+8-8,8-52
+93-96,5-94
+11-18,17-94
+17-81,17-85
+42-66,43-66
+23-83,22-24
+47-60,46-48
+81-82,5-81
+58-89,58-90
+10-48,11-83
+12-93,11-93
+98-99,27-94
+21-61,18-19
+95-95,52-95
+18-99,17-95
+19-75,15-75
+43-44,6-44
+63-86,62-64
+85-90,30-62
+2-78,77-78
+13-72,87-96
+62-86,49-61
+5-33,15-34
+26-71,59-83
+2-85,76-87
+8-14,15-72
+19-77,17-76
+4-68,2-2
+23-92,22-91
+15-72,4-72
+8-70,8-46
+8-74,8-83
+9-75,29-58
+14-97,13-96
+9-61,9-61
+9-10,13-44
+16-48,40-49
+73-78,79-79
+32-54,54-54
+13-99,13-98
+9-91,8-91
+8-42,12-42
+10-87,9-86
+5-5,6-93
+8-75,9-76
+20-94,17-99
+16-17,17-58
+70-88,89-89
+68-68,64-71
+23-94,74-94
+14-58,14-57
+69-70,3-70
+24-82,22-82
+19-97,12-18
+4-5,7-72
+23-79,79-80
+61-83,61-88
+37-49,34-36
+86-98,86-99
+43-84,44-85
+96-96,2-89
+85-86,4-85
+41-43,24-43
+18-72,18-65
+7-7,6-93
+20-94,93-99
+24-92,23-93
+58-82,83-83
+65-71,69-71
+63-95,96-96
+42-51,42-52
+22-81,80-90
+2-96,1-96
+43-65,44-66
+77-77,50-76
+16-91,15-92
+41-83,82-95
+37-94,21-34
+37-98,97-98
+1-1,1-74
+17-22,18-23
+24-56,57-57
+7-15,1-6
+42-57,37-57
+8-96,8-96
+33-97,63-88
+6-7,5-84
+36-97,83-96
+35-37,36-79
+4-98,4-99
+77-77,34-76
+30-54,31-62
+43-64,34-64
+51-90,53-97
+58-80,38-64
+71-86,72-86
+18-88,28-87
+3-80,2-79
+23-66,32-66
+64-81,62-64
+3-89,2-4
+94-96,11-81
+15-91,15-92
+15-78,16-77
+1-99,2-98
+4-98,1-5
+31-59,11-30
+21-59,20-58
+32-71,84-88
+96-96,7-83
+6-66,67-67
+20-43,21-43
+16-95,17-96
+34-41,35-41
+25-84,84-95
+29-31,30-91
+96-97,14-96
+82-86,55-83
+55-55,29-54
+34-90,13-35
+58-81,57-81
+38-90,19-38
+26-67,67-99
+26-86,25-31
+16-99,10-15
+2-47,1-46
+6-74,73-81
+26-93,3-93
+20-44,21-45
+2-69,2-70
+5-95,5-95
+75-86,11-74
+33-83,84-84
+62-69,63-70
+41-57,58-58
+9-14,10-14
+77-77,1-77
+46-65,66-89
+69-75,69-69
+49-92,49-98
+27-50,22-22
+15-78,16-95
+12-83,12-92
+4-38,2-38
+26-87,25-86
+86-86,20-86
+97-98,3-97
+16-16,16-84
+14-21,28-79
+57-92,91-92
+3-5,4-79
+80-84,42-94
+45-96,95-96
+28-28,28-80
+58-76,74-84
+29-69,69-70
+1-67,66-67
+34-66,34-67
+99-99,3-86
+50-79,26-49
+92-97,91-91
+74-75,61-74
+2-50,1-76
+55-80,43-53
+8-89,1-1
+18-57,40-57
+72-94,93-97
+21-56,22-81
+22-24,32-83
+6-77,7-76
+6-60,7-60
+94-95,37-94
+11-90,6-90
+5-81,5-80
+1-4,5-78
+2-51,52-52
+13-96,13-96
+9-26,28-91
+2-90,63-89
+71-97,6-96
+50-87,51-88
+82-93,82-92
+11-22,2-32
+36-88,99-99
+25-99,1-94
+8-98,99-99
+11-42,10-12
+19-90,91-91
+51-63,52-85
+80-90,89-90
+30-55,31-55
+14-85,15-85
+31-92,30-30
+2-96,1-97
+71-85,27-55
+65-67,66-67
+32-96,31-95
+24-24,25-88
+7-84,6-6
+56-74,55-57
+76-80,74-75
+17-17,17-92
+36-46,45-47
+60-60,2-59
+17-53,53-87
+30-96,30-92
+10-46,5-7
+5-99,2-3
+1-49,1-48
+85-88,10-88
+33-94,94-97
+94-95,94-95
+19-52,36-51
+41-96,40-97
+2-78,77-78
+80-80,21-80
+7-17,17-17
+4-47,30-47
+16-16,8-15
+33-95,33-94
+39-89,90-96
+61-83,30-83
+25-76,68-75
+8-50,8-50
+17-86,12-18
+9-48,48-56
+28-99,28-99
+44-96,97-97
+4-74,4-73
+48-90,47-89
+35-46,36-47
+8-57,9-57
+45-70,98-99
+58-66,42-57
+8-18,3-3
+10-97,9-98
+3-93,2-89
+14-19,21-90
+85-85,27-86
+27-96,7-26
+53-53,54-96
+30-91,29-92
+91-91,98-98
+96-96,29-95
+3-82,1-2
+31-32,1-32
+74-95,24-95
+9-10,9-71
+21-23,22-99
+98-99,1-99
+50-92,39-50
+19-89,19-90
+84-88,26-88
+83-84,5-84
+13-30,30-31
+60-75,61-77
+23-60,61-93
+12-85,4-7
+9-95,10-95
+39-71,39-71
+29-55,28-54
+3-92,88-92
+17-80,10-73
+2-60,3-61
+39-88,78-88
+1-39,6-44
+5-26,6-25
+88-96,8-96
+1-96,1-1
+14-60,60-61
+7-76,2-5
+44-94,44-94
+75-75,75-96
+5-67,67-68
+19-35,6-34
+3-95,3-3
+27-62,27-62
+34-99,3-99
+46-89,47-88
+46-71,28-36
+15-56,14-96
+4-92,3-5
+67-68,25-68
+6-86,3-4
+17-81,18-85
+6-6,6-53
+2-2,1-89
+51-52,44-51
+59-59,28-58
+41-53,52-81
+27-91,27-27
+70-78,71-78
+16-94,17-23
+6-51,5-51
+55-68,55-69
+97-99,7-94
+5-90,89-90
+16-46,15-46
+12-99,9-98
+17-94,11-67
+3-98,99-99
+80-88,36-80
+9-87,8-86
+51-62,50-63
+82-82,82-84
+4-97,96-96
+46-94,99-99
+51-68,51-67
+59-80,53-80
+40-57,39-56
+22-84,27-85
+84-84,27-85
+46-62,45-61
+16-58,16-58
+54-61,47-98
+61-65,63-63
+26-38,27-39
+8-85,9-86
+3-91,2-91
+8-70,8-8
+73-85,86-86
+15-47,14-46
+1-89,67-92
+8-78,53-79
+15-87,15-86
+60-70,71-99
+66-71,20-75
+6-93,5-74
+26-81,26-82
+27-64,27-63
+9-42,10-25
+11-91,91-91
+39-78,38-78
+25-95,24-96
+4-56,8-56
+41-47,41-66
+79-81,25-79
+5-64,30-34
+20-98,24-66
+36-67,66-94
+31-40,11-95
+22-88,88-89
+2-78,79-79
+77-78,45-78
+5-81,5-80
+7-72,8-71
+41-41,41-53
+14-40,15-40
+4-61,6-61
+25-51,24-50
+10-87,11-92
+63-63,63-64
+19-21,12-22
+28-96,95-99
+91-92,10-92
+4-70,3-40
+60-82,59-81
+18-35,18-36
+41-76,77-77
+52-95,51-95
+34-44,30-44
+73-82,80-82
+25-81,3-26
+61-68,62-68
+50-98,49-98
+12-47,25-98
+29-53,29-88
+32-43,44-68
+10-90,9-90
+58-78,59-78
+17-19,18-62
+59-89,66-90
+94-95,23-94
+94-94,31-93
+7-89,7-76
+62-74,43-75
+16-95,18-89
+43-71,32-37
+31-57,19-57
+12-25,21-33
+71-72,72-94
+67-67,22-66
+16-86,21-86
+13-69,13-69
+4-96,97-97
+84-84,60-84
+18-93,17-94
+5-46,5-45
+51-65,52-64
+11-89,12-88
+3-23,1-23
+36-88,35-88
+13-36,37-83
+15-16,15-39
+8-86,7-79
+24-99,38-99
+46-51,47-72
+23-40,40-43
+86-86,45-85
+21-60,16-60
+4-55,3-5
+79-96,68-96
+2-3,5-95
+17-77,17-78
+36-88,36-88
+43-88,40-54
+74-90,73-89
+6-96,6-95
+3-19,64-70
+17-72,2-6
+43-82,30-83
+23-72,22-72
+25-91,26-90
+13-95,55-95
+20-58,22-58
+21-57,47-71
+25-86,24-87
+8-99,9-99
+2-3,3-96
+48-48,22-48
+5-83,1-4
+27-61,84-91
+3-70,52-90
+37-82,37-85
+24-54,55-65
+81-82,3-82
+17-80,79-93
+59-59,60-95
+30-31,32-32
+10-99,5-9
+23-53,24-53
+13-85,1-12
+10-99,2-2
+49-78,78-87
+97-98,5-97
+45-74,46-74
+16-92,16-82
+13-86,13-51
+27-29,28-36
+28-90,28-89
+2-99,1-1
+15-73,14-73
+56-96,20-55
+12-84,85-85
+85-86,27-85
+10-92,11-77
+19-33,34-98
+15-26,6-14
+8-78,5-85
+6-95,7-59
+1-3,2-65
+82-99,33-82
+48-77,21-27
+8-57,15-27
+1-97,2-99
+12-63,1-90
+25-75,58-75
+92-98,24-43
+8-10,9-98
+13-25,44-87
+18-58,18-78
+11-13,12-61
+39-55,11-56
+70-94,31-70
+6-20,7-19
+9-63,63-66
+1-5,13-90
+40-70,40-71
+31-75,54-94
+5-95,5-94
+17-37,18-21
+3-57,29-57
+99-99,81-97
+11-92,11-91
+29-79,49-78
+44-85,43-84
+98-98,63-98
+19-82,13-18
+23-93,23-93
+5-90,4-6
+5-96,5-97
+16-21,15-15
+16-69,19-24
+23-59,60-80
+35-77,77-88
+72-95,6-73
+7-88,7-88
+15-87,14-87
+4-54,4-44
+67-73,34-44
+55-55,55-77
+16-82,81-82
+34-93,7-33
+20-82,21-81
+60-73,73-74
+37-63,66-96
+24-26,25-51
+42-43,42-84
+45-52,57-93
+4-96,25-97
+34-74,33-74
+6-37,5-5
+9-63,8-10
+31-85,11-16
+79-81,67-80
+23-23,25-83
+2-32,5-96
+84-85,38-84
+46-47,9-46
+87-88,23-87
+78-84,7-92
+36-39,34-39
+31-64,31-65
+39-76,25-62
+23-99,20-22
+99-99,38-86
+35-78,34-78
+30-95,30-94
+3-69,1-70
+27-82,26-52
+7-57,8-56
+78-83,60-69
+18-66,17-67
+1-94,3-94
+8-16,15-16
+29-30,13-29
+30-83,17-98
+28-87,27-87
+77-82,10-81
+30-76,2-29
+4-4,5-73
+62-66,62-67
+1-81,44-72
+16-44,43-44
+98-99,3-99
+98-99,9-78
+29-70,30-62
+79-93,80-94
+84-95,84-95
+27-36,26-88
+3-89,3-88
+16-44,15-45
+21-65,18-53
+8-63,7-7
+19-76,18-74
+35-44,19-39
+16-48,3-15
+7-7,7-33
+96-97,78-97
+20-83,16-83
+55-85,28-52
+18-82,18-81
+4-10,9-92
+32-66,7-66
+49-79,18-49
+53-93,52-93
+53-97,85-99
+24-98,24-24
+28-97,27-27
+27-92,76-92
+8-9,16-20
+54-54,54-87
+7-89,89-98
+57-76,56-77
+9-87,8-87
+48-81,48-82
+3-33,3-48
+8-8,9-76
+24-79,10-25
+37-96,37-97
+72-77,74-77
+39-69,40-70
+33-97,4-60
+53-57,57-58
+91-91,49-90
+1-1,1-95
+1-91,92-92
+48-90,89-90
+86-98,87-96
+67-81,68-80
+66-66,66-87
+94-95,19-95
+1-6,7-14
+28-30,28-29
+6-60,30-84
+25-46,6-8
+8-69,8-68
+7-94,6-94
+9-80,10-81
+89-98,56-88
+61-91,62-92
+39-87,40-91
+29-57,18-57
+89-90,58-89
+95-96,72-95
+42-59,31-47
+70-80,39-86
+24-35,1-36
+25-39,25-39
+1-1,1-96
+44-81,45-90
+30-88,89-89
+69-77,46-72
+31-72,32-72
+60-61,59-61
+17-26,1-16
+10-91,91-92
+81-95,34-95
+80-81,18-73
+13-58,13-57
+7-57,6-56
+53-68,66-85
+64-93,57-63
+77-78,11-77
+19-23,24-88
+30-58,31-58
+16-27,15-28
+12-94,12-93
+4-29,27-29
+57-60,56-68
+15-96,15-97
+5-51,9-94
+25-61,24-61
+40-86,41-86
+4-84,5-84
+6-98,5-97
+53-53,15-53
+51-63,51-62
+30-38,38-44
+58-83,5-74
+13-94,12-92
+19-20,20-99
+35-46,36-45
+4-98,1-3
+66-68,67-94
+4-80,9-99
+81-99,3-98
+9-80,9-65
+10-60,11-59
+1-22,22-22
+2-90,89-90
+45-83,45-84
+30-59,22-22
+97-97,2-96
+20-99,1-99
+10-15,16-79
+12-85,85-85
+13-50,3-12
+8-95,96-96
+73-73,1-72
+4-62,5-48
+27-47,27-48
+11-81,11-93
+65-83,59-72
+27-67,35-67
+44-96,16-44
+95-98,44-81
+32-96,96-97
+73-74,4-73
+43-56,33-34
+19-96,95-98
+32-96,33-95
+28-95,95-96
+61-81,8-61
+97-97,1-97
+37-83,36-38
+25-80,2-80
+58-67,57-67
+43-94,75-92
+32-42,41-98
+19-94,19-19
+15-84,15-99
+41-48,49-49
+15-96,15-15
+82-87,32-83
+3-35,2-4
+33-59,34-58
+19-99,5-7
+80-98,17-96
+4-75,74-75
+2-96,3-97
+24-24,24-76
+24-96,4-97
+45-84,46-84
+62-90,63-91
+39-89,38-90
+32-33,9-33
+4-23,47-90
+73-74,55-73
+54-99,29-54
+16-66,15-66
+61-91,77-91
+29-88,28-89
+45-77,44-78
+13-76,52-75
+33-92,32-58
+38-85,37-81
+54-92,38-93
+10-91,21-94
+3-98,14-98
+7-58,6-58
+23-25,24-83
+19-86,13-18
+61-63,62-96
+24-63,57-80
diff --git a/2022/day5.rb b/2022/day5.rb
new file mode 100644
index 0000000..6d6f849
--- /dev/null
+++ b/2022/day5.rb
@@ -0,0 +1,43 @@
+TEST_S = <<EOF
+ [D]
+[N] [C]
+[Z] [M] [P]
+ 1 2 3
+
+move 1 from 2 to 1
+move 3 from 1 to 3
+move 2 from 2 to 1
+move 1 from 1 to 2
+EOF
+
+class Stacks
+
+end
+
+class Instructions
+ attr_reader :indexes
+
+ def initialize(header)
+ indexes = {}
+ indexes.default = []
+ header.readlines do |line|
+ line.scan(/\w/).each do |c|
+ indexes[line.index(c)] << c
+ end
+ end
+
+ self.indexes = {}
+
+ indexes.each_key.each_with_index do |i, index|
+ self.indexes[i] = indexes[index]
+ end
+ end
+end
+
+def parse_input(filename)
+ File.open(filename) do |file|
+ contents = file.read
+ header, body = contents.split(/^$/)
+ end
+
+end
diff --git a/2022/utils.rb b/2022/utils.rb
new file mode 100644
index 0000000..ef1185e
--- /dev/null
+++ b/2022/utils.rb
@@ -0,0 +1,10 @@
+require 'pry'
+
+class Array
+ def each_n(n)
+ while not self.empty?
+ a, b, c = self.shift(n)
+ yield [a, b, c]
+ end
+ end
+end
diff --git a/2023/day-01/Cargo.lock b/2023/day-01/Cargo.lock
new file mode 100644
index 0000000..7dc86fc
--- /dev/null
+++ b/2023/day-01/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "day-01"
+version = "0.1.0"
diff --git a/2023/day-01/Cargo.toml b/2023/day-01/Cargo.toml
new file mode 100644
index 0000000..ac3eb44
--- /dev/null
+++ b/2023/day-01/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day-01"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/2023/day-01/src/bin/input.txt b/2023/day-01/src/bin/input.txt
new file mode 100644
index 0000000..a1ff397
--- /dev/null
+++ b/2023/day-01/src/bin/input.txt
@@ -0,0 +1,1000 @@
+99lbqpxzzlbtvkmfrvrnmcxttseven
+q7cnfslbtpkvseven
+6threezlljtzcr1sdjkthree4cx
+21xfxfourmzmqbqp1
+lkdbjd5
+8three27
+21three
+3lqrzdq16
+49threenjdgrmgfnfhcgz
+fourmsmjqfmbjvtwosevendcljsdcstl3one
+four98
+4sevenfddxgcvdgx
+dffmkvmhhdbzjcgrjc5132
+eight4one31nxlnrzvtfvrkfvgbbqmvff
+mdmvbhqjt5rkfpcnfvzhkkfbjvh8three9
+four32
+seven6pljhqnineeightjjsvnqblk8eight
+6glzfour77fiveone
+ntvhxqzsixxcrfpgstwo915onevxz
+81four8xkttczb2vj
+six8flfzdzl72eightnine
+sevensevenzsztgvh4sixbzltzl
+2fivehgrszcrgc9
+four53ninedrjllgffrfrtjgggvknine
+nineonecxpzzqsptc7nv9pck
+sixrqqfkcjrqkppvqthree1
+1five72cxh3fivefive
+75349sixnhxjpgtnhqlf
+9963onefourthree6oneightq
+51fp
+foursix2lt7one1sevenone
+fourddcmgbvkm8fivethreeksqghch65ztdtsdmpvk
+35jxmgctsevennine
+mbbkjxfthreetwoqlcrjnlvkrgnine41vkjknnmtv
+three7sixtwohpghsdxleightthreetwo5
+twocbtbkxhhcdrctkc14hlmdh
+4sevensix3ninedss8
+snqhqmffonettwofourgdkjmbjvjpgxxxpzkm8zfpfcgj
+3xmpfmnlz9fourthree9pdnzdlcsix
+66fourone1
+bdkfdqvkmmstkhdsbbl5
+48nfive
+twothreesixthreecvsskxq3threefoureight
+1vkseveneight
+gskgpsix4lhrtwo88threernhqnnfqdf
+nskfvvncxfourninehkrbxpgdsk4
+vlm3qszxqnnzz1ptcvdxnf
+xrppvsfourfive3sixthreebvbdkpckgheight
+pckngkbfour3nineninepqcxvsqspbthmhzrp
+pbtndgpfkhpflpj39zkpjcnine
+954fourvrmftt
+2xjrkdb8mzcfkvbdcx6
+plt462
+mcmzfzcdones2seven4
+8chnpnqmbx946eightkdjvhkkbtthree
+6zgvqslsixnine4fivethreegqqpjz
+9twosixseven4
+7seven75
+four7sevenmdj8
+6r219sevenpcvfpmfxxl
+dvxjblhdjqttxdfourhhrgdpmvvone83
+one3sdnfone1ddjlzhgninethreenine
+nine3sbj5msppfonetwo
+14tgmqlnh
+seven5xjncjmggjppmnsx7fourdzxrsck
+j1hphv
+61threejjlccdzvsevenjqpbjsphdq
+pjmsphdtwo5x6vjzmvtkfhk43hknqc
+xfpbzdl6
+twosix3fournlddsqmfbpslstnfiveonezfgoneighthtl
+828fivethreetwo2
+fmrgz5sxrrd
+one88cjcvxddjmczjznhpnvsix
+two9six7pkgttqdnsbgfdcdsixmskjgfvvlvqvdx
+six7eighteightq68eight
+seven4bsrfpxb6threesevenmgxfmfive
+gf74fourjdflkdtrvmljskxsix5three
+xsvrhh25
+2sixtwofivez813four
+kbkclv3onelmf4ntxhxbrppsixsix
+8nine9hstninezzbflnjfxrndcpzknk
+1hjlnsszbmtjtwo
+2one146
+9jdpnzgqrf
+1qfbhl83threezxcrdfzcbbqv
+p4lcmztns33
+xmcsevenseven21jjfphz7sevengxlvfrrj
+jfkmdmrfhv8
+73spzlbvnxsqsvgpbkl
+kkeightlrnj4three
+4qxzfxjdmrddlhxfive173eight
+jhmvxpbeight681gj6seven
+mqpsxqpxj3nine9ss
+fourdjqll2vbqbtwo
+28fivesix6one
+pgblvrqlnjfdtvngfbzpl5njsmvshn5tc
+eightvvh43nine
+dpxc5oneonebdbkheight
+pveightwothree2kfzpkks3ljxnbp
+vknl4xptptjjp
+4twotfour
+182eight
+ninesixqkfbhgtwo3
+twoseventwo4fivethree3one
+sevenoneeightnine4sgkckjszmp
+six4svkqftsrdzk
+bhnbm96fivenineszx8sevenoneightkdk
+rjldcxl8cxkpsdsdpgbngqeightnine9
+5two6bdrksqgd
+threestrhsdtmnc998xfdtfg66
+bknkttsjf6gonesixeight
+nine6one9jnqf1
+qkrpkv95bd11two8
+dksqfpmb6ttt5twothree5
+xxhrnpjsvcq7nineonexjkcsrbxr6one
+hsmdgfvbsk76four1sixhfn
+ninefiveeightrflsdc4one9
+four73915seventhfmjjqgxjzsnxvmnl
+seven9phpseven9ftwo
+59121fivep4
+gg3eightgdngqf
+4zbthb7
+rxrhprtfb4ljdzqfmhgbzqzmrvvj1eight
+zkvmsrvtk3two4
+ckbk8nine
+tbbkxr844lpkgjvmsix
+onetwo8kbxqgvsevenmrhqndt
+ptvgfn6rnpfkxcc52
+three1vd
+fivefiveeightdrljdrljxc9bjpbqseven8
+fourx7mlksevendjtr1lb4
+6ndfqts3two88
+qh976eightvfch7
+five9xdthree1seventhreeseven2
+xvfmccmmjcjjsm5
+ffiveeight579
+97hcfbrhkfive39lzhgjddsx6
+388eightkrmdktwopjdlpfmfivetwoneql
+eightonenine4
+bqzpzbzkbs7nprbdmbqseven8kzr1pflnine
+9eightfourthree5four
+cclc6
+13one8tkfrmvcjfq4sixjlxj
+dtrtwo9foursflc
+3six4two3nine
+7vkztxh6
+xthtrhfz83six
+twofive56
+nineeight5
+one5qmhmvrkktjmvhgxx
+4four1
+8one2dljjrvkthreehjdsbpqgtbjm
+foursevennine51s
+1nine8ddhdnbheightseven1
+nine5five2375lhphjk
+ftdrpmmzhvrxcz3vfqnhjqlqxdcrxeighteightspmj9
+qbczvsdl449six1
+seventwohpknrrjtvfhpxpzb3sevenn2
+jnpxrqrtwogqsk4
+three9fouronejjlrzqdrxkcqnd
+ql871three1rbhtszd
+xfbrnkzshqtwo43twohhfqdddc8j
+ninedgj6
+two3three6ninethreefourseven
+4bfsl1shdzeight3
+96mcdgv1
+4fivefour4
+sixfivetwo4pjbkcg
+4onetwotrnqlgxgtxxrgxpgsevenddjfd
+three19
+jbnrs5bgmsixeightxzjznzkhpvsix5twoneb
+7sixpzhsbnhrrmonetwosrjbt1jcxflk
+74onetdh7
+5one4cmmcmjnl9eightkvhrnkgqjstxnpt
+seven9xttdmzsix9tbnjfgmsgfoureight
+32five4
+7five41lpscgz
+48three
+hddfhppseven2
+5ninecbtfxkfrtccfdzplndjpseventfhqkmcm5
+65ninesqgeightjt7
+four3csxzztgbrninesbfzf
+2bcnlphn
+xsfmhnbdrj31828
+ninezrvbf717six
+7hlbhqxseven
+2jrvfr5lbqzfjgpdgfourthree7srmq
+6sixfive8nine
+eight29one
+onefour5ddgcrninedgdkzh1threesmcjmntnhh
+gdg18ntxdpvvxcn7zk74
+5onesixfnppbf2vxxbntdqvv
+kmclhrb2five49sevennine3eight
+6jdddgdjbgdqmkktf
+26jhvtscmrjthreenine53mldd8
+mkdcpnbsevencjfm21twotwo
+3bqzmtnjhlbdszlrvpmvcgclbgfzljk74
+8gfbmnnlltjcmjkmmvnfsgph
+eightpcggqtqns2
+ztzrvxglv7three5cmhnbt1five1chfk
+9eight8cfzrsixthreevvvfour
+3nine824ninefour
+nmrjjp2fourd
+twoonemgdm67
+foursdmljtklzldsevenvbqpthree917
+3ddzjxlsg69nine2eighttwoseven
+6btlmdone8eight
+7qhmpdeight
+dxlb1
+zp9bqm4176seven
+5krrrsix6
+9seven4ninexsgrqs6
+9zzfj98fourpjzqtk9
+svsrlmggeightpgmprpkpj486twot
+sevenfourtwo8sevensix7
+zqspkktb831xjlhvfourtbtvpzmlbbt
+2gfffoursix5
+8ccqxqm4tsdpvvxpdpcrlmktmg
+5fivesix
+7fourone55two7fivenine
+9twothreethreeoneone
+xtzc64fourzkpcqjg7twobslssjln
+38fivetwo716
+hkxrxtdjzdzqnrzxfzsix3three
+onetwo8
+ppbrqlhvqpcfx2
+rhlbtdddqggnmfour74zcmrkdthree
+threesix3seven1one
+nine6six9eight
+mzmhvmrmtvsk5
+2qgbkrrgeightfzflbhpxctdpg39
+61two6
+2rzbdfmbczxcgphmonexmntkcmdxxpg6
+b6threetwosix791
+sevenmzlmcqxdbfmfj8ckchpkgxgmtmnzcninethree
+jvrpkltm9n9p
+two3bhlrgqjxbc6crzbvzmz9nqfdtztvqbhcrjptdvm
+jdjchvpkcrfive67fivegltkrflqsbktkc
+sevennine99jpkqljhfztbqrzm2twoctrgm
+rcmlkj5
+lltwo4ninestwoseven1l
+65threerzpkhjtzxl3jx
+ninesixninebdlfckbp2
+fourdqqklkgcsbtwobj5
+threesix44six2tctgp
+9zczcltwo
+vr6bmpl
+7fivelpfnzgct
+ninethreesix1twocqfpchfour9
+1jcj81tkklgrhhjt
+pntwonetwotnpnbmonennfblctcv91nqr
+jnsfspcg45xkc
+8eightqbhmrqc
+five5threerhxffonemkbnine
+16hqlvzjc
+3mzjkkr
+kcsrxhsnmqkz3two
+9ftxzstqrdjcqddvzdxljz6sixsbxlztnqgthree
+threeninesxt965six
+4threenine2417qcljfive
+4mqzxsnt3hqbhjj
+r9ctkhvtl51
+47kmgznjvcg5eight
+one5rv9ztvpt1
+2one3htxp3three
+74six4bkqsjfgtdt
+two2onenine9fourfdqqrmx4one
+rvltwo9grrhsvgzr6pmnvrnlxb
+ninefourrzgfgcfcvv8two8oneone
+1zg5seven3
+six91xgqcs28
+5threemxxntrml
+3hjltzgdgcmfmstvgfivenxfour5eight
+five1dl8six8
+96lkghnglthree
+7sevenvggnkkjvzmjbbjgjhmtx53
+9onetwo
+6tmltdjvsevenfourfive
+ghqkskqmbnhnone7dphgvqjzbq834
+nllxconethree1
+fivez5lxtfpjxpfdtwo6twosevenkhtmqbm
+eightone4lnhlq3639np
+8cqcjfxvclskqqnbgq8
+qvsixgxlfsevensixhqtgmnmvk6
+twopfccg6nine4gdhrzdqrbm
+1hg72five
+kqrr96jhsfxgddncone4
+55xsfk4nqzqvthck4onerldsjx
+ninesbcqfdlvl1sixeighthdnhsh3eighteight
+rrspvpclvl7eightthreeqtfive
+twobfjrmffive6three9kqmqmmps4lrjzjqt
+fivefivejjxcmczlsdeighthdxbltgvjgthree8mp
+one46mhghdxldbfiveckljksxm
+c7fiveonesix
+sixnineseven8xqb48eight
+2mqxkvdmhgbnx
+sixkrknqflbz6
+6four9twogonesix
+cbxrknrrddnfour73ninexqdhlql
+rjtdxkjfs628eight
+xchpj2
+fhteightsdzsjqvhgceight43threefive
+426jqvrxqflhch9
+sevenmj3fiverfqzhhpvtbkrqglqzp
+2nine8fnz3five7xjzrp
+twofiveeightfivedcnpv74
+7fiverkzrthree
+gfctwonesevenhhcsvjqfourpfxjmthbcm5mttmfrb
+fourjc9threethreetwosixpffp
+sf9eight5fivenrlxfkjgq9
+hd48bq
+five21sixone
+vgkgfvnblrdbeight245nlfnnhfx
+3fsdrdmvrqptwothree
+ntcx82fivesevencvdkk5
+6gdmmvxcvp5sixthreecjtfkgnpmnthree4three
+xpkthreethreeeightxzkdv7mgrbzxhfive
+one98
+5foureightmqstc
+twothreejrhffour9twosxcj
+twoseven5five4ptz34
+1phdclsix
+3chbfpvfzj51tbhpvqhninefschztfbdm
+113tqmjkzjlgr
+kjdrfrnzhvone6bhv8zlllc2
+four1nine
+3pkxz8
+four1oneseventcspbzninenineqdg
+one9lsmfghl6pxhbmmzxpjjthree
+szlqptvcvskkcgxxtfrfivefive28pccjhzz
+7sixjhhzhgh
+onerxgnxcvprphgpzsixphrkdd97two
+twodhqbmrz11lg
+5ninectctwo2ninenc8
+hntt5
+chkjc4twokc
+threecsix62one8tgnsqxxvpjsix
+fhtjrljsevenfchxccpckl8
+nine61sixrqktdm9
+threepkzmnmnmmngxrcq7
+4dtfivehdvcknmkj4sevend3tx
+njcvzpmp8gmgvtoneninecnhgj3five
+4pvqncghvr4pmlone
+2eight4596bs6
+twosix93fclbgfive9fourxnqdhkg
+8onektghncz3dcklzvbdtwovsnlrcclpc
+221threegtmppngzseven
+jrhvplk55five7keight
+4eightktndbfzfmskcjlm1
+fskbxxvvsmsevenrzqrcgninemscc8vnvzseven
+kbtsf6sixczlbqzrjfm9oneightmqg
+vvn3threefour6sixseven2
+6jfourzkhlllkseven
+2twodxxhhns4gdjqmztnine
+sevensfxztmfive7twofourqbzlzkjc
+vqcblfvrgfourfiveseven7
+6nineseven4
+bnfivevbjgfzcctrhncmmnpfzmcdt4six
+two8onesevenonecmtddxnfbjeight7
+4sixfourdgmstmsj
+7eight97kzxxdbdonejtsjqgjcdlssix
+vtvdone2cjzcjltcj6six
+ztwobmrvcbfsnine4one
+jjblshvzsevenfoursix1ndqlgphrbbfkkcmstlsoneightfjm
+5seventwofive
+onebk4
+61bgcdfjsevenhhcjjgdqhr
+6kdvfpsevensevendg3
+61gslvnlcjlsfgdsflqp1rnqdgktfseveneightwom
+rvcmkdtqqglcvsxkntfour32bdptgseventhree
+zvsbhkftlpgntvfgfxpcztm9fournmvxjnine
+four91nptdgzk8rnmqc
+tqmtfsixbcxspjscnine2
+1kvmreighthnine2qxvrckqvgd5
+dcpvrl8two1fivec698
+xqg91snbsslnrptwoeightdzq
+gsnvsix4vdmszmjfourfnrnine
+9nineeightthree51gl2
+7sixffvf9two
+bbgqpxghsb45seven312eightworg
+fournineeight45five4fivebrznpkz
+dhrsrghxfivejdrqfgkdlxzb869
+8nzxvsmrrcz1one5four
+3mmlzvzqptttbbmtgthfive1nine
+one9eightpzsmjvnptwonemkf
+fivejkgrclbthree5
+5fourtxxxvfthreelxcmghhtkqnrqzvts
+1tlhcscbd
+99six
+53sixthreetwoninedjsvdfourone
+fivefour7pbponectstmp
+six5tnl164htsv
+fivekbkjtjkxfszcqvppqqxdtwo29
+42threexpdfive
+9892
+lvlkqlzvsix7gbxhpxrdfh2zcgccjvblhpvxqshmbbjkpgpd
+two7sevenfourblphfkgoneone3
+7onenine6535
+59zv
+347threeeight
+8five49
+73four
+heightwosix99
+1foureight
+soneight1xzmfs8six7vpxcfq
+nine91
+pvxtkphg3gzgvqlfk9vhjvqmgszfivegd
+seventwo9six2
+2sqp
+3twoeight3
+8slnsxtteight429seven
+qfjtthmthree3twothree
+txrdqsp4oneqsprgjnnsc
+7kqgv3five1
+fourninegrfz2
+seventbbfrvjqlkvm47
+8pkqtpxfxrgpq1
+kqvseven4n5ksixdphmjk
+17j
+1m3
+ninefivefour6
+jrdmvztnncnhnp8onefourfive88
+kbvninetworblsd3fivesixhvhtxvgt
+4ninesevenkpfgcddkninetnhg
+9rdzsixsixtfbgzmhsgconethreedfxqqvv4twonem
+kvbeightsdtqrhsscpone6
+7fivezhxkkxlsonenine
+sevenone7threeddmjmsjrhprn
+eightsix5
+4bjmfskbtc37seven3eight
+grxbdmppllthreeeight53
+one8jnhgjpdbseven8bc5fivenine
+jvlmsfive43gqmpzseventhree
+jqj9twosix
+eightseven9
+fourninexdzbnqsvkdvbbkb6
+pttwone2nbone7gnpbllbhp8
+sxpkrnshj8fivefive9kfvgjpv
+4threepkvz2shljdn9hgrmznine
+6seven29gnhtvshpks77fourstkdf
+bmnfthree2threetwofive
+51
+jghxzhndrkfourtwo1
+jspckbhzfcqsbone26mfhkmqztnine
+5fgzbmgfivefive
+six18sxvchr
+rv7fivebdrtdl5twojt4cx
+twofourthreetwo5onejfm6
+threesixeight2
+9jrmdmzvlgnine6cjlphdnine7
+9fivembvhfrlnzbsevenngp73ninefour
+sixxtcgjvssevenmfiveseven15l
+threeseven6
+cknkdqrnxrjfbn818vstmprqbts
+4zfmxjxlkv7rdqhjfourfoureightcgvrpxfnrn
+ghzmpsgzrkztp8s4zl
+ninefour78rhtjfrqvh4
+one9qzkjtsix13
+sixfk72jjnrninertbzheight
+rxhvxzcp366one
+24eightthree
+teightwofprzdscnts4nv88
+eighteightshqcbqzxmbktwo54fourpdkf
+sixfhvgkfourfoursjxnstgqnjh2
+6two1vtnqbrhqjbnkm7six9six
+66threeeight
+lbdkggsncthree315
+8gqsrmseven3gvvxq99
+sltgzbgbmg1
+9twov6
+shhbqkcc71threecmkl
+cgqtpsjkglzszffcnineninesgvj1
+fourhqnlhrrsbrsevenkrgffivefour6eight4
+twojdccnhk6fivelddgrppkldtdlt
+4dlkn5x
+12sfdtvcqztxmtvvkds
+44one6jxjdbsjxpg
+7sixfmbbfxnjjhj5qkqfvfntonegdktrfl
+eightfourzkdxgqn8
+1fourthreetbvtpphj4rmrhlcbxbrqfdxszfour
+eight42onehpvrlbkglq
+9five2five5
+bnzbccq26mblqtjxlsbtdvm
+nineninelnknxhbfk4xssrlsdmsixoneltjseightwofzf
+8mleight7zhfsmsmpdthree
+mjcsr5tsktfpzc2nine7
+tmlxbkh79four7
+fiverzrfvlcdnmkn46onennxbbvn
+threefournine9
+snz6bcgqlhx
+4ninevqjlbfklgz
+8fsvsfiveone9fvdfiveg5
+eight5dhcgxjts
+ljldjmfmgtzclfhthkdtdthree4
+qrlmdjmkvvtwopdphfpmdd6fourxkblfqcx5
+62glckjgdvnpfourzlkphvrjffive
+nltxkzk2zhmqhfqq
+95six8xflfzhf3
+zsfvrpjx67
+two4vfivehglclslddsix
+gssccpnhjx5128foursxpgrgztdfour
+87fourpqdrxmvqdmxfrtzthree
+one85fmkj
+5rtjzsevenfive1thpzqxxm5
+bone78
+4three83947
+sixffkfmhzfkksevennllffhjvkxqhpjjtfl1
+foursixxvfst6twosbvjfvcb2t
+fgzthreekkpffive5four
+685jfttdmjq
+t4
+xqeightwojhbrrrqgdtbcqlhthreesixsreight7rxxgqntqdqlbnm
+stbmgqjdvqfour4
+dfour11gfcvx4nine5
+eight4fourseven5five
+six3seveneight
+four2sevenltvckjxjhjfslsvgpzxffivefive
+27one5vdtkjt4
+fourzpr1gxgone
+gtfive5hbqktbfour5g2tk
+nine2pqhqgprxrg9hgjj4
+twovcjkcsqznsix557psh2
+1fkpjccjffr7nine3gxzk
+5threezzbbvtcbvj4
+8nkbdhct
+8eight2
+six17ninetworpc4
+qljgkvq23eightfourfour
+onebblhxbnlhztgrkchlbtwo5
+sixthreevmngjjgpfourrrblxqvcl22
+mcnksthree81xrzrrrvnvdvbzfzlrgseven
+chjxhjjxthree3
+mrmxzpbxnh4sixrxskzvnjtlkjddnrpkbjhslbxjbkq8fsix
+2kgfmzeight
+plvslqzpbk7
+xsfq49ljfts
+seven2x9hpzbhqzpffoursix8
+5999one1mbnxmrqcxv9
+eight52prffgvvgznineseven
+l8onehqzcf
+sixkzxvqdgnbbmdtrvhzfouronekmklkjp34v
+98144threethreebvcjpllggz
+nine7twofive9sevenszvdrq
+jnvcprvbgtfourthreed9pm3
+tszbl9one5dfmsmkmlvfrlf
+537tmcrdxp
+sfcqfrrcqj26
+8fourfoursevensixmlmqzggmrfive
+kbmbxz1onelqtdxxk3
+45mxksixfour
+7zncmh2
+hzoneightsixfourzzlkmrnzptllthree2tpdjtsszxnjdhkgv
+ztpqbd68814five
+92gnzsvldmvhhzb8
+ninefour2sixseven1seven4vcnkgklh
+sevenfsjrdhclm7six8nlrhdpplbjg
+sevenlgd86
+pg75sixtwozk
+734eightone5gssxhffscq
+5sevendrxvkmfsjkgg5twocqpqlhksrp
+seven1cktfl
+mrs7
+2foursevenninelpzxthreetwojmbvfzs
+2rdsjl1three1
+xrkztslbkgdzgjjtst5six5fourthree
+twosixfhlldtwo2sevenfourknbfgnnjs
+nine699two9pp1
+9kdlfour8kzfm57two
+hlmscnhk1cqqzqbsxqglf9jgpjnfrjczeightspkkzrdqjd
+72six7mjsxfxtz5
+3sixonebkfgp
+fivefourvslvn2six
+19pshkt
+739bzfpltmtsevenfour27
+fvps6pprtjlq5foureightworm
+qds3zdsgzxvthreethreeeightdqjbtrfjbbj
+nine3148oneeight
+nineggvmffthree1fivefbkmmfvjkpcgsxrfzg
+7vlff9msmx3njb76
+hsthree4jfpvhxnceightkfseventhree
+hx3seventwonineklbq7six
+38zeightjlxj
+jdbqgmsix8
+seven8njthzbdrtninexkplhnrfourone
+tnhhzhjccjdtpleight3onegsevenxkqbmqzx
+4679scb2
+twos334fourfivefourfour
+sixseventwo356
+xnmsevennlr78jlfrbgb
+four7krmgzcclgf6dteighteight
+94mzfhdk
+7two43threecthree
+lztbgnscq7ggeightsevengtjpseven
+nbcrvpljfive1threefive5seven
+fc895
+eightlqzzlgrxv9gdfcrpkxkhzgbjtpcgncppm
+8cfjbngnd6371threedczkfqmptxtrqt
+6jblvpxskcnine
+onexvkxthreebcvnnrctsix1oneightsrd
+two66fourfourdnccpl
+3fourbqznm
+eight9lbz3eightfourmonethree
+2qpvlbbb
+threeoneone1mjhqfive
+2threenine
+two6qvxnnqj91eightfourkqxvhq
+rtsftmvb14
+kvzptdxdfsrm5four5three
+sixkfjjbccbeight3eight
+kjskjrnbfs29seven6
+68qxpjrz
+eight4cnmx9four9eightvbsvvsix
+6xvsptbqcsxlcdzcnzrninehhrjqjsixkk
+seven7vknjphhfbs
+rjmhjgmpzk22fjmtmtc7spgkfkqgcn
+three8ftxlktggjn2rfljxmlg9
+9threehlvtmftzfiveqghnvmtbseventwo21
+pceightwopbpbj3two2eightfive7
+lsdbf6five3nddpcnnine5xvqx
+2sevenseven86lldmhf
+8rqhnhsrcjnfzgpcclrmnlvbphrtgchpls9
+kxeightwoxsrvcbzhhbpdlrt22fhqfivefptwo
+bdseven2hnqccjqgxjvjk86xvbhddlbx6
+zszz4kqtsqjfpqmcxbndmbdseventhreeeight
+fourfiveoneseven83twotzblfpldfq4
+tgbxlthreezdfspjsnhrmrqxqj6cplcczt2pgsbfczn
+jzdkc6xfmhpqstvzzmvxk431
+7eightqbxcnsgxm
+5sixeight
+6sixvjstz
+4trxhdlkzqvjpzgpvfp1
+sixqhghvddcdn7blhptxp5htcf3
+nineksjvmvc2
+41krm9
+nine42sevenfive2
+zfivepkfqrgpkmxbmjbq6tgktpvnjvdjzsd
+gssrnnqmm7sixfivelklmggxgkdtlmlzqp
+64qsevenftmjzgs
+6nctkfbskghpqr7
+8nine3
+hkjoneight6seventhree9
+11nineeight9nine
+845fouronetwothree
+pfhb14v
+three21kdgcplbzzbeighteight
+4cszltd7ninerrmhjqmtrprtccpjnjgdbdtwo4
+five96
+2lkfbsnq64three
+srltvpbgnxvlksmfzpj2
+four9tpjvhhpsctclzpnsr1fourcttqvng
+gpjxncqsbp46vb9tqgnninetwo
+four1four
+6dtklvddhlprphffpnkrksfseventwonek
+eight4seveneight2onezfbnvjplvl97
+7ndvfp8qstcjdgzcfcninebj
+9beightbsbphgrnq1ninesixsvthrx
+bpxthreezkhjleightsbxmsdeightseven4
+fivemlfsninesix1nine6six
+4fivethree3qtqsbscnc
+four7dsix3kfhrrgbbnlzdfbgxsix
+hqckztqxgxeightkfmvvjg6tp4nine8
+tmgfmcl2twonedg
+fmvvcsix8nineninepqdrcmhdzsixtwohcnrss
+nine258foursevensix8eight
+8q
+pqjqrxnine2one
+9sixpbxr43sflnine3
+4onethreeonefoursixonefour
+1vnscdrnnfpkrj8mndxbqdrckzgdpnfdone
+threeseven7six8three3six2
+jvt24pjtnxdcpsthree
+7nxfpnfzrssvqqcnrjnine47
+cflhgfournine368
+62srjsxgr
+mnsix6fivefourjdnqfgjvp99two
+8five6fdvgctwoeightcsmspmxmbgjqzjhlhb
+seventgcdvchsfivefour9nine4seven
+bbzvxfvmxhqv26rp5
+2psmsflpgqmb
+eightnine4threekgfjmhbkhtxgr4threekxnmspvbfs
+seven9two84phzrrvftgpt
+xgpfkphfchzptzvconetxcp3qdmdn
+five2fddc8hdzrzgcgdtonesix
+one24sixtwo
+mxfltrcltqjmmtj4psbf
+jbrskjdtthvksk9mhfxjgdjt
+four96njn
+five8tqltpdxrklninednqkmgstlptpjhqvklnjhrvpzvpfr3
+onecsktmkt9
+seveneight1
+nineeighttwo1txhjjkqzqtnine
+37onegfcf253
+4ninethreepndgnfqpvqzxbxkpgp4eightwozg
+tfxnx999864three
+sixthree19
+3nineonefive
+rpht1onetztgngmeight
+9928two4six5sp
+gmhtwooneclqfdqvfivefour5
+two3dkkfive
+7four6pklfxjqhgbvnpxmndsixthreetwoeight
+5eightthreeseven9
+9fourseven5pmtcdpfvhjj
+24fhbms2sixtrjtm
+seventwob99
+3mffcdvdqsixgxtbrxqddkrzclz92
+5fivenkmtgbsnsixeight
+3seven9hcbmcnjvqfour7
+bvspr4jhjlnddp3eighttwosixfour
+kdvh5
+seven7hvcmdfkfour5nine
+1ksqzfnmhfqjjlklptmmpvxnine6
+fxp7hljzvndnd2mpqm8
+86qxntjqmljdqpdbftqfrfiveninefcxzdqctbjppc
+one62
+two23fivesgtsqpjrkvlbrfknjgcjbt
+29gkcpcfdlm3
+ninehzvhg2one
+ljv73tpfjvbhlxnpxqxhfivefivezxtzhlfsc
+three7637
+rnmkzqgtjpfbn3nine8nine9ttcsdbr
+jqtwo7fourone7dclxtnlnthree1
+872fivemjghskxcxmninexljstpvb
+9hdjtfkqsb8skkvpfpgqlctvlz
+nqnltrnsevenfbsixmnxrv87ffsjn5
+fkxzbxsbbfour17fivenine424
+ccbrxlskjzmrclgchlxlcpkck2
+one9sevenjgxrk33twonepjs
+5eightthreefivethreetwor
+zxqdnhnk51
+two39xctxpvsmfivenbtsmpcg3eight
+three52threevgj8
+1twom52
+3pthscht
+8ninegx3f8
+lzjvthree96jgfhfvsbv7qfour9
+threenineeight722ltvvxhdczjfivedcxbst
+fourgvlbxrone8btblnlbkmx51
+one5nine93fzxthreebzchcqjbrxxct
+3sjbbtbpkr1onectngpqpdfp
+5xdgpgpm
+nine9onev952
+fxc9seven
+fiveggdqqlspfoursevenfour5three
+7ninekhxpdgfive
+3fmkhhbztk
+737
+3kx2sixgrgslpfvvlfourfive7gbk
+1rqjxnfmzkvxxsixt
+fiveszkkmrtrctjgqvcfbg5r5
+6onefoursixntbbrjxfrfournpjbgcx
+sixgpbbbkhxdj4skfrvnnlmmhxcpfnxfive
+two37hjdklhtvtwonzhcqrbfv
+eightsix7
+four9253njcqvvhtgs
+fourfive3bxnvck
+ninelsrbgctxvn59six
+3jzqb7six69eightonenine
+73nine6tkrqsc3kthjdmdtmsixspvvr
+8691twothreeeighteight
+8ninetwo7nine21qpkbml
+3lttttwonemh
+8eight9onefpscrm5
+qgl38onevqjbfldcg
+dbcxgcfsf23jbb6eight671
+18pzgfqjsfourthree4bvqtxsh
+fiveseven7mdgmsbdphthreefivedpzjbjc
+7onemmspfpbfbftcpgvxhmh944cvdvlp
+96hpgcqlp8six
+two5jrrsix4dktmzkqgvb
+two93fourninekfkkgdxbvk
+93onesdnxqtwo
+jxmfmmvlxzseventhree5sfconeeightkrzdcvnhpvmfnz
+86gkxpqspnxs
+seven9pblxnnkkjffournjlkgqmonedxqseven6
+jtddqv7nzpsixseven
+vgjkbfnc29gskmmjmgsrbvghgrbtsbrdglszsix6gm
+gjglfour8three7five
+seven8ninetc4foursevenxfxlvmt
+sevenone21nine
+9onefouronevqrsthmlone
+8threemsrbrchmk22fivepjdxprpvplt
+rsqkrlnfpsixfive3three77
+twoeightseven2threejzgzmzzgqdrcmf
+three8lsctcbnhgkpr3
+4ktrtzn
+vqhvfxrxhpdgqhcrrczjlmhdnlzseventvtrrktd9twonenqn
+twonineeight7
+67sixeighthvfkjhtj5
+644
+onezdfz6
+6qmcd9ninenineninetwo8
+four7nine7
+4hjnndn
+1fqfqdqqxdnvhmqcp8
+rrhndnbpjjzhclhv9ppvlbtxklzfivejhxzcbpmd
+six7526
+8ninefkhszlp2
+fivesix34twocg14
+3sixfive
+2nine3
+2hv4rrfh3two8lr
+sevenrqbzmkmcn22
+56vrglvbcdtxxrnjrlhpffr
+mfddxflkqd4six
+bfsfnkqxc76rtpgss3pkqkksrcxnine
+83fivemnjdfnk85zqmssgfffourvgqjbn
+822
+dvxgqrbjpnqvpsfthkz6
+4fdlzcxeight8crmrztfdmthree7eightfive
+two9threefourtwo8vj2
+nine1jxpclfhj
+jrgfxlgblzqnr9mnfrcsixone
+5t3nine5
+twogxssevenoneseventdc3
+rvzcbtwofour4sixgfzk
+six22eight81ninepnscnlv
+eightfiveeightsevendxx1gh
+7nzlpbx864g5
+hxgdrrnnsix1sevennvmsvdvccpmfive
+1threevz9
+36eight4xvnrghgjf996
+nine8mmtqkffkthree8xpmsbksix
+1fivejrgqrjjnql2dvmcqdbjbsix
+15fiveseven1td3
+kmfmbhcmf62five
+36dxfoneninefivehrr6
+four54sixfzhq26
+1427qjseventhreefiveqhv
+eightghnnlddqdpm1
+9jbcfdjzjxreightlcpmdddts
+6ninesrdgkrfivefoursckkrfrpqqhgzeightwoj
+xmqsnjgskfour8eight
+9l8one
+four9jghzbrsix7seveneight4
+9tgsvk
+sxgkkbnlsbnbbc2ckqhzgdlsbhp
+6ktwohsvbeighttwo
+xgfrrnrlkgdqfxdtwo9fvthree
+5hqdvsdnrvr81sixsqjmbdls
+kkghseightsevenmtbtvplcjnqtscx6
+rveightwobhqtmjhsrptpzkbv3ninem
+3qpgbd2fourqdsnnbgmnsqgdb4
+mfive12
+52xqhpfdjgmeight13tcn3four
+6lkgjdj
+rvsvpt144lrtvrtpvd
+8fourfive8
+28dhzrtfcjlgchxbthree
+vvsixtwodxfz5six
+seven7rcp7
+threethree136gts9threenine
+9477
+seveneight8gmhthree8
+nn633sixzxcxthree
+two95rfcffourtwo3
+76nine
+cvhlpzsbmknkqpgsevenlkzvm7hnznjsbszgvxrmdnn4
+pnlqmxlmvkkpdgktwo1four41one
+4hgnhzkbmlvkqpqqptd93two
+lfsnfs7eightvdnghthree
+shpndlkr7five1three6
+sevenfourfivesckjjlzgv27four
+xhtpxlqssd3eight6two6
+48ckzhkk84seven1ggsffz
+33rqthree6jvqlbzllz
+4jfourthree6
+jkhflbhqhtmpmhmonebfbmcmczbspj9sttmnvnvgfivekz
+eighttwodk25sevenninenine2
+oneqqxfkffivesevenzqhvjtgjlrninenine1
+2nineseven82fivethreezzqfjm
+mh4
+3tjfmrtnff498
+five7three7three52eight
+jgrndnjckvc1
+9sixgvv
+six3rfpxrl9three1chczskrxthree
+6bjqqzfqcxvnxbkpq
+922
+loneightnznrcpd6cpfsmclp
+7five7qncxmfhleight
+bhsgbsdnsixnine4msnfmonerjbpvkqf6five
+4xrcrrllzh9two6zgcftpfqj47
+six31two5fourthreeeight
+gqhckrzrpltwo72znb4oneeight
+trsxcpls3pmqqrskpmfivehdqrptvdtq
+six3four87one
+46two3
+9fiveseven57vhmq
+jkrbkfsevencnvzp89vhmsdcfcthreetwonedrl
+9cvzvqfboneffive6jmnpjkvrjz
+82xrqjdqchdbvhxpninefourdhb
+3bqsrf
+fourtwosixsevensix9threesixthree
+3fourkgjbxbpsrtgsmgrjthree
+ndeightsevenfourtwo943
+471pn6
+bpstsix84four32
+gjkcq89ninegkckjpkz
+eightkgvmxlzlhrnrdpttdqbthree117
+vtdnlkqcg65
+btwone727onesevensixkhbnkvtlthfjfive
+twozspnzkssqseven413
+7nttlqthreenspcdrhdpn563
+six3nine
+4twodkrlmssknsgfourkcfrxskpntnine
+qgtgfxhfjj3pslzsttxpfive
+fivethree9ct55sevensix
+8twooneonesixjlszd1hlhbcgjf
+fivetwosixsevenmrzjqjtfourmrk7two
+pfnine6sevenone
+3threex94znone96
+79two2sixeightqmnbxcxf8
+oneeight5
+763lsdvlz24threed
+four9oneeighthdcrzqlnvxj6ninex
+7552twojhv4
+3rzxhddcfxone553one9
+sixsix8
+7seven26k
+86onethreenine1vlnmvghn
+sevenglrmsnngpf3mfblll3seven
+npdrbsxxpcpc3jzlpljsnlsrvdmvtr6one
+6894one
+rjzxs7
+7mllptmtwoqxrpgprvqrstmvvvvm
+sixone12
+225
+dcjzmcnbpptwothreedzqctmhm4seven3qhnbn
+oneone2six56jsmdjqcznjtwolcjvmpkxlj
+2sevenseven
+7cpnpkcqsstfourjthreenbzvrdgeightsevenhfnztth
+4phcrvcgseven4njn4
+three9fiveninefdv
+63ll
+9sevenx7
+9fivehvtfdckjnpvk
+gpkhmlrxs5two39
+kfvqv5oneonefiveonethree5five
+2mrjctkmlks4z
+8eightkrzkdxvrrjvtwo2
+fiveninesix9
+rhtnxkvthkpbqn4mtgtdnmmxmvmmzmcbt1
+mtwonexdljqqgbbnineqrgbqnqx7eight
+fiveeight8sfvzbpkeights4
+8threesix8two8hszvhcbonefour
+tpjtvpjgtnine2rbbfd
+zrxjftfg4b6three37four
+th5kktbzgmvkxhhcsqcrvtldnldml7seven
+4txnqnplsixzptgszd
+gzt5threefiveninetwoeightsevennine
+jtfrlffv17268
+qfour9six
+49vrbpqkkzct6
+14two
+nine2drdcd7sixpfvsblcxqsjshhg
+5onehfivefour8mnine
+5qlthree6hbkktrpbmgninepqtxq
+three8four
+ftm67qrmsix
+seightwoplhzgbvb7275
+qnqtbdmqd4
+onefive2lcrdjrzbheightthreegvc4three
+87eight4fiveninefiveeight
+1seven7eightfivezqcndfj5cmblgczd
+seven6rkxsvbs529fbgbtclkjhcljpkjbgmvz
+1twojxpxrgvvzq14ldngl9eight
+qkg2fivemrlzlhxxzcmfive
+one85four9six8eight
+7sixbgvdf4841
+hktntngtlfflzrdpfourninevlzpdrngvchg2
+6two115
+fiveninesevenqxgjrnk3two
+eightthree988nrclmr
+2one6
+6737jfive
+8four3
+4fivesvntkxfpnqhone94three
+7six1twothsd86
+98pczqhlqbzjlvfnine68
+xtqtwoneeightlvcjqfourckfour2nine
+9sixllhhqhfivemmoneeight9
+4czj3
+ggdlxrrxjl1jnndbgbdninesbcfhd2five3
+kszvbdfninethree5onevflrqffxmdonefour2
+1nkpmvbf75
+lnbgnkkfhseven5zfive2qcr
+seven75xcx
+2eightbzsp2pfg7eightv7
+fourone29
+4two5two9xcpkkjqxcfivessqqvhbbt
+ncnqg1sixt9ninedlfgsqhnxx6
+xrlsktwodnbcbonefvxxqgbrsdthree3seven
+klvsv73
+onezvbhrblrkzcrsevensix96jnpxjone
+nine6chd4
+bdvkqlrh9eight6eightninehq7
+fivexpx1vsrreightkp7dph
+3eightlrrlgck967
+xcntwone4633sixmkm1nine
diff --git a/2023/day-01/src/bin/part1.rs b/2023/day-01/src/bin/part1.rs
new file mode 100644
index 0000000..3fd213d
--- /dev/null
+++ b/2023/day-01/src/bin/part1.rs
@@ -0,0 +1,44 @@
+fn main() {
+ let input = include_str!("./input.txt");
+ let output: u32 = input.lines().map(process_line).sum();
+ println!("Result {}", output);
+}
+
+fn process_line(s: &str) -> u32 {
+ let mut string = String::new();
+ let iter: Vec<char> = s.chars().filter(|c| {
+ c.to_digit(10).is_some()
+ }).map(|c| c).collect();
+ assert!(iter.len() >= 1);
+ let chars = [iter.first(), iter.last()];
+ for char in chars {
+ if let Some(c) = char {
+ string.push(*c);
+ }
+ }
+ string.parse::<u32>().unwrap()
+}
+
+#[test]
+fn input_1() {
+ let result = process_line("1abc2");
+ assert_eq!(result, 12);
+}
+
+#[test]
+fn input_2() {
+ let result = process_line("pqr3stu8vwx");
+ assert_eq!(result, 38);
+}
+
+#[test]
+fn input_3() {
+ let result = process_line("a1b2c3d4e5f");
+ assert_eq!(result, 15);
+}
+
+#[test]
+fn input_4() {
+ let result = process_line("treb7uchet");
+ assert_eq!(result, 77);
+}
diff --git a/2023/day-01/src/bin/part2.rs b/2023/day-01/src/bin/part2.rs
new file mode 100644
index 0000000..5185b76
--- /dev/null
+++ b/2023/day-01/src/bin/part2.rs
@@ -0,0 +1,86 @@
+use std::collections::HashMap;
+
+fn main() {
+ let input = include_str!("./input.txt");
+ let output: i32 = input.lines().map(process_line).sum();
+ println!("Result {}", output);
+}
+
+/// Return the position of `needle` in `string`
+fn find_ocurrences<'a>(string: &'a str, needle: &str) -> Vec<(usize, &'a str)> {
+ string.match_indices(needle).collect()
+}
+
+fn find_min<'a>(matches: &[(usize, &'a str)]) -> (usize, &'a str) {
+ let (position, word) = matches.iter().min_by(|(x,_), (y, _)| {
+ x.cmp(y)
+ }).unwrap();
+
+ (*position, word)
+}
+
+#[test]
+fn test_find_min_1() {
+ let input = vec!((1, "eight"), (2, "eight"), (3, "2"));
+ assert_eq!(find_min(&input), (1, "eight"));
+}
+
+#[test]
+fn test_find_min_2() {
+ let input = vec!((4, "eight"), (5, "eight"), (3, "2"));
+ assert_eq!(find_min(&input), (3, "2"));
+}
+
+fn find_max<'a>(matches: &[(usize, &'a str)]) -> (usize, &'a str) {
+ let (position, word) = matches.iter().min_by(|(x,_), (y, _)| {
+ y.cmp(x)
+ }).unwrap();
+
+ (*position, word)
+}
+
+/// Return the first and last number on `s`
+fn process_line(s: &str) -> i32 {
+ let mapping: HashMap<&str, i32> = HashMap::from([
+ ("one", 1), ("two", 2), ("three", 3),
+ ("four", 4), ("five", 5), ("six", 6),
+ ("seven", 7), ("eight", 8), ("nine", 9),
+ ("1", 1), ("2", 2), ("3", 3), ("4", 4), ("5", 5),
+ ("6", 6), ("7", 7), ("8", 8), ("9", 9),
+ ]);
+
+ let matches = mapping.iter().map(|(k, _)| {
+ find_ocurrences(s, k)
+ }).collect::<Vec<_>>().concat();
+ let (_, min_number) = find_min(&matches);
+ let (_, max_number) = find_max(&matches);
+
+ (mapping[min_number] * 10) + mapping[max_number]
+}
+
+#[test]
+fn simple_input() {
+ let string = "onetwo";
+ assert_eq!(process_line(string), 12);
+}
+
+#[test]
+fn overlap_input() {
+ let string = "oneight";
+ assert_eq!(process_line(string), 18);
+}
+
+#[test]
+fn example() {
+ let string = "two1nine
+eightwothree
+abcone2threexyz
+xtwone3four
+4nineeightseven2
+zoneight234
+7pqrstsixteen";
+
+ let result: Vec<i32> = string.lines().map(process_line).collect();
+
+ assert_eq!(result, &[29, 83, 13, 24, 42, 14, 76]);
+}