summaryrefslogtreecommitdiff
path: root/2021
diff options
context:
space:
mode:
Diffstat (limited to '2021')
-rw-r--r--2021/Cargo.toml2
-rw-r--r--2021/day1/Cargo.toml8
-rw-r--r--2021/day1/input.txt2000
-rw-r--r--2021/day1/src/main.rs21
-rw-r--r--2021/day10/Cargo.toml8
-rw-r--r--2021/day10/example.txt10
-rw-r--r--2021/day10/input.txt110
-rw-r--r--2021/day10/src/lib.rs191
-rw-r--r--2021/day2/Cargo.toml8
-rw-r--r--2021/day2/input.txt1000
-rw-r--r--2021/day2/src/main.rs34
-rw-r--r--2021/day3/Cargo.toml8
-rw-r--r--2021/day3/input.txt1000
-rw-r--r--2021/day3/src/main.rs36
-rw-r--r--2021/day4/Cargo.toml8
-rw-r--r--2021/day4/input.txt601
-rw-r--r--2021/day4/src/main.rs107
-rw-r--r--2021/day6/Cargo.toml8
-rw-r--r--2021/day6/input.txt1
-rw-r--r--2021/day6/src/main.rs36
-rw-r--r--2021/day7/Cargo.toml8
-rw-r--r--2021/day7/input.txt1
-rw-r--r--2021/day7/src/main.rs29
-rw-r--r--2021/day9/Cargo.toml8
-rw-r--r--2021/day9/example.txt5
-rw-r--r--2021/day9/input.txt100
-rw-r--r--2021/day9/src/lib.rs90
27 files changed, 5438 insertions, 0 deletions
diff --git a/2021/Cargo.toml b/2021/Cargo.toml
new file mode 100644
index 0000000..9f555f1
--- /dev/null
+++ b/2021/Cargo.toml
@@ -0,0 +1,2 @@
+[workspace]
+members = ["day1", "day2", "day3", "day4", "day6", "day7", "day9", "day10"]
diff --git a/2021/day1/Cargo.toml b/2021/day1/Cargo.toml
new file mode 100644
index 0000000..a3c4e52
--- /dev/null
+++ b/2021/day1/Cargo.toml
@@ -0,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]
diff --git a/2021/day1/input.txt b/2021/day1/input.txt
new file mode 100644
index 0000000..ad1abff
--- /dev/null
+++ b/2021/day1/input.txt
@@ -0,0 +1,2000 @@
+173
+175
+171
+177
+179
+177
+174
+177
+178
+185
+189
+195
+194
+211
+227
+226
+227
+221
+224
+227
+228
+231
+232
+229
+226
+244
+252
+251
+258
+269
+263
+255
+259
+261
+232
+231
+241
+244
+245
+278
+258
+259
+273
+272
+281
+284
+288
+303
+306
+312
+313
+325
+327
+332
+335
+345
+346
+328
+329
+327
+330
+325
+326
+325
+351
+352
+353
+363
+364
+382
+402
+401
+380
+370
+371
+348
+359
+357
+366
+386
+401
+387
+388
+404
+409
+430
+435
+441
+475
+469
+475
+473
+478
+510
+507
+508
+510
+502
+500
+512
+517
+521
+519
+532
+533
+537
+538
+540
+541
+545
+556
+548
+543
+549
+561
+562
+563
+562
+561
+572
+574
+575
+568
+569
+570
+579
+591
+590
+602
+601
+581
+583
+593
+590
+591
+577
+576
+579
+581
+563
+559
+563
+564
+567
+569
+570
+582
+579
+601
+598
+583
+589
+591
+597
+611
+618
+621
+622
+641
+657
+658
+661
+631
+633
+646
+647
+652
+667
+670
+676
+680
+681
+683
+681
+687
+690
+683
+687
+690
+695
+691
+693
+696
+695
+700
+697
+696
+700
+713
+696
+693
+698
+701
+700
+699
+690
+692
+693
+696
+722
+744
+746
+758
+763
+768
+782
+776
+777
+787
+797
+800
+801
+789
+814
+815
+812
+790
+791
+790
+804
+813
+841
+845
+844
+848
+855
+847
+855
+858
+859
+858
+860
+867
+868
+869
+877
+887
+888
+895
+896
+904
+905
+907
+923
+932
+944
+945
+950
+955
+965
+990
+1019
+1017
+1025
+1040
+1041
+1066
+1060
+1033
+1034
+1047
+1057
+1060
+1061
+1068
+1071
+1080
+1081
+1090
+1096
+1097
+1098
+1099
+1093
+1096
+1100
+1101
+1112
+1118
+1119
+1121
+1123
+1125
+1126
+1152
+1155
+1149
+1161
+1166
+1178
+1181
+1182
+1189
+1190
+1176
+1169
+1183
+1196
+1183
+1205
+1207
+1198
+1200
+1186
+1172
+1162
+1177
+1179
+1175
+1163
+1164
+1170
+1168
+1171
+1173
+1172
+1174
+1175
+1172
+1173
+1167
+1169
+1173
+1176
+1177
+1178
+1179
+1181
+1185
+1186
+1196
+1183
+1181
+1176
+1190
+1200
+1216
+1240
+1238
+1234
+1224
+1247
+1257
+1258
+1246
+1233
+1234
+1223
+1229
+1231
+1232
+1231
+1232
+1249
+1255
+1254
+1257
+1268
+1298
+1300
+1302
+1325
+1337
+1339
+1345
+1348
+1336
+1341
+1342
+1343
+1344
+1343
+1336
+1351
+1360
+1362
+1359
+1357
+1358
+1364
+1370
+1372
+1373
+1374
+1378
+1409
+1390
+1398
+1410
+1411
+1417
+1418
+1431
+1450
+1451
+1452
+1456
+1468
+1469
+1472
+1475
+1465
+1469
+1453
+1457
+1458
+1474
+1464
+1454
+1457
+1460
+1467
+1469
+1470
+1455
+1456
+1468
+1476
+1498
+1502
+1500
+1514
+1522
+1529
+1528
+1516
+1511
+1516
+1521
+1503
+1523
+1498
+1515
+1527
+1526
+1527
+1556
+1567
+1586
+1607
+1616
+1615
+1611
+1612
+1621
+1599
+1600
+1601
+1625
+1632
+1633
+1628
+1656
+1644
+1646
+1669
+1671
+1675
+1676
+1682
+1681
+1658
+1657
+1671
+1669
+1668
+1669
+1670
+1691
+1708
+1709
+1708
+1724
+1731
+1738
+1748
+1766
+1767
+1769
+1756
+1757
+1758
+1759
+1760
+1773
+1775
+1777
+1780
+1782
+1793
+1813
+1795
+1796
+1798
+1797
+1804
+1806
+1811
+1812
+1813
+1818
+1822
+1829
+1824
+1814
+1811
+1806
+1825
+1844
+1847
+1837
+1841
+1844
+1836
+1825
+1828
+1841
+1846
+1839
+1840
+1847
+1856
+1869
+1870
+1871
+1879
+1884
+1890
+1888
+1859
+1861
+1873
+1870
+1871
+1876
+1885
+1886
+1887
+1888
+1887
+1895
+1888
+1889
+1891
+1890
+1884
+1885
+1854
+1857
+1860
+1841
+1837
+1838
+1841
+1859
+1863
+1865
+1866
+1864
+1853
+1855
+1865
+1867
+1875
+1876
+1877
+1880
+1877
+1876
+1886
+1894
+1901
+1903
+1910
+1901
+1903
+1905
+1911
+1913
+1928
+1938
+1940
+1946
+1956
+1951
+1953
+1955
+1961
+1957
+1960
+1967
+1966
+1970
+1976
+1979
+1980
+1979
+1967
+1974
+1980
+1974
+1975
+1976
+2005
+2012
+2015
+2022
+2023
+2024
+2018
+2017
+2024
+2041
+2042
+2043
+2074
+2075
+2077
+2084
+2090
+2091
+2096
+2097
+2100
+2103
+2090
+2063
+2081
+2082
+2079
+2095
+2093
+2095
+2103
+2084
+2093
+2098
+2116
+2123
+2124
+2123
+2117
+2115
+2120
+2121
+2132
+2138
+2146
+2158
+2162
+2163
+2167
+2177
+2178
+2183
+2178
+2198
+2174
+2187
+2196
+2221
+2224
+2228
+2232
+2237
+2238
+2257
+2262
+2263
+2266
+2280
+2287
+2293
+2280
+2281
+2289
+2290
+2289
+2291
+2307
+2316
+2322
+2321
+2320
+2335
+2339
+2345
+2348
+2357
+2360
+2361
+2367
+2375
+2380
+2382
+2389
+2398
+2384
+2388
+2390
+2367
+2369
+2371
+2366
+2370
+2371
+2379
+2364
+2365
+2368
+2369
+2370
+2377
+2378
+2390
+2392
+2398
+2402
+2393
+2404
+2417
+2441
+2446
+2453
+2459
+2462
+2463
+2464
+2476
+2477
+2481
+2482
+2483
+2477
+2481
+2489
+2500
+2504
+2491
+2490
+2487
+2474
+2475
+2476
+2478
+2489
+2491
+2498
+2501
+2513
+2514
+2532
+2546
+2547
+2553
+2559
+2562
+2580
+2588
+2590
+2602
+2601
+2608
+2613
+2616
+2623
+2626
+2651
+2652
+2654
+2650
+2651
+2654
+2658
+2657
+2660
+2654
+2668
+2669
+2662
+2665
+2647
+2660
+2670
+2672
+2680
+2677
+2678
+2677
+2684
+2677
+2678
+2684
+2702
+2703
+2707
+2727
+2728
+2738
+2739
+2738
+2757
+2759
+2766
+2771
+2775
+2788
+2790
+2794
+2797
+2800
+2798
+2801
+2800
+2802
+2803
+2804
+2831
+2820
+2821
+2824
+2827
+2813
+2816
+2826
+2827
+2829
+2834
+2835
+2841
+2849
+2854
+2855
+2867
+2877
+2894
+2900
+2918
+2917
+2898
+2899
+2901
+2902
+2903
+2901
+2919
+2920
+2931
+2939
+2945
+2946
+2934
+2936
+2947
+2956
+2955
+2958
+2946
+2947
+2951
+2955
+2957
+2960
+2964
+2965
+2974
+2976
+2992
+3009
+3014
+3015
+2997
+2996
+3003
+3000
+3006
+3026
+3019
+3031
+3012
+3013
+3020
+3010
+3014
+3018
+3019
+3031
+3007
+3017
+3018
+3031
+3033
+3025
+3037
+3039
+3033
+3000
+3001
+3003
+3014
+3016
+3034
+3033
+3035
+3038
+3040
+3038
+3020
+3018
+3020
+3021
+3039
+3043
+3034
+3036
+3043
+3059
+3074
+3076
+3090
+3096
+3103
+3101
+3102
+3113
+3114
+3115
+3119
+3127
+3146
+3140
+3145
+3146
+3147
+3151
+3152
+3153
+3154
+3144
+3149
+3157
+3163
+3172
+3175
+3180
+3206
+3207
+3212
+3215
+3211
+3212
+3220
+3229
+3230
+3226
+3227
+3256
+3296
+3299
+3301
+3303
+3301
+3302
+3308
+3324
+3323
+3313
+3314
+3317
+3318
+3317
+3330
+3358
+3360
+3369
+3363
+3368
+3371
+3377
+3381
+3385
+3382
+3379
+3381
+3383
+3385
+3386
+3389
+3388
+3392
+3396
+3393
+3391
+3393
+3394
+3398
+3400
+3403
+3404
+3408
+3424
+3425
+3426
+3424
+3415
+3417
+3420
+3439
+3442
+3447
+3454
+3478
+3480
+3477
+3478
+3470
+3472
+3477
+3476
+3477
+3479
+3509
+3519
+3542
+3547
+3548
+3564
+3565
+3569
+3570
+3584
+3591
+3590
+3589
+3598
+3603
+3605
+3609
+3608
+3628
+3624
+3644
+3652
+3654
+3648
+3650
+3652
+3659
+3661
+3675
+3676
+3690
+3692
+3699
+3700
+3702
+3703
+3706
+3715
+3719
+3720
+3725
+3721
+3730
+3722
+3740
+3750
+3751
+3752
+3761
+3763
+3778
+3777
+3778
+3780
+3777
+3794
+3793
+3792
+3802
+3803
+3806
+3817
+3814
+3823
+3824
+3825
+3826
+3831
+3834
+3835
+3844
+3856
+3857
+3864
+3879
+3904
+3906
+3923
+3933
+3935
+3934
+3935
+3937
+3935
+3944
+3941
+3936
+3937
+3935
+3936
+3935
+3937
+3938
+3949
+3950
+3949
+3952
+3953
+3980
+3989
+3990
+3991
+3992
+3988
+3993
+4003
+3969
+3959
+3964
+3973
+3981
+3987
+3986
+3975
+3982
+3981
+3983
+3981
+3984
+3992
+3991
+3984
+3999
+4003
+4004
+3996
+3992
+4035
+4043
+4042
+4034
+4027
+4051
+4052
+4048
+4051
+4049
+4060
+4059
+4062
+4061
+4063
+4062
+4053
+4056
+4067
+4055
+4057
+4058
+4072
+4077
+4075
+4060
+4057
+4058
+4061
+4060
+4061
+4060
+4070
+4088
+4097
+4093
+4105
+4107
+4105
+4103
+4105
+4109
+4086
+4111
+4112
+4115
+4110
+4118
+4119
+4127
+4128
+4129
+4130
+4134
+4136
+4135
+4138
+4139
+4140
+4135
+4158
+4137
+4138
+4158
+4157
+4154
+4156
+4175
+4176
+4179
+4184
+4198
+4196
+4199
+4180
+4188
+4193
+4192
+4201
+4200
+4192
+4207
+4220
+4218
+4230
+4229
+4247
+4248
+4249
+4253
+4254
+4256
+4265
+4266
+4272
+4268
+4273
+4295
+4296
+4305
+4295
+4310
+4311
+4312
+4311
+4314
+4307
+4305
+4294
+4306
+4321
+4316
+4326
+4330
+4331
+4337
+4336
+4337
+4338
+4340
+4342
+4345
+4347
+4345
+4370
+4384
+4405
+4406
+4419
+4420
+4435
+4439
+4443
+4445
+4447
+4431
+4424
+4433
+4418
+4417
+4416
+4417
+4420
+4424
+4440
+4442
+4454
+4461
+4481
+4483
+4479
+4480
+4484
+4485
+4495
+4498
+4499
+4524
+4527
+4528
+4539
+4541
+4545
+4543
+4559
+4569
+4571
+4568
+4573
+4570
+4571
+4580
+4579
+4580
+4583
+4588
+4589
+4590
+4597
+4632
+4625
+4626
+4618
+4621
+4632
+4642
+4644
+4647
+4650
+4665
+4669
+4666
+4673
+4674
+4677
+4681
+4686
+4651
+4657
+4658
+4664
+4665
+4667
+4685
+4688
+4695
+4712
+4714
+4715
+4717
+4731
+4734
+4738
+4737
+4743
+4745
+4752
+4753
+4748
+4763
+4768
+4769
+4771
+4774
+4801
+4802
+4830
+4845
+4850
+4847
+4873
+4883
+4884
+4885
+4886
+4887
+4896
+4891
+4913
+4914
+4937
+4938
+4953
+4959
+4979
+4984
+4990
+4982
+4979
+5008
+5007
+5008
+5004
+5015
+5017
+5038
+5066
+5067
+5069
+5078
+5091
+5101
+5086
+5088
+5086
+5092
+5097
+5098
+5088
+5070
+5072
+5083
+5082
+5073
+5077
+5080
+5076
+5073
+5065
+5066
+5068
+5069
+5081
+5082
+5084
+5083
+5086
+5089
+5092
+5095
+5130
+5133
+5119
+5129
+5130
+5138
+5140
+5148
+5147
+5150
+5151
+5155
+5163
+5188
+5190
+5192
+5189
+5196
+5180
+5191
+5193
+5197
+5182
+5162
+5163
+5147
+5154
+5155
+5168
+5207
+5216
+5223
+5228
+5227
+5229
+5221
+5218
+5221
+5219
+5220
+5230
+5259
+5260
+5233
+5256
+5258
+5251
+5246
+5230
+5234
+5242
+5245
+5260
+5261
+5269
+5281
+5285
+5296
+5297
+5296
+5297
+5298
+5313
+5314
+5313
+5319
+5313
+5322
+5324
+5325
+5333
+5346
+5354
+5355
+5345
+5347
+5349
+5350
+5352
+5339
+5349
+5345
+5361
+5362
+5363
+5404
+5398
+5424
+5415
+5420
+5433
+5435
+5436
+5437
+5438
+5455
+5454
+5460
+5455
+5453
+5454
+5466
+5469
+5471
+5481
+5482
+5502
+5503
+5501
+5484
+5460
+5461
+5465
+5466
+5470
+5454
+5460
+5486
+5482
+5483
+5502
+5512
+5514
+5516
+5518
+5525
+5526
+5521
+5515
+5518
+5521
+5528
+5539
+5557
+5561
+5577
+5571
+5572
+5579
+5576
+5577
+5589
+5592
+5595
+5596
+5595
+5601
+5587
+5560
+5563
+5562
+5571
+5598
+5606
+5621
+5636
+5637
+5663
+5665
+5678
+5677
+5678
+5679
+5684
+5687
+5684
+5688
+5691
+5690
+5693
+5696
+5707
+5725
+5727
+5731
+5734
+5738
+5748
+5767
+5768
+5763
+5767
+5758
+5760
+5791
+5777
+5778
+5782
+5773
+5776
+5777
+5791
+5792
+5793
+5795
+5781
+5786
+5793
+5805
+5807
+5818
+5822
+5821
+5826
+5827
+5846
+5847
+5864
+5886
+5878
+5873
+5868
+5878
+5876
+5881
+5876
+5888
+5890
+5893
+5894
+5895
+5900
+5907
+5908
+5915
+5916
+5937
+5936
+5927
+5938
+5945
+5944
+5935
+5942
+5943
+5945
+5948
+5977
+5985
+5975
+5985
+5998
+5999
+5996
+6027
+6047
+6031
+6033
+6034
+6022
+6023
+6025
+6030
+6029
+6030
+6034
+6046
+6055
+6061
+6058
+6067
+6070
+6077
+6069
+6088
+6084
+6090
+6100
+6102
+6107
+6111
+6108
+6103
+6104
+6114
+6118
+6107
+6114
+6102
+6112
+6113
+6115
+6116
+6139
+6135
+6143
+6154
+6155
+6160
+6163
+6160
+6163
+6169
+6184
+6176
+6199
+6205
+6204
+6219
+6222
+6231
+6207
+6218
+6219
+6221
+6222
+6221
+6200
+6194
+6203
+6204
+6210
+6209
+6210
+6209
+6210
+6230
+6238
+6239
+6245
+6249
+6264
+6271
+6262
+6275
+6252
+6253
+6240
+6245
+6219
+6220
+6221
+6222
+6225
+6231
+6236
+6238
+6267
+6272
+6273
+6278
+6287
+6286
+6287
+6281
+6264
+6269
+6270
+6274
+6247
+6248
+6259
+6264
+6267
+6276
+6281
+6286
+6284
+6289
+6287
+6275
+6247
+6263
+6261
+6264
+6265
+6270
+6271
+6272
+6271
+6280
+6282
+6283
+6291
+6302
+6303
+6315
+6335
+6361
+6358
+6359
+6362
+6363
+6349
+6348
+6355
+6357
+6358
+6357
+6375
+6374
+6367
+6342
+6350
+6354
+6353
+6354
+6357
+6369
+6371
+6382
+6384
+6371
+6403
+6402
+6412
+6413
+6415
+6416
+6417
+6418
+6419
+6420
+6438
+6436
+6438
+6443
+6454
+6440
+6439
+6431
+6442
+6441
+6444
+6446
+6450
+6422
+6424
+6418
+6426
+6437
+6438
+6439
+6449
+6451
+6452
+6463
+6464
+6475
+6492
+6499
+6506
+6519
+6548
+6545
+6543
+6556
+6565
+6567
+6564
+6553
+6554
+6556
+6564
+6584
+6580
+6581
+6582
+6584
+6585
+6586
+6595
+6596
+6595
+6598
+6575
+6594
+6595
+6593
+6591
+6602
+6603
+6575
+6573
+6577
+6586
+6587
+6615
+6624
+6647
+6677
+6678
+6679
+6683
+6682
+6684
+6689
+6704
+6709
+6723
+6751
+6754
+6755
+6757
+6758
+6774
+6787
+6791
+6816
+6837
+6838
+6846
+6847
+6845
+6847
+6850
+6864
+6863
+6853
+6874
+6875
+6874
+6883
+6891
+6899
+6918
+6920
+6921
+6937
+6934
+6935
+6951
+6950
+6969
+6971
+6976
+6978
+6979
+6987
+6989
+6987
+6989
+6991
+6990
+6991
+6980
+6979
+6963
+6964
+6968
+6972
+7000
+6992
+7003
+7006
+7019
+7022
+7028
+7040
+7035
+7034
+7055
+7063
+7065
+7066
+7071
+7079
+7092
+7102
+7118
+7115
+7121
diff --git a/2021/day1/src/main.rs b/2021/day1/src/main.rs
new file mode 100644
index 0000000..7e18b94
--- /dev/null
+++ b/2021/day1/src/main.rs
@@ -0,0 +1,21 @@
+use std::fs::File;
+use std::io::prelude::*;
+use std::io::BufReader;
+
+fn main() {
+ let file = File::open("input.txt").expect("File not found");
+ let reader = BufReader::new(file);
+ let values: Vec<i32> = reader
+ .lines()
+ .map(|x| x.unwrap().parse::<i32>().unwrap())
+ .collect::<Vec<i32>>();
+ let mut increasing: u16 = 0;
+
+ for index in 1..values.len() {
+ if values[index - 1] < values[index] {
+ increasing += 1;
+ }
+ }
+
+ println!("{}", increasing);
+}
diff --git a/2021/day10/Cargo.toml b/2021/day10/Cargo.toml
new file mode 100644
index 0000000..40d2066
--- /dev/null
+++ b/2021/day10/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day10"
+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/2021/day10/example.txt b/2021/day10/example.txt
new file mode 100644
index 0000000..b1518d9
--- /dev/null
+++ b/2021/day10/example.txt
@@ -0,0 +1,10 @@
+[({(<(())[]>[[{[]{<()<>>
+[(()[<>])]({[<{<<[]>>(
+{([(<{}[<>[]}>{[]{[(<()>
+(((({<>}<{<{<>}{[]{[]{}
+[[<[([]))<([[{}[[()]]]
+[{[{({}]{}}([{[{{{}}([]
+{<[[]]>}<{[{[{[]{()[[[]
+[<(<(<(<{}))><([]([]()
+<{([([[(<>()){}]>(<<{{
+<{([{{}}[<[[[<>{}]]]>[]]
diff --git a/2021/day10/input.txt b/2021/day10/input.txt
new file mode 100644
index 0000000..df5a5a3
--- /dev/null
+++ b/2021/day10/input.txt
@@ -0,0 +1,110 @@
+{[[<{(<{[{{[{[[]{}]{<>{}}}({<>()}{{}{}})]}{({[<>{}]({}[])})[{[{}[]](()<>)}<[{}{}]{()<>}>]}}]<(({{{(){}}{[][]
+<<<({((<{<([([<>{}]<{}<>>]{<{}<>>({}<>)}])>}{({(([()[]]{[]()})({{}<>}<(){}>))[(<<><>>[()[]]){{()[]}<
+<<<[(({{(([[[[<><>][<><>]]]([[{}{}](<><>)][(<>[]){[]()}])])([[(<{}<>>(()[]))(<[][]>)]]{{<[[]{}]{<
+({({([{{[[[{(<(){}><[]{}>)}]]][(<<([()[]](()[]))>[[[{}[]]{[]<>}](<()>[()<>]]]>(<(({}<>){<>[]}){<[]()>}>{[{(
+[([{(<[<<[({<[()<>][{}]>({{}{}})}({[<>{}][()()]}[([][]){()[]}]))]>>]>)<<[((([[{{()()}(<>{})}[(<>(
+{[[{<[[[[([[{[()[]]<[]()>}<({}())<[]<>>>]({<{}[]>}<<{}<>>>)](([(<>{}){[][]}]<[(){}]({}{})>)[((()){[]})<{{}
+{{<<((({(<[({<<>[]><{}{}>}((<>[])([]())))[((()[]){[]{}})]]{<([{}[]]<<>[]>)(({}[]}{[][]})><<([][])([][])>>}
+([[(<({[[{[{<[<><>]({}())>}](<[[{}[]](<><>)]{{()<>}[{}]}>{((<><>]<()()>)([(){}]<()>)})}{[<{({}())<<><>>}[(()
+(<((([[<<[<[{[()[]][[]{}]}{([]<>){[]{}}}]>]>>{{([[({<>()}(<>{}))]<{(()<>)([])}([<>{}}{{}()})>
+(<({{<(<{[{<{[(){}][<>{}]}{[[][]]{<>{}}}>}<(([[][]][<>()])[[{}{}][{}()]])>]}>{{{([<(()())>
+(<[{<<(<<<((<[<>[]]>)({[[]<>]}<({}<>)([][])>))[{<[[]()](<>())>{<[]<>><{}()>}}(<<{}<>>(<>[]
+<[[(((([[(<[{((){})<{}<>>}{({}<>><{}<>>}]([{<>()}([]<>)]<{()()}({}[])>)>)]{{({([{}<>])(<<>()
+<({<(<{[{<<[[[{}[]][()[]]](<()()><()>)]>>[(((([]<>){(){}})<{{}()}({}())>)[<[[]()]{<>[]}><[()[]][<>()]>])[(<<<
+([[[{(<<<([[[<<>[]>]]{<([]<>){[]{}}><<[]>({}<>)>}]<(<<{}<>>([])><{<>[]}<{}<>>>)([{[]()}<<>
+<({<<(<{(<<(({[]<>}{{}{}})(<<>[]><<>[]>))(<<<><>><[]{}>>{[()[]][()[]]})>>){{<{([{}()]{<>()}){<[][]>({}<>)}}
+(([{{(<[([([([[]()]({}))<<[][]><{}()>>][[[{}<>][<>{}]]]){[{[[][]]<{}{}>}<<()<>>(<>())>]}])<{{[(({})<[]()>){[<
+{(<<[<{<<{(([[()<>]{<>[]}]{[{}{}]{<>()}})<([[][]]{[]<>}){(()<>)<[]<>>}>)[[{{[]}}]]}<{{((<>)<{}>){
+<{<{<{{[<{{<<<<>[]>{()[]}>><[<<>()>{{}[]}]<[{}]{[]()}>>}}>[[{(((<>{}]({}()))<<{}()>[[]()]>)}]{{({[<>()
+<[[<<([{([{{[[()()]<{}<>>][{{}()}<()()>]}({([]<>)<<>[]>}{[[][]][()[]]})}[((<{}{}><()[]>){<<>()>((){}
+<<{([[{[<{[<([()()]{()<>}>[<[]<>>[[]<>]]>{{[{}{}][()<>]}<[[]{}][{}{}]>}]<((({}<>)<<><>>){{<><>}[()<>]})>
+[[[[[{({((([<[<>{}]<{}()>>[<{}[]>[[]{}]]]{{{()<>}<{}[]>>([()()]{{}()})})))}[{{[({<{}[]>}<[[]()]>)(
+{[[<[([{((<[<[{}[]][<><>]>({{}{}}[{}{}])]{{({}{}){{}[]}><[{}[]]([]())>}>[{<{()<>}([]())>}]))(<[([[()][[][]]
+[(({[((<{<{<<[[]<>]<{}[]>>>{[<[]{}>[[]{}]]{((){})<[]>}}}<<<{{}{}}<<>()>>{<<>[]>([]{})}>>>}{[{{{<[]()>(()<>)}<
+{[[[{<([{[<{([<>()]{<>[])){<<><>>([]<>)}}<{[(){}]<()<>>}>>([[<()<>>((){})]][<<[]{}><()()>>(<[
+[{(<{[({[{[{{(<>{})({}{})}<(<>[])>}([<()<>>[()<>]]{(()<>)<{}()>})]{([{{}{}}(()<>)][{()()>])[<<[][]>(<>[])>
+[[{[{([<<<<([{[][]}{<>()}]([[]<>]<<>[]>))<{[<>()][<>{}]}[((){})]>><[[<{}<>>([]())]]>><<{{(()
+<{[<<[[[<{{[<<[]{}>[()<>]><{()()}<()[]>>][[[<>{}][[]()]][<<>>{{}[]}]]}{<<<[]()>({}<>)>>(<[[]()]{<>[]}
+{(([({{<(<<[(({}{})[()[]])<<{}{}>(()[])>](([()[]]<{}()>){{<><>}<[][]>})>((<{()()}[{}()]>[{<>()}
+<(({(([[<[{[{<{}>(())}{<{}[]>[<>[]]}]{<{()}><<()()>[{}{}]>}}]({<<<()[]>{()<>}>>}[[{(<>){[]}}((())
+{{<{<<(([[[{{[{}{}]{<>[]}}}{[<{}<>>[{}<>]]{{[][]}{[]]}}]({<([][])[<>]>{(()())<<><>>}}([([][]){{}()}]<{()[]}{[
+[<<<<<[{<{{({[[]()](<>())}{{[]{}}([][])})}(<<[{}{}]({}<>)>[<<>>{()}]>)>({[(<[][]>{{}[]})][[(()())<(){}>]{<()<
+{({<<([[(<(([(()[])]{{{}<>)((){})}))[([<(){}>[<>()]]{{<><>}})<({<>{}}(<>[]))>]>({[{([]()){(){
+<{[<(<{[(<<{(({}[])(<>()))}[{<[]<>><()[]>}<<{}{}>(<>{})>]>{{{<{}<>>[{}()]}}[<<()()}>(([]{})([]
+{<[(([{{{[(<<[{}()]>{(<>())[[]{}]}>){{[{{}[]}{()<>}]{(()<>)<<><>>}}}]}{(<[([[]][{}[]])]>)[[((<{}[]})[
+([[[({({{[<<[<[]<>><()>]>{([<><>])(<<><>><<>()>)}>[(([[][]]{()<>}>)([{(){}}({}<>)])]][(<<{{}{}}{()
+{([({[{{{[(<<<<><>>([][])>[<[]<>>[()<>]]>)[[(<()[]>)(<<>()>[()<>])]({<[][]>{[][]}}[<()()>[<>[]]])]](<<{<<><>
+<((({{<[[({[(([]<>)[[]<>])]{{<{}>{[]<>}}(([][])[()[]])}}{[{<()<>>[()[]]}{{[]<>}{[]()}}]}){([{{{}{}}[(
+{<<[[{[<(([[{([][])[<>()]}<{<><>}>](<<[][]>[[]{}]>[{<>}{{}<>}])]{<([()<>]<()[]>)(<[][]>(<>[]))>[{[[]<
+([{((<[<<([[[{<>()}(<>())]([(){}](<>[]))][[<[]>]]]<{<[{}[]][[][]]>}([<[]()><<>{}>]<{(){}}[{}{}]>)>)>({([
+([{(<<[<{<[[(<[][]>{<><>}){<<>()>}]{({()[]}<<>()>)}][{({(){}}[()()])<[<><>]<<>[]>>}]>}<<[({<
+{<({[({{<[[({{(){}}<<>[]>}<({}[]){()())>)<{([]{})([]())}>]]>(<{[((<>[]){[]()})<<()<>>({}<>)>]{{{()[]}}}
+{({[[<(<{[[{<<[]()>[()()]>([<>{}]{<>[]))}<{([]())(()<>)}<<[]><[][]>>>][({<{}><[]()>})[<[()[]][()()]>{<{}<>>
+{({(((<{<[<(<({}<>)[()()]>{<[]{}><()<>>})[<({}<>)><(<>)<()()>>]>(<(([][])<()<>>)<<<><>>([])>>{(<[]{}>
+[{{[([<<(<[<({<><>}{[]()})[{<><>}]>{<(()[])><[<><>]>}][<{[{}<>][[]<>]}(([]{}))>[[([])<{}[]>]{<(){}>({}())}]]
+{[<<((<<[([[([()[]]({}()))(<{}()>{(){}})][((<>[]]{{}{}})((()<>)<<><>>)]]{[<(<>[])<[]>>([<>()]{[]
+((({({{<[(((<[<>[]]([]<>)>[<[]{}>{<><>}])<{[<>()][()<>]}{<{}<>>[[]()]}>))<[<{(<><>)<()<>>}>[<[[]<>]<[]{
+{<<<{<({([({((<><>)[[][]]){[()<>]{<><>}}}<[{[]<>}[<>[]]][[()<>]{(){}}]>)<[[[[]<>]]((<><>))}(<<()<>><<><>>><[[
+(({{[({<{<{[[<<>[]>([][])]{<<>()>{{}()>}]{[<<>[]>[{}{}]][{()()}{[]<>}]}}([({{}[]}{{}()}){(()<>){()<>}}
+(<([({{{{<[<{{<>[]}{{}}}<[{}{}]<{}{}>>><{{(){}}([]{})}>](<[([]())[()]]>[(<[]<>>[[]{}])])>[{(<[[][]]<{}
+((({[{{{([<{{<<><>><[][]>}{({}())<<>{}>}}[{([]())}[<<>()>({}[])]]>{<[<<>[]]<()<>>][[()[]][<>[]]]>[{[[]
+<(<<[[<{({{[(([][]))([<><>][{}{}])]}})}>]](<([{{[{<{[][]}[{}<>]>([{}()])}]}([{{(())}{{{}{}}<[]{}
+<([<[{{({[(({({}{})<{}()>}))[[((<><>)<{}>)[[[][]]((){})]]<<<[]()>{()[]}>>]]{<<(<[]<>>[<>{}]){({}())}>>}}{[[
+[<<[(({<({{{[{[][]}{(){}}][<()()>]}((<{}{}>>[{{}[]}])}{<[(<>[])[(){}]](<<><>>({}<>))><(({}())
+[([{<{(([[[([{{}[]}<(){}>])]<{([[]()][[]<>])([{}{}]([][]))}>]({<<([][]){()<>}>>{([()<>]([])){{{}()}{[][]}
+{<({[<[(({{({<(){}><[][]>}[{<>()}({})])<[[{}]{<><>}]<<[]{}>([]{})>>}[(({[]<>})([(){}]<()[]>))]}))]><<(
+{<<[[<[[[((<[<{}<>><<><>>]<({}[])([]{})>>{<{()<>}>{([]{})[()[]]}}>[[<({}<>)([]{})>(<{}()>[[]()])][[<()<>><[]
+{((({(<{[[[({<<>[]><{}<>>}[{[][]}[<>()]]){([<>()][[]()])({[]<>}{{}<>})}]<<{[{}<>]<{}()>}<(()){(){}}>>{
+<[[{<<([<[{{(({}()){[]{}}){{{}[]}{<>()}}}}{<{[<><>]<{}{}>}(({}()){()<>})>(<(<>{})[<>()]>{<<><>>{[][]}}
+{{([{(((({<{[({}{}){{}{}}]{(<>{})[{}{}]}}[{[()[]][{}()]}{(()[])(()())}]><({(<>[])}((())<[]>))>}<{{{{{}<>
+({(([({(<<<((({}[])((){}))((<><>)[[][]]))((<()<>><(){}>){{{}()}(()[])})><([[{}<>][()[]]])(([<>
+<<<<<{({{([(([{}{}]<{}()>))][<<{<>[]}{<>}>({()<>}{{}()})>[([<><>]{{}()})([[]{}])}]){({[([]<>)<[][]>][{<><>
+((<[<<{{<([{{[{}<>]{{}<>}}([[][]]<<>{}>)}{[[[]{}]])]{[<<{}<>>{{}{}}><({}<>)>]([(<><>)[{}()]])})(<
+<(((<[(((<([[{(){}}<<>()>]]<{<<>{}><(){}>}<{[][]}{[]{}}>>)>{<<{{<><>}{[]<>}}{{<>[]}<[]()>}>[{{{}()}{[]<>
+{[<{((<<[<<([(()()){{}()}](([]{}){<>()>))>{({((){})({}())}[[()][<><>]])<([{}[]][[]{}])(([]{}){()<>}
+(<[({[(([[{[[<{}{}><<>{}>][<<>{}>]]([{<>()}<<>{}>]{{[]{}}({}())})}([({{}()}{{}()})][[<<>[]>[<>{}]]{<<>[])}])
+{<{(((<([[[<[(<>())[()[]]]<<()[]><{}<>>>>]<{({<>()}(()<>)){<<><>>{{}[]}}}{(<()<>><<>[]>){{[]()}[[]()]}}>][(<[
+<<[[<(({{{{<{{[]()}({}<>)}[(<>{}){[]{}}]>[<{[][]}{{}{}}>]}{{(<<>()><{}{}>)[{{}[])[(){}]]}(([()[]][{}[]]){<
+(<(<<<([{((<[[{}[]]{{}}]<({}<>)<()<>>>})<(<[<>{}]<{}<>>><([]<>)([]<>)>)[{<{}<>>[()()]}[(<>[])]
+<{(([([[<<([{{<><>}[<><>}}{[{}<>]{{}<>}}]{([[]()]<()[]>)[({}<>){[][]}]})({[((){})<<>[]>][{<>()}[[]<>]
+<<<{{<{[({<<[[[]][[][]]]({[]()}{{}[]})>>{[({{}<>}{[][]})[[{}()]{[]}]]}}([[[[<>[]]<{}[]>]{[{}{
+{<{{([([<{[[{([]<>)[()<>]}][{<()()>}<{{}<>}([]{})>]]{{[{[][]}<{}[]>]([<>()]{{}{}})}{(({}{})((
+<{<((<{<{([<((()<>){()[]}){[[]<>](()[])}><(([]()])<[[]()]{{}<>}>>]{({<()><()()>}[[()<>]<<>[]>]
+[<[{[(<<[(<<<(<>[])[[]]>{<(){}>}><([<>[]]{<>{}})[{<><>}{[]()}]>>{[(<[]<>>)<[{}<>]{<>()}>]{<(()())[[][]]>[
+[<<<{[(<<[({{{<>[]}<[]()>}{<<>[]>(<>[]]}})]>>{[[<({([][]){{}()}}[{<>()}({}())])({(()[])(<>
+[<[[<{<{{{{{<([]())[<>()]><{()<>}[<><>]>}}}}}><<{(([{<[][]>{[]()}}[{[][]}{{}<>}>][(({}())({}())
+<[[{{[<{<<[<(<<>[]>)<<()()>{{}[]}>>{<{()<>}[<><>]>[{{}{}}{()}]}]{(<([]<>)({}())>{<[]{}>}){[({}())]{(
+({{[(([(<{[[{(()<>)({}())}<({}{}){{}}>](((()())<{}()>)[<{}<>><{}()>])]({{([][])({}<>)}<({}())<[]
+{[(<[<{[(([<(<[]()><{}()>)<<[][]><()>>>][<<[{}[]]<{}{}>](<<>>{<>[]})>[{(<>())[<>]}<{[]<>}((
+[{{(<{{[{<<<<(<><>)>(({}[]))><<[[]{}][<>()]>>>({[({}{}){<>{}}]<[<><>]>})>}<[<{{<{}{}>{<><>}}}>]<(
+{<{<<{[{<[[[<<{}[]>{()<>}>(<()[]>({}<>))]{<((){})[<><>]><{<>{}}{<>()}>}]({([()[]]{[]()})}([{()()}}<(<>()
+[<<([(<[<[[([(<>{}){()<>}][<{}()><{}()>])]((([()<>]{()<>})[[<><>]]))][{([{{}{}}]<{<>}[{}()]>)[[{
+<[[{([({<<<(<([]<>)<<><>>>[{[]()}<(){}>])>>>({(([[<>{}]([]<>)]{[(){}](()())})([{<>()}([]<>)]))<[{[{}()]{<>[]}
+<(([{<{[[<({[({}()){{}[]}]{<{}[]>[{}<>]}}[[[{}<>](<><>)][<()()>({}<>)]])<{{[{}<>]{<>[]}}}([[{}[]]<<>{}>])>>
+{(<[([[[{[<[[<[]()>[{}{}]][<()[]>{[]()}]]>[[[(<>[]){<>[]}][{<>{}}<()[]>]]]](<{{([]())[()()]]<[{}[]][[](
+[([[[<<<{({[[{[][]}<()[]>]][{{[]()}([]<>)}({()<>})]))[<{<[<>{}]{[]{}}>({<>{}}[()()])}><<([<>[]]{{}[]})[<[][]
+{(({({<{([[[[<[]{}>(<>{})]{({}())(()<>)}]]<{{<[]()>(()())}{([][])}}<{[[][]]<()<>>}{(<>{})({}
+[{{<[{(<{({<[{[]<>}[[]()]][[{}<>]{{}()}]>(<[()()]>([{}[]]{(){}}))}{{{({}<>)<<><>>}({[]<>)<{}>)}})([<({
+(<[{{{{<(<[<{{()()}{[]{}}}<([]{}){<>()}>>[({{}<>}{{}[]})]][[({{}()}(<>[])){<[][]>[<>()]}]]>]>{[(
+[{<(<<{[<(<[<({}[])({}{})>]{<{{}()}<<><>>>{<{}{}>(()())}}>)>][({<[[<(){}>(<>())](({}{}){{}()}
+{([[{<{<{(([<([]<>)[<>]>{(<>[]){<>[]}}][<[(){}]{{}()}>((<>[]))])<({[()<>](()[])}){<[()<>]{<>{}}>{([])<()
+<[{[{(<<({[((<[]{}>{[]{}})([()[]]<(){}>))<{<<>[]>[{}]}{<{}<>>{()}}>]{{{(<>())}(({}<>))}<<{()<>}({}())>([{}<
+<(<[{{<{{[([{{(){}}<<>{}>}(<(){}>)][[{{}<>}(()<>)]]){([<<>{}>[()()]][{[]()}<{}()>])}]<{([{[]}([][]
+<[[{<{[<{([<[<[]<>][{}]]<({}{})([])>>]({{(<><>)[[]<>]}<<{}[]>[[]<>]>}))}([<(({()()}{[]<>}))<{<()[]><[]()>}(((
+({{{<{([{<[{{[{}<>](<><>)}[[<>()]({}[])]}[[<(){}>({}<>)]<(()())({}())>])>[<<<[[][]][(){}]><([
+((<{[<[[(((<[<<>()>([]())]<(()<>){()[]}>>[<{(){}}{{}}>[[(){}}<[]{}>]])<[[[[][]][{}()]]{[{}()][
+(({[[<{({[[[[[<><>]<[]{}>]<(<>{}){[]()}>][(([]<>){()[]})([<>{}]<()<>>)]]]}[[<{<(<><>)<{}[]>>}<<{<>
+<{({[{(([[{(<(()[])<(){}>>{<{}{}>{<><>}})[<(()())<[]{}>>]}[{{{[]}[()[]]}[<()[]><<>{}>]}{<[<><>]{[]
+[<[<<{<{{<[(<{(){}}[<>()]><({}<>)<<>{}>))<<<()<>>({}<>)><[<><>][()]>>](({({}()){()()}}<[[]<>]<<>{}>>)<[[[]
+{<{(<(<[<([{<{{}[]}(()[])>[({}())<[][]>]}<<{()()}[<><>]>>]<{{[[]{}]{<><>}}(({}{})[[]])}({(<>[])<<>{}>
+{{{[[((<[(<<[[{}()]<[]<>>]{<()[]>}>[<<()()>>([<><>]((){}))]>{<<[{}{}][{}()]>[(()())[<>[]]]>{{
+<({<{[{<[<({{[<><>]{<>[]}}<{[]<>}<<><>>]}{{[{}{}]{{}{}}}{<[]<>>{[][]}}})(<({()<>}<{}[]>){([]{})
+{<(<<[<{([{[({{}<>}[()()]){(()<>)[{}<>]}]}])}>]{{(<[<<((()())<<>()>)>{([[]{}]((){}))<({}<>)({}<
+[<(<[[{{[([[<<[]{}>{[]<>}>{(<>[])[{}{}]>]([[[]<>](()())])])([[<{<>{}}(<><>)><({}<>)<()>>][({[]<>}
+[<{({{[<([{<{[()[]][(){}]}>[([<>[]]{{}})]}<<((()<>}(()()))<[(){}]>>((({}())[{}<>]){({}<>)<<>[]>})>]{<<{<{}[]
+[[<{<{({(<{<{({}())[{}]}([()[]]{{}()})>}((([{}{}]{()<>})<[<>()]{<>[]}>)[([()<>]<<><>>)[[()[]]{[]}]]]>){([[[
+{<(([<<[<{(((<()<>>{{}()})({[]{}}[[]{}]))(([{}[]]{[]<>})<<[]>(<>{})>))}[{{<(<><>]<<>>>}}({[({}[])
+[[{{[([<[({[{(<>()}[<>[]]}{{<>{}}<[]{}>}]{{{()[]}([]{})}([()<>]{()<>})}}[<{(<>)<<><>>}{{<>[]}<<>[]>}>({<
+{{[{{{<([<{<{<{}<>>}{[(){}]{{}()}}><{{[]()}<{}>}>)[[{[{}{}]{()<>}}<(<>{}){[]{}}>][[(()<>)(<>())]({[]<>}[()[]
+((<({<{[(<[{[<<>><{}()>][[{}[]>]}{({()<>}[{}[]])[(()())]}][<<{<>{}}<<><>>>[{[][]}{<>()}]>]>[<({({}()){{
+[([<<({({[<{(((){}){<>{}})(({}<>))}{<[[]()][{}{}]>{([][])<[][]>}}>]<<(<{<>()}[()[]]>[<(){}>[<>()>])<<[{}(
diff --git a/2021/day10/src/lib.rs b/2021/day10/src/lib.rs
new file mode 100644
index 0000000..6cf54ad
--- /dev/null
+++ b/2021/day10/src/lib.rs
@@ -0,0 +1,191 @@
+use std::collections::VecDeque;
+use std::str::FromStr;
+
+pub struct SyntaxLines {
+ lines: Vec<String>,
+}
+
+impl FromStr for SyntaxLines {
+ type Err = ();
+
+ fn from_str(input: &str) -> Result<Self, Self::Err> {
+ let lines: Vec<_> = input
+ .trim()
+ .split('\n')
+ .map(|x| x.to_owned())
+ .collect::<Vec<String>>();
+
+ Ok(SyntaxLines { lines })
+ }
+}
+
+impl SyntaxLines {
+ pub fn part1(&self) -> u32 {
+ let mut result: u32 = 0;
+
+ for line in &self.lines {
+ let mut qopen = VecDeque::new();
+ let mut panic_char = ' ';
+
+ for character in line.chars() {
+ match character {
+ c if character == '('
+ || character == '['
+ || character == '{'
+ || character == '<' =>
+ {
+ qopen.push_back(c);
+ }
+ c if character == ')'
+ || character == ']'
+ || character == '}'
+ || character == '>' =>
+ {
+ match qopen.pop_back() {
+ Some(bracket) => {
+ let mut error = false;
+ if c == ')' && bracket != '(' {
+ error = true;
+ } else if c == ']' && bracket != '[' {
+ error = true;
+ } else if c == '}' && bracket != '{' {
+ error = true;
+ } else if c == '>' && bracket != '<' {
+ error = true;
+ }
+
+ if error {
+ panic_char = c;
+ }
+ }
+ None => panic!("Wtf?"),
+ };
+ }
+ _ => {}
+ };
+
+ if panic_char != ' ' {
+ if panic_char == ')' {
+ result += 3;
+ } else if panic_char == ']' {
+ result += 57;
+ } else if panic_char == '}' {
+ result += 1197;
+ } else if panic_char == '>' {
+ result += 25137;
+ }
+ break;
+ }
+ }
+ }
+
+ result
+ }
+
+ pub fn part2(&self) -> u64 {
+ let mut scores = Vec::<u64>::new();
+
+ for line in &self.lines {
+ let mut qopen = VecDeque::new();
+ let mut panic_char = ' ';
+ let mut result: u64 = 0;
+
+ for character in line.chars() {
+ match character {
+ c if character == '('
+ || character == '['
+ || character == '{'
+ || character == '<' =>
+ {
+ qopen.push_back(c);
+ }
+ c if character == ')'
+ || character == ']'
+ || character == '}'
+ || character == '>' =>
+ {
+ match qopen.pop_back() {
+ Some(bracket) => {
+ let mut error = false;
+ if c == ')' && bracket != '(' {
+ error = true;
+ } else if c == ']' && bracket != '[' {
+ error = true;
+ } else if c == '}' && bracket != '{' {
+ error = true;
+ } else if c == '>' && bracket != '<' {
+ error = true;
+ }
+
+ if error {
+ panic_char = c;
+ }
+ }
+ None => panic!("Wtf?"),
+ };
+ }
+ _ => {}
+ };
+
+ if panic_char != ' ' {
+ break;
+ }
+ }
+
+ if panic_char == ' ' {
+ while !qopen.is_empty() {
+ let v = qopen.pop_back().unwrap();
+ result *= 5;
+ result += if v == '(' {
+ 1
+ } else if v == '[' {
+ 2
+ } else if v == '{' {
+ 3
+ } else {
+ 4
+ };
+ }
+ scores.push(result);
+ }
+ }
+
+ let middle = scores.len() / 2 as usize;
+ scores.sort();
+
+ scores[middle]
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_example() {
+ let input: SyntaxLines = include_str!("../example.txt").parse().unwrap();
+ let result = input.part1();
+ assert_eq!(result, 26397);
+ }
+
+ #[test]
+ fn test_example_part2() {
+ let input: SyntaxLines = include_str!("../example.txt").parse().unwrap();
+ let result = input.part2();
+ assert_eq!(result, 288957);
+ }
+
+ #[test]
+ fn test_puzzle_input() {
+ let input: SyntaxLines = include_str!("../input.txt").parse().unwrap();
+ let result = input.part1();
+ assert_eq!(result, 392367);
+ }
+
+ #[test]
+ fn test_puzzle_input_part2() {
+ let input: SyntaxLines = include_str!("../input.txt").parse().unwrap();
+ let result = input.part2();
+ assert_eq!(result, 2192104158);
+ }
+}
diff --git a/2021/day2/Cargo.toml b/2021/day2/Cargo.toml
new file mode 100644
index 0000000..8aa34bb
--- /dev/null
+++ b/2021/day2/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day2"
+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/2021/day2/input.txt b/2021/day2/input.txt
new file mode 100644
index 0000000..9e714f9
--- /dev/null
+++ b/2021/day2/input.txt
@@ -0,0 +1,1000 @@
+forward 2
+down 8
+down 1
+up 7
+forward 4
+down 4
+down 3
+forward 2
+forward 5
+forward 2
+forward 7
+forward 8
+down 7
+forward 6
+forward 1
+down 8
+down 8
+up 9
+down 9
+forward 1
+up 1
+forward 6
+forward 7
+down 7
+forward 4
+forward 2
+forward 1
+forward 3
+forward 8
+forward 4
+up 6
+down 2
+forward 4
+down 3
+up 3
+up 2
+up 3
+forward 8
+down 5
+down 8
+down 5
+down 4
+down 2
+up 1
+forward 6
+forward 6
+forward 8
+up 5
+down 5
+forward 8
+forward 7
+down 9
+down 7
+down 6
+down 3
+forward 3
+up 7
+forward 2
+up 6
+forward 7
+forward 9
+down 9
+forward 3
+down 2
+down 2
+down 7
+down 7
+forward 8
+down 7
+forward 9
+up 7
+down 4
+down 8
+forward 2
+forward 2
+up 1
+forward 8
+down 5
+forward 8
+forward 4
+up 1
+forward 2
+forward 2
+forward 2
+down 9
+down 7
+down 9
+forward 9
+forward 4
+up 7
+down 4
+forward 9
+forward 8
+up 5
+up 1
+down 1
+down 9
+down 6
+up 8
+forward 2
+forward 7
+up 7
+forward 7
+forward 6
+down 6
+forward 8
+up 6
+forward 7
+down 7
+forward 4
+forward 9
+up 9
+up 8
+forward 8
+forward 3
+up 1
+up 4
+down 4
+up 9
+up 8
+forward 6
+down 2
+down 2
+up 4
+forward 4
+forward 1
+down 8
+forward 6
+down 5
+forward 6
+down 8
+up 1
+forward 1
+up 9
+down 8
+up 3
+up 9
+forward 9
+forward 2
+down 2
+up 6
+up 6
+forward 8
+up 3
+down 3
+forward 5
+up 2
+forward 1
+forward 1
+forward 8
+down 4
+forward 8
+forward 7
+down 8
+forward 7
+down 7
+down 2
+down 1
+down 7
+up 9
+down 5
+up 1
+forward 7
+down 5
+down 9
+down 2
+down 8
+down 4
+forward 2
+forward 2
+forward 1
+down 6
+up 7
+forward 2
+down 1
+down 5
+forward 3
+forward 8
+down 4
+up 2
+up 9
+up 7
+forward 7
+forward 4
+up 8
+up 3
+up 4
+forward 6
+down 7
+forward 7
+up 6
+down 9
+up 6
+forward 4
+up 3
+down 3
+up 6
+down 9
+down 6
+forward 7
+forward 9
+forward 2
+down 6
+up 3
+up 9
+forward 9
+forward 8
+up 4
+up 5
+forward 6
+down 5
+up 4
+up 9
+down 8
+forward 5
+up 5
+forward 7
+forward 6
+down 8
+down 5
+down 2
+up 5
+down 8
+forward 7
+forward 7
+up 6
+forward 3
+down 8
+forward 5
+forward 8
+down 7
+forward 6
+down 2
+forward 2
+forward 8
+down 4
+forward 5
+forward 7
+forward 5
+forward 8
+forward 9
+forward 6
+down 6
+up 7
+down 9
+forward 7
+forward 1
+up 2
+forward 8
+down 1
+up 9
+forward 7
+down 2
+up 2
+forward 5
+down 4
+down 3
+up 8
+up 6
+forward 3
+up 4
+forward 3
+forward 1
+forward 1
+up 9
+down 2
+down 9
+up 4
+forward 4
+forward 4
+forward 2
+forward 5
+forward 9
+forward 7
+up 4
+up 5
+down 5
+forward 9
+down 1
+forward 2
+down 6
+forward 9
+down 4
+down 2
+forward 2
+up 7
+forward 7
+forward 8
+up 9
+forward 3
+up 1
+down 5
+forward 5
+down 1
+up 5
+forward 4
+forward 5
+up 3
+down 4
+up 6
+up 1
+down 2
+forward 6
+down 8
+up 9
+down 7
+forward 9
+down 8
+forward 3
+forward 8
+down 1
+down 7
+forward 6
+up 6
+down 1
+down 5
+forward 6
+down 7
+down 2
+forward 6
+forward 2
+forward 8
+forward 7
+forward 2
+down 7
+up 2
+down 7
+forward 8
+forward 8
+forward 2
+forward 4
+down 1
+down 6
+down 1
+down 4
+down 4
+down 2
+down 7
+up 5
+up 5
+down 1
+forward 3
+up 1
+down 3
+forward 9
+forward 4
+forward 7
+down 4
+down 4
+down 2
+forward 2
+forward 1
+forward 9
+down 1
+down 4
+down 1
+forward 4
+up 8
+forward 3
+down 6
+forward 5
+forward 9
+forward 1
+up 8
+down 7
+down 8
+forward 4
+down 4
+up 5
+down 3
+forward 3
+down 6
+down 1
+down 9
+forward 8
+up 5
+down 7
+up 7
+forward 3
+up 5
+up 7
+down 4
+up 2
+down 2
+down 8
+up 6
+down 4
+up 1
+down 8
+down 4
+forward 7
+down 4
+up 3
+down 9
+forward 3
+up 4
+up 1
+up 5
+down 4
+forward 4
+forward 4
+down 2
+down 3
+down 4
+forward 2
+down 9
+down 9
+down 6
+forward 5
+forward 7
+down 3
+forward 2
+up 8
+down 6
+down 8
+down 2
+up 9
+down 1
+forward 8
+forward 1
+forward 8
+up 4
+up 1
+down 8
+up 2
+forward 5
+down 3
+forward 5
+forward 4
+forward 1
+down 9
+forward 2
+forward 5
+forward 4
+forward 3
+down 7
+up 9
+forward 7
+up 8
+forward 3
+forward 3
+down 5
+forward 7
+forward 5
+down 4
+forward 6
+down 6
+up 3
+down 3
+forward 7
+forward 8
+up 3
+up 8
+forward 8
+up 4
+forward 5
+up 4
+down 7
+forward 4
+down 8
+down 6
+forward 7
+down 4
+up 7
+down 6
+up 5
+down 2
+forward 7
+down 7
+up 3
+up 3
+down 3
+down 5
+forward 3
+forward 5
+forward 8
+down 3
+down 8
+forward 3
+down 1
+forward 4
+up 5
+forward 8
+up 1
+up 4
+down 4
+forward 1
+forward 6
+up 7
+up 1
+up 7
+down 5
+forward 8
+down 1
+forward 1
+forward 6
+up 9
+up 6
+down 4
+forward 5
+down 1
+forward 7
+down 8
+up 3
+down 9
+down 1
+up 7
+up 6
+forward 8
+down 9
+down 4
+forward 4
+up 7
+down 3
+forward 5
+forward 8
+up 5
+down 7
+up 2
+forward 3
+forward 3
+forward 4
+down 1
+forward 5
+forward 7
+up 7
+forward 7
+forward 1
+forward 3
+forward 9
+down 3
+forward 5
+down 9
+down 7
+down 4
+down 8
+up 3
+down 1
+up 5
+down 5
+forward 2
+down 6
+down 5
+forward 2
+forward 6
+down 6
+up 6
+down 8
+up 1
+forward 4
+forward 2
+forward 1
+up 1
+forward 5
+forward 3
+forward 7
+down 9
+forward 3
+down 9
+up 5
+down 7
+down 2
+down 3
+up 5
+up 3
+down 2
+forward 4
+forward 1
+down 3
+up 4
+down 8
+down 1
+forward 6
+down 3
+forward 9
+down 7
+down 3
+down 4
+down 5
+up 1
+forward 8
+forward 2
+up 3
+up 7
+up 1
+forward 3
+forward 9
+up 5
+forward 6
+down 8
+down 9
+down 5
+forward 6
+forward 3
+forward 8
+forward 7
+forward 9
+forward 2
+up 9
+forward 8
+down 2
+down 6
+down 9
+down 5
+forward 1
+down 7
+forward 2
+down 4
+down 1
+up 1
+down 2
+forward 5
+forward 8
+down 9
+up 6
+forward 8
+forward 3
+up 6
+up 2
+forward 8
+down 8
+up 1
+down 6
+down 2
+down 6
+forward 5
+forward 6
+down 4
+forward 1
+down 4
+up 7
+forward 4
+up 1
+forward 9
+forward 7
+up 3
+down 7
+down 4
+forward 3
+forward 8
+forward 6
+forward 6
+up 1
+up 2
+up 8
+down 7
+forward 8
+down 5
+forward 6
+down 1
+down 9
+down 2
+forward 6
+up 3
+down 5
+down 6
+forward 1
+forward 2
+down 3
+forward 8
+forward 1
+up 5
+down 8
+down 4
+up 9
+up 2
+forward 7
+forward 9
+up 8
+up 6
+forward 1
+down 7
+up 1
+down 3
+forward 2
+forward 3
+down 3
+down 2
+forward 3
+down 7
+forward 3
+forward 7
+forward 7
+down 8
+down 4
+forward 3
+forward 4
+down 7
+down 9
+down 4
+down 2
+forward 7
+up 8
+down 4
+down 3
+forward 9
+down 5
+up 6
+up 2
+down 5
+down 6
+forward 2
+forward 8
+down 1
+forward 6
+up 7
+down 6
+forward 4
+down 2
+down 5
+down 9
+forward 7
+up 4
+forward 9
+up 7
+down 4
+down 6
+up 9
+forward 1
+up 7
+down 5
+forward 3
+forward 3
+down 7
+down 1
+down 7
+down 7
+down 1
+forward 8
+forward 9
+forward 8
+down 9
+down 8
+down 5
+down 3
+forward 4
+forward 1
+down 1
+forward 1
+down 7
+forward 7
+forward 3
+down 8
+forward 3
+forward 9
+forward 8
+down 7
+forward 8
+down 2
+up 5
+forward 7
+forward 4
+down 2
+up 6
+up 8
+forward 7
+down 9
+up 3
+forward 4
+up 9
+up 5
+up 5
+up 6
+down 4
+down 5
+up 5
+forward 7
+forward 6
+down 4
+forward 5
+forward 4
+up 7
+forward 8
+down 2
+forward 1
+down 9
+down 8
+forward 7
+down 7
+down 1
+forward 9
+down 7
+forward 6
+down 2
+up 9
+forward 1
+up 9
+down 3
+up 9
+down 1
+forward 1
+down 1
+up 6
+down 8
+up 2
+down 3
+forward 1
+down 4
+up 5
+down 5
+down 4
+forward 5
+forward 4
+down 9
+up 7
+down 7
+forward 7
+forward 6
+forward 8
+down 8
+forward 8
+down 1
+down 1
+down 8
+down 2
+up 2
+up 1
+forward 5
+down 1
+up 5
+up 2
+down 6
+up 8
+forward 5
+down 8
+down 1
+up 5
+down 1
+forward 4
+down 6
+down 4
+forward 2
+forward 2
+down 1
+up 4
+up 8
+down 6
+down 2
+forward 5
+forward 8
+forward 7
+down 5
+down 7
+down 3
+forward 6
+down 3
+down 3
+forward 6
+forward 6
+forward 6
+up 7
+forward 1
+down 5
+down 2
+up 8
+forward 6
+down 7
+down 6
+forward 1
+up 5
+down 4
+up 9
+forward 3
+up 3
+forward 9
+forward 9
+forward 7
+forward 5
+down 9
+forward 1
+forward 6
+up 8
+down 7
+forward 9
+forward 5
+up 4
+down 8
+forward 8
+forward 4
+down 9
+up 2
+forward 5
+forward 8
+down 8
+down 9
+down 9
+forward 4
+forward 8
+down 5
+down 5
+forward 5
+forward 5
+up 9
+up 7
+forward 3
+up 4
+down 8
+up 6
+up 6
+down 4
+down 3
+forward 2
+forward 9
+down 4
+down 2
+forward 4
+up 9
+forward 1
+down 8
+down 9
+down 9
+down 3
+forward 1
+down 5
+up 9
+forward 6
+up 4
+forward 2
+forward 2
+forward 4
+down 9
+up 5
+up 1
+down 6
+forward 7
+down 8
+forward 4
+forward 9
+up 9
+up 4
+down 5
+down 3
+forward 2
+down 8
+down 6
+forward 3
+down 2
+forward 6
+up 2
+forward 6
+down 7
+up 4
+forward 1
+forward 4
+up 4
+forward 6
+forward 8
+down 7
+down 6
+up 7
+down 2
+down 4
+down 5
+forward 1
+up 4
+forward 8
+forward 6
+down 8
+up 5
+up 2
+up 9
+up 5
+forward 6
+down 4
+up 3
+down 8
+down 6
+down 2
+up 3
+up 5
+down 1
+forward 9
+up 8
+up 2
+down 3
+forward 6
+down 1
+forward 5
+down 3
+up 1
+up 2
+down 5
+down 7
+forward 8
+down 8
+up 9
+forward 3
+down 8
+down 8
+forward 1
+down 4
+down 4
+forward 3
+up 6
+down 3
+down 7
+down 7
+up 1
+forward 3
+forward 2
diff --git a/2021/day2/src/main.rs b/2021/day2/src/main.rs
new file mode 100644
index 0000000..e0153a3
--- /dev/null
+++ b/2021/day2/src/main.rs
@@ -0,0 +1,34 @@
+use std::fs::File;
+use std::io::prelude::*;
+use std::io::BufReader;
+
+fn main() {
+ let file = File::open("input.txt").unwrap();
+ let reader = BufReader::new(&file);
+ let tokens: Vec<String> = reader.lines().map(|x| x.unwrap()).collect::<Vec<String>>();
+ let mut xpos: u32 = 0;
+ let mut ypos: u32 = 0;
+ let mut aim: u32 = 0;
+
+ for line in tokens {
+ let command: Vec<&str> = line.split(" ").collect();
+ let (action, value) = (command[0], command[1].parse::<u32>().unwrap());
+
+ match action {
+ "forward" => {
+ xpos += value;
+ ypos += aim * value;
+ }
+ "down" => {
+ // ypos += value;
+ aim += value;
+ }
+ "up" => {
+ // ypos -= value;
+ aim -= value;
+ }
+ _ => {}
+ }
+ }
+ println!("{}", ypos * xpos);
+}
diff --git a/2021/day3/Cargo.toml b/2021/day3/Cargo.toml
new file mode 100644
index 0000000..898e70d
--- /dev/null
+++ b/2021/day3/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day3"
+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/2021/day3/input.txt b/2021/day3/input.txt
new file mode 100644
index 0000000..b380427
--- /dev/null
+++ b/2021/day3/input.txt
@@ -0,0 +1,1000 @@
+011110011110
+101101001111
+000000010101
+100111001010
+110000011010
+011101010101
+011110001100
+010111111001
+111011100101
+011110000110
+010100001111
+000001001100
+110001001000
+001000100101
+010100011110
+010111011110
+110101001111
+011010111011
+000011010101
+100111011100
+010010100011
+010010011001
+000111010011
+111001000111
+100101111111
+011001101110
+110010101100
+001000010001
+110101100011
+101110001011
+010100000110
+001110011110
+011101100110
+001111101101
+000101101000
+100110000111
+000001010100
+111100010110
+000100100100
+001000110001
+101000001011
+101000100110
+110000101010
+010111110000
+111110010110
+011011111111
+111010100000
+100001000111
+011000001010
+011000010001
+101101100001
+011001101011
+111001001010
+000010110101
+101110100010
+001111111101
+011110001001
+000111100011
+010101001001
+111110111111
+111000111010
+001001111100
+000011000001
+011100010110
+110010000111
+000010010101
+110000001110
+010011111011
+001010100100
+111001010101
+001101000011
+110100110011
+110010100101
+001000001011
+111110011000
+110111011011
+110110101001
+010010100100
+111100001100
+100100001100
+110001111010
+111011001011
+010000010001
+110010100000
+010100011100
+000110001001
+010011000001
+111011010001
+010011111101
+111101110100
+110110101100
+010100111110
+100011001101
+000010000010
+011111100001
+100000101100
+100001110011
+100101100100
+000100001001
+101000000011
+110111101100
+100100101001
+001001101001
+000001010000
+001001111110
+111011111010
+001000011110
+110000100111
+010010010101
+011010001011
+100010010101
+010110101010
+011111001011
+110010011100
+111110101010
+000001111010
+111101110101
+101010110111
+100010101111
+000110101110
+000000010000
+000010100110
+111110010001
+000100110000
+110010011011
+101001000010
+010110000101
+100011100100
+110000110100
+110011000001
+101110001000
+010100011111
+111000100111
+110001100010
+100001101000
+101001000111
+111110100000
+000011000010
+110000000001
+111010000111
+100100111011
+101101110001
+111100110100
+100110010000
+001001001110
+100010001001
+101000110100
+011100001111
+001110100110
+110100001100
+101101001011
+000011111110
+101101010100
+000110110001
+011100011001
+111000111111
+011010101100
+111000100101
+100111011110
+011010100110
+110000101111
+110010000001
+100001110101
+110101011111
+111111000011
+101010010010
+000111111111
+000001001111
+101101010010
+111111001000
+001001110000
+110010011110
+110011001111
+100111101011
+011111000111
+110010111100
+010110000000
+110001100011
+111000100001
+011000101000
+100110001100
+001101011011
+011001111110
+011101000110
+110110111001
+110101001010
+111000111011
+100111010001
+100110000011
+010001000100
+001001001000
+010010001010
+010101101101
+001110001001
+101110011111
+010111001111
+110111001110
+100000101011
+010000111111
+101000101011
+101011010111
+000101110001
+100100010010
+100111011101
+111100000100
+100110000001
+000001000101
+101100001111
+100000101001
+010101010110
+000110010111
+011101001100
+000111111011
+000001100101
+100001011011
+111000101110
+111101100111
+011010010100
+101001001010
+110100110001
+111101011101
+000011101110
+011000100100
+101110000111
+011101110110
+111001010001
+011110000100
+011110001101
+100111100001
+010011100001
+001001101101
+001111111010
+010101000101
+011100000110
+100010001101
+011011101011
+110111001010
+101000010010
+111111100011
+000101111011
+001101010011
+100101000001
+101101100011
+101110010011
+011001100000
+110001111111
+011100101100
+010010001110
+111110101101
+010110001000
+000011000110
+101010011011
+000100111011
+001000111101
+010011111111
+011101100111
+111111011111
+001100000000
+101100001110
+101100001000
+100001011111
+100001000101
+000101011001
+010100111100
+110000111011
+010000111100
+011100110000
+101111110010
+100011110101
+100100110101
+100001100000
+101000100101
+111000001100
+010000001011
+110101010111
+011011001000
+100111000101
+011000000100
+110110011000
+101101101101
+100101110010
+001100001010
+010111000011
+111111100001
+100010111011
+110011001001
+000011011101
+001100101101
+010110011001
+111100110010
+011111001110
+100110001111
+000111101111
+011000110001
+001010001010
+000111010100
+010011110101
+011111000010
+000101000010
+111101011010
+110011111100
+100000001000
+100001000110
+101010100001
+000101000101
+100100011111
+110000101110
+000110000101
+001001011111
+100010011100
+000001110001
+110000010100
+011111010100
+001000001111
+000111000001
+110010001000
+001001111101
+111000001001
+001011000001
+111110010100
+110010001100
+010110110000
+011100100010
+011000101011
+001001000001
+011001001110
+111000010100
+000110000110
+011011000100
+011000010111
+110001011000
+010111011000
+000101110100
+000000011111
+001100111100
+000010100101
+000111110000
+000110000001
+000100101001
+101111110100
+010010000001
+001100010001
+101111001101
+111011111101
+000011110011
+111001011100
+010110110110
+000000001101
+010010000000
+000001010011
+101000010000
+101000001110
+010001000111
+111010011011
+101001111110
+000110101100
+100110101001
+100111111111
+101001101001
+110010010011
+011001011111
+111111110110
+101110010110
+100100001101
+010001111110
+111111101000
+100010100001
+011110010100
+101000110011
+010110110011
+011111001000
+100010100101
+110010010110
+111011001000
+101110001101
+000010110011
+001110100100
+100000011101
+011001100001
+011001101010
+001100011101
+000111101100
+001010001001
+111001101110
+110110001111
+001111001010
+001001000011
+001000010000
+000001111110
+000101101111
+001001000110
+100001101110
+101111011100
+111110010010
+010001100011
+101000100111
+001101000111
+111011110011
+000011000101
+111101001110
+110111111111
+011100010100
+110011110001
+001011011001
+000011010111
+011000001110
+000101010111
+110101110001
+001100001111
+110111010111
+110010010101
+100111100111
+101000000111
+101111000100
+100011100010
+000100100101
+111011110110
+001111100110
+011011000010
+100010010100
+010111110010
+100010110011
+111111111000
+011010101111
+101110111011
+101110101010
+001011001000
+110110001011
+110100101111
+001011001011
+110011010000
+000000100000
+100000110000
+101110011011
+100101101111
+010110100010
+000010100011
+000110110000
+111101000001
+011001010011
+000000001110
+000100110101
+111111111110
+001010101001
+001101100111
+010100000101
+000111001001
+101100101110
+011011110111
+011010000011
+000100101011
+100001100110
+000111011101
+000100011100
+000101100101
+011111111110
+111010111011
+100000100101
+011001011110
+010101100010
+010101111101
+100001000001
+001000100001
+010010111110
+100011001011
+011011000111
+110011010101
+111101100100
+001110001010
+110011111101
+111011011101
+001101000001
+101011011011
+100000111010
+010101110101
+000101011100
+011000011001
+111001010011
+100100010110
+111101010001
+110110011011
+011110110100
+101000110101
+101110111101
+011011011110
+000100110110
+100011011111
+111010101001
+011111011000
+101000101110
+110010111001
+111010000010
+110011011001
+110110010100
+111010011010
+000010110001
+011101100010
+110010110111
+010101001111
+011011001101
+101111000110
+010111010010
+101111011011
+100111101100
+001000001101
+010110100000
+001010100110
+111111000111
+100101000100
+100101001100
+110111010110
+101000101000
+100001001111
+110011110010
+111111101111
+110001111000
+010001110110
+101100000010
+000110000111
+001011100101
+101010100101
+110110001001
+000011011111
+110110101110
+101100110010
+101110101110
+101010110101
+000111000011
+101000011111
+001100000111
+101001111111
+100100011101
+111100011011
+000010111010
+111010101010
+101001010010
+101100010011
+010000110110
+011110110011
+001101110111
+110111110110
+001011000100
+101111100010
+011010011100
+110100001010
+100100110111
+000011010011
+000110111010
+001100100000
+100111011011
+001101101011
+101011101111
+001101100100
+111010010111
+100111111100
+101101000100
+000011111100
+011111001101
+110101001101
+011100100110
+101011000000
+100001010011
+011110111110
+011011100110
+110001011010
+111111110101
+001111111000
+100010011011
+100001101100
+110011010100
+100011000001
+011110111001
+010111110110
+100110001010
+100000000011
+001001101111
+101111011010
+010000110100
+101001011110
+100100011000
+101101000111
+011101001001
+010101110010
+000110000000
+000100111000
+010110111010
+110000011111
+011001011100
+010100110110
+011111110011
+111011011010
+001000101011
+000010110100
+011100101000
+111111100110
+011001110100
+000100011000
+010101010111
+001011101000
+001000011100
+110101101100
+010001000010
+001010010000
+111000110001
+101111111111
+011101011110
+001001111010
+001000100110
+000011011001
+100101100001
+110111000000
+100111011111
+111000110000
+110010111111
+000010010011
+100001100111
+010110100100
+001101001010
+101001100110
+010001110101
+001011000010
+010111110101
+000001001110
+010010100110
+111011001110
+101011111001
+000100000000
+111101001100
+100111011010
+000010010001
+100000010000
+101101000010
+110100010100
+111011111000
+101001100100
+001110101011
+000111001010
+111110000011
+001110100101
+101010000101
+010101010011
+110000111100
+101011001010
+010001011011
+010000011010
+000010101011
+100110110101
+100111011001
+100111010111
+000101100000
+101110000001
+100100001000
+010111000010
+000101001010
+001110010010
+111011000111
+001110110010
+111010000001
+011000100101
+000111100101
+100000100111
+100110011011
+001011100001
+101010100111
+011001111000
+000011011010
+001011101100
+010011011001
+000111111100
+010001011110
+111111011010
+111010010101
+110000010011
+001001101010
+000101011011
+100111111110
+110010101001
+111000011000
+011100101110
+011100010001
+001101110010
+101000111111
+101011011001
+110111000110
+001000010100
+000111000100
+010000101110
+001100100001
+111100000011
+111011101010
+000001111000
+100100010000
+110110000110
+000010111100
+110110110111
+010000011011
+101110000100
+011100100100
+010111001011
+001011010000
+000111010001
+110010111000
+001011011110
+000001100111
+010000101111
+110001100100
+111000001101
+000110011001
+010000010110
+101010001110
+111000111000
+011111011100
+111001110110
+111100010001
+110101111001
+001001010011
+010001111001
+001101101110
+010011000010
+000100011011
+000001101000
+001110100001
+100011010011
+100000011100
+011001010111
+110011011010
+100110001011
+011001110111
+001010001100
+000111010111
+110111111101
+111001101010
+001110001000
+011100001010
+010011101010
+111011010011
+000011001010
+100101000110
+100101010111
+110010100010
+010100101111
+111011011100
+100011100101
+101111111101
+001001110011
+110111101001
+100100010101
+010101100001
+100011000011
+001010010111
+011001001001
+110001101001
+010011100010
+111000001111
+010101111111
+001001001011
+000111110111
+100110111101
+011011110000
+001001011110
+011010101101
+111011101011
+010001100111
+110100001111
+100010110111
+000000010100
+100000010001
+010011010101
+010011100110
+100011111011
+110110100001
+110000100110
+110101100000
+110001101011
+110110100110
+101111101110
+011010101011
+101001010101
+110110111101
+100111100010
+101100100010
+101011101101
+010011010011
+001111011100
+100101010100
+101010101010
+010000011101
+011100000010
+100111101000
+111111010101
+011010101000
+001010110010
+111110010011
+110111011010
+010010111111
+111001100111
+010101111000
+000111110011
+111101000110
+001011000000
+110100100110
+101001110010
+101111011001
+111110000001
+011101110010
+011000010110
+101011010010
+100110011101
+000010011101
+001111110100
+110011001100
+111110111100
+011001011000
+001110000011
+110001001101
+111110111011
+110000000000
+010000110001
+000100110001
+001000101101
+001100110111
+101011001111
+110011110011
+010011100101
+001001000000
+011110100000
+001010110111
+110101111101
+001111000000
+100011011001
+100000001001
+000010101010
+110000100000
+111111101001
+111010101100
+101100110111
+110100011000
+010011000111
+010010001000
+001011001111
+001001001100
+100010110110
+111100111011
+111100101100
+000111111101
+101110000011
+100001011101
+111101110011
+100100000011
+111110011001
+100010111101
+110001001010
+111111100100
+010000110101
+001100001101
+001001110111
+110110101010
+011110010010
+101011010000
+101101110010
+010010110000
+011110100111
+010111000100
+010100000010
+000011110100
+111001011101
+010111100101
+110010101101
+011100010010
+001110111100
+011111110110
+001110100010
+000001100001
+011011110010
+000010111101
+001011111110
+111110111010
+001010101101
+100011110010
+001111110010
+011001110010
+100110101100
+010111010011
+001000010011
+111110110010
+011000000110
+011111111100
+000111110110
+110001110100
+101110010101
+010000111101
+011011101110
+011010100111
+001010000010
+100001100011
+110001000000
+101111100111
+101111110011
+001101110011
+110001110101
+100101010010
+010101011110
+000011111000
+000100001000
+101001110011
+011100110001
+000000011100
+111110010111
+101011101100
+110011101100
+110101011000
+010111001000
+111100001010
+001000011111
+010100111011
+101010101011
+001110001110
+100011000110
+000101101011
+110011010111
+111001011110
+111010100110
+010001110001
+011010101110
+101011110000
+001101010010
+001010000011
+011001000111
+010001000110
+010110011111
+001111011000
+000010010111
+100011110111
+111100111100
+010101010001
+100011101111
+011101011001
+001011001100
+001111000101
+110111011000
+011001001010
+010000000100
+100110111010
+000000111110
+011100100011
+100100111110
+000010011010
+111000000100
+001110001111
+011000101010
+011100110010
+110101000111
+110110111111
+101110110010
+000110100000
+110100001101
+000111101110
+111000111001
+000111111010
+010110111011
+000101110111
+111000011011
+010110001010
+001011111011
+100100100011
+011110110010
+000111110101
+110110011101
+000011000011
+110011001010
+000100101100
+101100100011
+010111000001
+110101100001
+011110111010
+111100101000
+010000100010
+110011000111
+010011011100
+100110101011
+000100001011
+101111000010
+010000010000
+111110000100
+111100011110
+010100111001
+100000011111
+010111110100
+100100110011
+111101111001
+100010011000
+111110101111
+010111001010
+110000101000
+001111111111
+000111100110
+000011101100
+011010001000
+001011010011
+110011111011
diff --git a/2021/day3/src/main.rs b/2021/day3/src/main.rs
new file mode 100644
index 0000000..10c1f81
--- /dev/null
+++ b/2021/day3/src/main.rs
@@ -0,0 +1,36 @@
+use std::fs::File;
+use std::io::prelude::*;
+use std::io::BufReader;
+
+fn main() -> Result<(), std::io::Error> {
+ let file = File::open("input.txt")?;
+ let reader = BufReader::new(&file);
+
+ let lines: Vec<_> = reader.lines().map(|x| x.unwrap()).collect::<Vec<String>>();
+ let mut bits: Vec<u32> = vec![0; lines[0].len()];
+ let half: u32 = (lines.len() / 2) as u32;
+ let mut gamma_string = String::new();
+ let mut epsilon_string = String::new();
+
+ for line in lines {
+ for (index, character) in line.chars().enumerate() {
+ bits[index] += character.to_digit(10).unwrap();
+ }
+ }
+
+ for bit in bits {
+ if bit >= half {
+ gamma_string.push('1');
+ epsilon_string.push('0');
+ } else {
+ gamma_string.push('0');
+ epsilon_string.push('1');
+ }
+ }
+ let gamma_rate = isize::from_str_radix(&gamma_string, 2).unwrap();
+ let epsilon_rate = isize::from_str_radix(&epsilon_string, 2).unwrap();
+
+ println!("{}", gamma_rate * epsilon_rate);
+
+ Ok(())
+}
diff --git a/2021/day4/Cargo.toml b/2021/day4/Cargo.toml
new file mode 100644
index 0000000..8842130
--- /dev/null
+++ b/2021/day4/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day4"
+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/2021/day4/input.txt b/2021/day4/input.txt
new file mode 100644
index 0000000..4c28ac7
--- /dev/null
+++ b/2021/day4/input.txt
@@ -0,0 +1,601 @@
+76,69,38,62,33,48,81,2,64,21,80,90,29,99,37,15,93,46,75,0,89,56,58,40,92,47,8,6,54,96,12,66,83,4,70,19,17,5,50,52,45,51,18,27,49,71,28,86,74,77,11,20,84,72,23,31,16,78,91,65,87,79,73,94,24,68,63,9,88,82,30,42,60,13,67,85,44,59,7,53,22,1,26,41,61,55,43,39,3,35,25,34,57,10,14,32,97,95,36,98
+
+17 45 62 28 73
+39 12 0 52 5
+87 48 50 85 44
+66 57 78 94 3
+91 37 69 16 1
+
+ 1 67 4 58 13
+25 54 34 63 87
+59 70 66 72 71
+33 17 8 20 85
+69 46 50 41 88
+
+47 63 80 15 90
+24 1 40 94 13
+56 62 74 81 95
+43 88 37 99 22
+57 52 33 84 49
+
+33 58 54 28 10
+ 7 82 97 66 92
+95 77 5 86 84
+85 91 94 21 69
+23 12 13 98 46
+
+ 1 63 58 23 0
+67 14 45 42 32
+48 64 83 10 13
+74 16 3 79 46
+44 52 95 25 6
+
+93 47 5 96 28
+88 76 70 0 72
+77 1 36 54 9
+14 17 75 64 15
+79 66 61 78 26
+
+23 75 96 71 76
+63 59 39 65 36
+95 21 67 41 74
+ 9 97 4 2 49
+32 17 81 0 56
+
+77 53 30 94 5
+ 4 42 87 25 24
+52 15 68 9 45
+56 89 98 47 34
+99 32 27 78 46
+
+75 70 99 65 41
+87 6 11 88 1
+ 4 42 64 98 78
+63 50 69 79 39
+67 46 17 97 26
+
+26 73 6 79 47
+67 51 64 16 60
+ 8 1 61 76 39
+13 57 48 65 46
+63 83 4 92 71
+
+97 93 21 88 80
+58 42 53 95 90
+49 29 30 26 22
+66 51 75 8 13
+ 5 39 19 4 96
+
+77 16 33 1 6
+54 91 60 56 88
+ 4 59 24 79 22
+36 49 17 97 27
+67 99 92 62 86
+
+78 18 59 74 54
+79 68 23 51 85
+47 42 92 58 12
+30 97 19 26 15
+ 1 62 94 65 70
+
+ 6 91 56 55 11
+58 96 21 50 53
+51 60 67 64 71
+12 25 44 47 39
+15 92 81 9 38
+
+98 16 31 21 30
+58 10 3 89 7
+79 20 60 74 26
+86 4 83 96 15
+94 29 44 41 34
+
+50 75 83 20 52
+65 85 41 78 38
+31 64 86 32 10
+25 82 13 61 22
+11 73 4 77 24
+
+56 74 26 20 62
+83 46 41 24 52
+34 28 76 80 36
+75 48 63 17 55
+69 47 22 45 60
+
+17 15 71 28 68
+12 76 27 25 14
+34 39 31 58 13
+75 67 2 26 42
+72 43 0 23 54
+
+37 43 18 76 47
+96 1 80 77 27
+13 89 16 4 6
+74 92 55 99 38
+19 75 52 85 81
+
+69 51 39 95 98
+90 61 91 6 21
+25 57 81 10 49
+67 55 43 96 17
+78 11 3 64 77
+
+51 66 8 62 60
+82 94 24 54 26
+59 91 97 37 77
+20 25 69 98 84
+38 12 65 35 61
+
+ 7 26 91 84 17
+23 52 86 19 24
+58 44 5 32 40
+ 6 27 89 76 92
+33 10 90 83 82
+
+44 61 68 70 87
+23 17 90 93 21
+92 54 95 46 14
+47 24 89 33 31
+26 80 35 42 78
+
+88 80 50 46 26
+ 1 97 92 51 74
+16 24 40 31 95
+47 85 61 99 12
+27 8 25 42 13
+
+ 8 59 37 87 44
+62 0 67 39 92
+79 81 54 24 93
+56 84 23 18 34
+72 68 29 11 91
+
+64 51 81 44 12
+49 20 23 36 53
+59 73 37 60 57
+96 65 5 43 14
+46 31 47 87 1
+
+11 13 72 30 3
+67 20 84 59 77
+52 87 97 51 16
+43 36 21 33 82
+41 96 91 93 29
+
+ 7 31 19 87 94
+92 68 18 57 23
+ 5 88 81 86 10
+99 50 37 33 25
+97 22 0 53 91
+
+78 39 41 44 89
+91 82 71 42 37
+25 93 67 53 9
+84 23 33 92 14
+74 45 57 86 50
+
+79 83 10 85 48
+51 29 93 87 21
+58 5 52 37 99
+80 1 18 46 42
+60 92 0 44 59
+
+79 76 54 14 42
+57 11 39 66 33
+86 62 27 61 26
+48 68 47 99 46
+78 90 9 36 98
+
+76 79 66 38 65
+67 91 90 41 93
+ 2 1 33 56 50
+46 9 0 61 62
+26 58 16 24 10
+
+20 22 86 58 14
+53 74 54 85 6
+ 2 96 40 72 78
+99 81 16 31 55
+11 57 62 51 32
+
+ 8 51 73 40 88
+83 35 37 98 27
+ 3 42 15 14 33
+ 2 38 52 82 71
+67 55 9 66 53
+
+94 99 54 18 14
+40 56 57 66 68
+28 74 48 30 0
+59 1 22 50 23
+13 71 6 26 15
+
+28 60 66 25 56
+49 68 84 10 38
+73 50 87 16 14
+79 26 29 18 2
+57 22 5 48 91
+
+61 78 3 95 87
+ 6 62 25 74 84
+22 71 93 57 20
+81 33 15 45 96
+38 14 19 72 26
+
+51 19 62 72 39
+36 83 6 33 9
+95 43 42 2 22
+94 99 23 97 11
+66 61 16 30 35
+
+51 38 7 24 82
+23 12 46 55 85
+43 97 45 61 67
+53 2 77 99 34
+17 93 25 9 72
+
+37 32 35 63 93
+40 16 51 99 88
+73 69 49 80 33
+56 54 18 87 71
+29 98 85 58 17
+
+38 4 55 72 33
+29 63 86 52 75
+ 7 47 34 53 14
+89 39 83 36 78
+ 6 21 15 18 96
+
+56 19 40 0 7
+61 33 50 66 54
+93 91 64 6 45
+51 90 94 18 37
+15 28 13 2 44
+
+18 79 4 56 15
+38 80 8 42 5
+60 11 53 23 27
+ 9 71 19 83 72
+39 97 98 99 7
+
+90 22 41 95 15
+20 18 7 70 49
+97 51 79 94 77
+31 89 50 40 9
+37 84 6 98 35
+
+38 56 94 55 0
+92 84 8 85 73
+86 81 76 35 1
+62 5 59 77 72
+79 97 60 11 70
+
+43 98 87 97 70
+53 55 35 8 64
+80 59 75 11 2
+17 95 13 38 90
+31 20 60 84 4
+
+38 19 10 73 86
+37 72 66 22 53
+ 6 41 20 21 92
+ 0 13 9 89 17
+43 61 80 60 65
+
+61 50 42 99 26
+11 51 52 83 64
+92 60 2 91 20
+95 10 14 94 98
+ 5 37 90 17 69
+
+82 48 51 32 78
+30 39 10 84 69
+94 5 60 92 89
+95 31 64 67 23
+96 20 33 66 61
+
+33 92 78 24 74
+45 34 73 5 57
+18 37 69 44 38
+25 30 53 87 64
+28 23 14 10 81
+
+39 82 40 64 86
+26 81 3 85 50
+71 75 91 65 96
+17 55 8 56 59
+22 36 73 90 0
+
+18 67 50 70 71
+83 8 75 55 29
+66 33 39 88 16
+32 84 78 59 0
+11 3 61 65 36
+
+ 1 12 66 59 9
+24 97 75 83 11
+45 16 14 31 71
+85 43 99 18 15
+61 56 80 69 29
+
+18 50 86 53 71
+67 36 14 24 55
+52 30 33 54 81
+72 51 39 28 42
+45 98 78 35 73
+
+60 86 68 58 37
+17 78 43 31 96
+33 61 34 45 36
+10 29 83 98 2
+88 73 7 84 50
+
+30 21 94 31 4
+20 68 91 55 51
+10 98 2 25 84
+64 97 29 28 58
+75 17 76 54 65
+
+17 11 88 9 66
+ 1 59 60 79 55
+30 46 83 67 91
+23 45 99 90 6
+81 33 8 13 76
+
+25 68 43 59 51
+56 14 41 52 16
+62 36 12 37 71
+83 90 81 91 0
+95 92 29 54 26
+
+53 84 85 18 10
+51 44 87 86 67
+ 4 81 82 77 30
+26 68 80 57 71
+22 83 47 61 14
+
+41 89 38 14 66
+70 92 26 97 53
+78 25 5 4 48
+54 86 31 23 0
+99 73 6 20 98
+
+18 81 96 60 47
+59 87 95 15 57
+34 17 26 7 42
+25 90 45 94 5
+10 41 32 20 98
+
+37 9 20 82 83
+84 14 62 3 76
+86 67 95 40 65
+57 26 1 19 69
+49 41 29 35 13
+
+29 74 69 92 48
+80 47 59 18 13
+98 5 64 89 83
+37 97 90 32 49
+25 87 39 21 63
+
+ 1 61 5 82 66
+87 75 18 23 63
+38 51 33 59 4
+21 14 17 97 92
+94 45 84 22 10
+
+86 93 8 99 54
+ 1 4 37 30 34
+80 17 50 74 97
+28 11 6 85 78
+94 76 92 63 79
+
+63 87 89 19 81
+72 90 71 96 16
+85 92 78 11 37
+50 17 68 82 66
+21 9 39 69 73
+
+30 63 90 5 45
+26 15 28 84 65
+ 1 23 0 12 17
+61 98 21 39 56
+67 51 3 8 42
+
+54 91 9 70 93
+75 58 89 53 19
+77 64 45 78 14
+ 7 31 99 42 51
+87 95 60 10 84
+
+98 35 66 42 85
+75 27 97 54 9
+16 15 60 44 49
+28 19 51 24 50
+59 18 37 88 39
+
+69 29 49 9 76
+ 4 83 64 33 2
+67 81 88 70 39
+85 73 97 15 8
+ 7 13 26 12 1
+
+57 3 65 28 87
+36 31 51 19 0
+56 77 41 20 76
+79 29 80 60 66
+55 61 8 30 15
+
+ 2 42 3 17 40
+10 56 91 52 23
+76 39 75 82 49
+50 36 99 9 53
+92 66 48 31 41
+
+16 51 80 95 23
+36 84 33 56 11
+49 46 32 78 85
+67 29 94 26 22
+76 6 30 37 0
+
+27 94 79 48 4
+55 81 22 18 88
+93 15 59 41 11
+67 43 24 92 65
+ 5 1 60 99 62
+
+ 2 51 42 84 82
+80 28 43 93 72
+81 57 13 45 66
+34 22 53 37 3
+31 46 70 77 79
+
+17 12 22 53 74
+23 49 52 60 40
+64 98 97 75 57
+58 81 85 89 92
+42 34 65 87 18
+
+13 8 54 25 11
+84 72 66 78 1
+22 82 48 85 62
+68 99 18 3 57
+64 41 80 94 71
+
+45 5 56 30 62
+10 50 78 13 34
+90 97 85 36 0
+86 35 80 55 74
+47 99 59 61 18
+
+79 87 81 45 95
+24 91 27 18 16
+51 35 34 46 48
+39 40 6 70 99
+ 1 82 63 32 50
+
+78 68 27 17 65
+74 15 21 38 24
+82 97 49 7 58
+19 23 87 79 22
+57 93 30 1 69
+
+64 13 40 21 89
+ 3 95 20 79 59
+80 46 91 54 1
+62 66 30 60 47
+26 99 55 25 2
+
+47 83 7 71 81
+ 9 72 12 20 96
+28 57 82 98 42
+34 59 18 69 1
+68 38 46 19 80
+
+43 39 48 84 87
+32 78 5 65 50
+86 13 20 22 70
+31 6 52 53 18
+73 25 4 60 99
+
+48 15 59 50 33
+93 99 46 70 21
+91 26 76 65 87
+10 27 78 5 96
+ 4 63 22 82 20
+
+88 63 66 48 37
+39 47 56 52 27
+81 18 33 12 59
+ 3 96 55 26 43
+42 4 7 28 22
+
+95 12 98 84 23
+37 35 78 9 61
+52 47 24 90 17
+55 87 18 80 41
+38 0 14 36 48
+
+62 72 56 78 8
+75 26 11 58 91
+38 74 52 65 45
+43 41 15 82 35
+89 27 21 54 0
+
+43 36 85 68 60
+26 89 84 10 80
+87 50 75 81 35
+12 46 6 70 59
+93 51 66 33 49
+
+68 32 0 63 54
+20 92 39 89 17
+48 60 87 36 14
+93 76 83 10 55
+64 74 80 11 41
+
+ 9 32 11 41 87
+78 22 8 72 75
+ 6 51 29 90 50
+21 68 47 2 7
+52 19 36 57 58
+
+83 36 25 31 99
+86 29 47 77 38
+13 51 20 59 27
+74 50 9 11 44
+52 95 81 2 70
+
+96 47 14 73 59
+84 87 7 4 46
+60 27 79 53 30
+58 28 55 5 43
+91 75 63 35 52
+
+41 66 27 50 56
+76 60 80 85 23
+ 3 21 37 74 95
+ 9 92 43 5 98
+79 49 88 24 70
+
+59 18 57 90 13
+79 29 12 2 0
+84 58 38 77 96
+33 89 43 11 44
+93 23 98 60 51
+
+58 86 28 17 1
+ 6 4 81 55 53
+84 27 38 12 83
+50 43 40 85 88
+26 72 25 41 44
+
+14 92 7 98 12
+44 11 71 64 26
+88 8 2 56 6
+59 0 15 33 51
+10 52 89 53 34
+
+52 4 5 63 50
+15 8 60 70 13
+33 79 21 39 34
+84 91 30 12 71
+61 31 41 9 66
+
+43 67 52 92 54
+17 21 71 78 60
+19 0 88 61 2
+14 66 87 12 37
+89 23 25 4 24
+
+41 62 7 66 33
+59 87 84 80 71
+73 97 25 85 60
+86 64 61 54 83
+22 18 63 81 27
+
+92 89 50 11 73
+41 48 62 80 78
+46 55 81 16 94
+97 45 5 13 40
+14 75 22 42 2
diff --git a/2021/day4/src/main.rs b/2021/day4/src/main.rs
new file mode 100644
index 0000000..4b2f9b3
--- /dev/null
+++ b/2021/day4/src/main.rs
@@ -0,0 +1,107 @@
+use std::fs::File;
+use std::io::{BufRead, BufReader};
+
+fn part1(grids: &Vec<Vec<u32>>, mut inputs: Vec<u32>) -> u32 {
+ let mut values = Vec::<u32>::new();
+
+ for _ in 0..4 {
+ values.push(inputs.remove(0));
+ }
+
+ let mut winner: i8 = -1;
+ for input in inputs {
+ if winner >= 0 {
+ break;
+ }
+ values.push(input);
+ for i in 0..grids.len() {
+ // Search by rows
+ for j in [0, 5, 10, 15, 20] {
+ let mut n = 0;
+ for k in 0..5 {
+ let x = grids[i][j + k];
+ if values.iter().any(|&i| i == x) {
+ n += 1;
+ }
+ }
+ if n == 5 {
+ winner = i as i8;
+ }
+ }
+
+ // Search by cols
+ if winner < 0 {
+ for j in 0..5 {
+ let mut n = 0;
+ for k in [0, 5, 10, 15, 20] {
+ let x = grids[i][j + k];
+ if values.iter().any(|&i| i == x) {
+ n += 1;
+ }
+ }
+ if n == 5 {
+ winner = i as i8;
+ }
+ }
+ }
+
+ if winner >= 0 {
+ break;
+ }
+ }
+ }
+
+ let mut sum = 0;
+ for x in &grids[winner as usize] {
+ if values.iter().any(|&i| i == *x) {
+ continue;
+ }
+
+ sum += x;
+ }
+
+ sum * values.pop().unwrap()
+}
+
+fn main() -> std::io::Result<()> {
+ let file = File::open("input.txt")?;
+ let reader = BufReader::new(file);
+ let mut lines = reader.lines();
+
+ let inputs: Vec<_> = lines
+ .next()
+ .unwrap()
+ .unwrap()
+ .trim()
+ .split(',')
+ .map(|x| x.parse::<u32>().unwrap())
+ .collect::<Vec<u32>>();
+
+ let mut grids: Vec<Vec<u32>> = vec![];
+ let mut n: usize = 0;
+
+ lines.next(); // Ignore the first empty line
+ while let Some(line) = lines.next() {
+ let mut line = line.unwrap();
+ grids.push(Vec::with_capacity(5 * 5));
+
+ for _ in 0..5 {
+ grids[n].extend(
+ line.trim()
+ .split(' ')
+ .filter(|x| !x.is_empty())
+ .map(|x| x.parse::<u32>().unwrap())
+ .collect::<Vec<u32>>(),
+ );
+ line = match lines.next() {
+ Some(x) => x.unwrap(),
+ None => "".to_string(),
+ };
+ }
+ n += 1;
+ }
+
+ println!("{}", part1(&grids, inputs.clone()));
+
+ Ok(())
+}
diff --git a/2021/day6/Cargo.toml b/2021/day6/Cargo.toml
new file mode 100644
index 0000000..89d04ae
--- /dev/null
+++ b/2021/day6/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day6"
+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/2021/day6/input.txt b/2021/day6/input.txt
new file mode 100644
index 0000000..de918c7
--- /dev/null
+++ b/2021/day6/input.txt
@@ -0,0 +1 @@
+1,1,3,5,1,1,1,4,1,5,1,1,1,1,1,1,1,3,1,1,1,1,2,5,1,1,1,1,1,2,1,4,1,4,1,1,1,1,1,3,1,1,5,1,1,1,4,1,1,1,4,1,1,3,5,1,1,1,1,4,1,5,4,1,1,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,1,1,1,1,1,2,2,1,1,1,1,1,5,1,1,1,3,4,1,1,1,1,3,1,1,1,1,1,4,1,1,3,1,1,3,1,1,1,1,1,3,1,5,2,3,1,2,3,1,1,2,1,2,4,5,1,5,1,4,1,1,1,1,2,1,5,1,1,1,1,1,5,1,1,3,1,1,1,1,1,1,4,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,2,1,1,1,1,2,2,1,2,1,1,1,5,5,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,1,4,2,1,4,1,1,1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,5,1,1,1,1,1,1,1,1,3,1,1,3,3,1,1,1,3,5,1,1,4,1,1,1,1,1,4,1,1,3,1,1,1,1,1,1,1,1,2,1,5,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1
diff --git a/2021/day6/src/main.rs b/2021/day6/src/main.rs
new file mode 100644
index 0000000..46a148c
--- /dev/null
+++ b/2021/day6/src/main.rs
@@ -0,0 +1,36 @@
+use std::fs::File;
+use std::io::{BufRead, BufReader};
+
+fn main() -> std::io::Result<()> {
+ let file = File::open("input.txt")?;
+ let mut reader = BufReader::new(file);
+ let mut buffer = String::new();
+
+ reader.read_line(&mut buffer)?;
+
+ let mut lanternfishes: Vec<_> = buffer
+ .trim()
+ .split(',')
+ .map(|x| x.parse::<i16>().unwrap())
+ .collect::<Vec<i16>>();
+
+ for _ in 0..80 {
+ let mut n = 0;
+ for lanternfish in lanternfishes.iter_mut() {
+ if *lanternfish == 0 {
+ *lanternfish = 6;
+ n += 1;
+ } else {
+ *lanternfish -= 1;
+ }
+ }
+
+ for _ in 0..n {
+ lanternfishes.push(8);
+ }
+ }
+
+ println!("{}", lanternfishes.len());
+
+ Ok(())
+}
diff --git a/2021/day7/Cargo.toml b/2021/day7/Cargo.toml
new file mode 100644
index 0000000..b170ccb
--- /dev/null
+++ b/2021/day7/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day7"
+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/2021/day7/input.txt b/2021/day7/input.txt
new file mode 100644
index 0000000..3e0fecf
--- /dev/null
+++ b/2021/day7/input.txt
@@ -0,0 +1 @@
+1101,1,29,67,1102,0,1,65,1008,65,35,66,1005,66,28,1,67,65,20,4,0,1001,65,1,65,1106,0,8,99,35,67,101,99,105,32,110,39,101,115,116,32,112,97,115,32,117,110,101,32,105,110,116,99,111,100,101,32,112,114,111,103,114,97,109,10,62,461,1087,183,1096,431,412,200,486,1543,25,580,1030,15,65,1186,9,226,173,77,119,691,855,451,88,741,221,1465,190,779,327,179,627,366,288,174,1147,49,773,3,5,65,20,172,601,307,611,699,1168,933,1295,832,242,62,8,4,226,768,33,566,21,10,937,15,760,100,574,181,89,72,1054,225,28,0,685,661,131,281,933,90,233,109,1345,81,106,636,1262,193,172,1056,709,1176,447,536,1054,929,171,226,127,274,710,917,218,192,25,128,321,1816,515,181,759,20,258,134,281,151,99,479,623,534,72,576,534,337,54,293,450,230,963,14,357,446,1244,964,16,865,52,1,1171,77,7,275,313,894,577,305,1119,393,285,354,136,1147,241,441,166,1024,650,101,178,1514,186,902,367,5,431,374,56,507,857,1316,0,186,63,118,1062,62,446,266,47,354,168,65,1036,447,689,160,749,728,791,1066,99,675,194,891,153,737,801,254,905,1046,21,413,386,204,603,373,218,440,137,1340,1616,121,903,722,841,731,213,219,405,336,1345,144,329,285,213,272,717,47,126,1137,548,32,21,755,219,595,187,143,636,476,397,185,70,345,89,319,80,867,26,1166,509,24,16,151,605,1415,893,814,473,289,377,407,44,184,290,447,1669,116,319,455,294,145,513,58,247,186,1565,31,297,1,226,1051,1561,1233,254,1274,422,547,1638,354,1855,419,71,1003,626,519,109,96,996,117,32,226,424,184,181,720,1311,1162,11,86,438,408,1269,887,612,327,133,1117,1390,345,10,370,175,37,1154,659,707,193,665,65,359,758,1253,498,219,601,59,919,1371,289,9,437,392,626,981,2,51,733,780,101,541,770,464,28,616,81,1708,1515,719,780,1214,673,268,246,25,252,301,205,27,160,0,298,69,285,58,809,1369,812,628,353,47,632,123,168,135,277,303,614,365,330,1385,1117,1346,737,744,1403,385,215,437,276,726,673,668,494,164,1,763,696,487,252,375,1253,42,1111,963,58,63,11,1648,1080,964,526,454,1349,1098,95,59,78,36,42,654,1441,1129,464,740,355,370,44,4,154,986,439,828,287,969,765,565,836,196,387,556,34,586,438,1205,760,798,6,61,260,25,418,1628,566,3,530,753,758,16,92,30,1388,109,240,513,1048,1056,588,1634,418,297,195,447,1145,198,466,0,607,180,57,58,72,319,221,869,744,339,195,1295,268,1336,1310,38,714,326,393,445,422,102,389,188,147,21,805,381,520,561,282,438,115,431,156,482,50,890,470,22,60,46,1588,971,1219,82,380,1061,948,455,99,255,400,1832,91,225,280,520,279,91,172,92,946,434,182,164,142,83,91,281,538,962,77,1104,1522,310,4,961,62,9,1257,596,464,733,338,1166,334,380,509,773,90,498,480,1523,1632,530,543,413,589,748,4,861,11,233,192,699,33,615,1853,205,270,624,1132,1100,227,1402,349,183,179,645,4,1120,962,317,326,128,422,281,302,701,53,179,34,802,272,1254,375,764,418,16,160,943,479,416,717,644,1029,372,140,114,449,351,159,305,1299,749,488,502,180,210,17,533,258,120,333,1097,185,1911,451,360,66,1329,1260,209,1611,454,809,336,783,1438,20,26,609,720,155,578,367,231,1715,64,610,465,752,81,108,389,995,244,1291,1144,159,161,1630,561,813,261,67,1604,124,231,833,14,15,1245,1309,1165,103,1270,228,1,133,644,581,218,481,716,237,155,360,110,1408,931,99,216,5,21,67,348,927,325,759,1127,557,584,696,428,653,548,247,1519,1682,132,3,1648,230,229,136,253,543,1153,204,669,58,81,357,85,82,749,503,139,32,1170,1352,151,653,1441,51,392,474,2,114,64,418,125,514,838,473,794,331,13,327,1476,836,37,3,0,115,18,1784,300,190,99,997,1164,31,1255,96,64,1101,354,698,372,852,1508,100,289,32,704,292,504,191,1342,231,692,12,369,1182,62,809,566,688,218,2,539,234,996,444,228,456,369,115,23,29,226,940,95,404,349,1254,171,69,711,2,1405,1181,34,8,92,173,533,20,181,921,201,1236,185,457,526,2,106,12,601,58,339,457,590,15,1583,473,451,1124,1569,401,72,154,9,1331,471,165,516,463,543,298,197,43,1294,101,1058,1025,1099,4,634,90,104,870,480,412,290,11,924,338,30,281,83,268,20,848,1722,1060,987,9,196,266,28,402,267,199,814,986,440,906,796,1403,1394,62,136,442,412,1729,571,459,91,730,269,172,202,772,305
diff --git a/2021/day7/src/main.rs b/2021/day7/src/main.rs
new file mode 100644
index 0000000..26e1e30
--- /dev/null
+++ b/2021/day7/src/main.rs
@@ -0,0 +1,29 @@
+use std::fs::File;
+use std::io::{BufRead, BufReader};
+
+fn main() -> std::io::Result<()> {
+ let file = File::open("input.txt")?;
+ let mut reader = BufReader::new(file);
+ let mut buffer = String::new();
+ reader.read_line(&mut buffer)?;
+
+ let mut inputs: Vec<_> = buffer
+ .trim()
+ .split(',')
+ .map(|x| x.parse::<i16>().unwrap())
+ .collect::<Vec<i16>>();
+
+ inputs.sort();
+
+ let half: usize = inputs.len() / 2;
+ let middle = inputs[half];
+ let mut sum: u32 = 0;
+
+ for input in inputs {
+ sum += (input - middle).abs() as u32;
+ }
+
+ println!("{}", sum);
+
+ Ok(())
+}
diff --git a/2021/day9/Cargo.toml b/2021/day9/Cargo.toml
new file mode 100644
index 0000000..b5e5273
--- /dev/null
+++ b/2021/day9/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "day9"
+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/2021/day9/example.txt b/2021/day9/example.txt
new file mode 100644
index 0000000..6dee4a4
--- /dev/null
+++ b/2021/day9/example.txt
@@ -0,0 +1,5 @@
+2199943210
+3987894921
+9856789892
+8767896789
+9899965678
diff --git a/2021/day9/input.txt b/2021/day9/input.txt
new file mode 100644
index 0000000..10120f9
--- /dev/null
+++ b/2021/day9/input.txt
@@ -0,0 +1,100 @@
+9876543234679310943456798433456798998764321357921025689921987899896498799923491297654545679876212347
+6987675036678939874567987012567897899975532467892334567890996789789989679895989398743236789865101456
+5598983124589598765689765423678956789876543568943565678999765395679876598789678987654345998764313689
+4349994235695329976789998634678946789987987679757678989398653234598767459654567998767499899875424568
+3298987656795419899896459745989134568998998789968789699219772123987654398753456899989989689986576789
+2126598787896998788902349897991013457899999997989994567909765244598875697542346789798764593987897897
+1012349898999887567893956999543234967967988656799323459898954355699876989331238996659875691298998956
+4123467999598765456789897987654347899659876545678912398767896466789987979210349965545996789399659235
+3234598985439878567896789198795456789898765434189329987546789998994699867991467894534987899985432123
+4347899876567989678965994349987897899909996521034998675323597899123989659889578943023498999875321014
+5456987997689299989254789498798998999919989992129876543213456789239877545678989432145999998989432345
+6567896798792109892123569987679999998898767889234997854324597994399765434689996565236789987698544456
+7898945689899998763012458976597989987784345678949998985434989219987654323456899854345699996597655678
+8949239796958899954124567895435678996543234567897889876599878998698765435678998765496978989498966899
+9932198965346789867258789932124567987655123458976778987988769876569876646889019887989869979329987957
+9893987896234568954345898743245798998766234567894567899875457987421987756799934999876649868912398946
+8789876789195689875457999655466799679879845678913348987654346987630298867897895988965432946794459435
+7653245678989799876767899867578954568989658799101234999869234598541349998976789876894321987895568910
+9654134789678986988979989878989243456799767895312349898998945987676556789345698765789210398996678999
+8765245696567895399898979999599012367899898986423498776566899999887687990296987984694331239989989888
+9954346897379964219787767893478943479901999597434569653465678999998798921989896593789452398978998767
+0976557898298965398656456794569894998919589439765698542324599689929899439976789432599543987767999656
+2998678999997897987642347895698769867898478929876987321015689599845996598765678953498959876656897545
+9859789899886789998756468998789655456797569999989996432326796498656789987654567894997899965545998968
+7643996798654567949898979659897643245698979989994987543689895329868999998765678949876778964234899879
+5432345697543458957999989545998732124569998967943198964599943210979098969876899129875467996446789989
+8584557987654569767899993123989841034979987654599979989679985341989197854987989039654346789677899899
+7675678998765699898988932034976432149898998863278954393989876832698986543298968998765956799898998789
+8776789439897789909977794255987543298787899985369893212399989764567997432129456789979899989949987699
+9899899524989896429865689356898655398656799876456789105679899895678987521012359891398797778932397569
+9987978939878987898754578967898786499545892998968994323456789989989498432154467910987676567891986478
+9876568998767898999743679879969897987656901239879895544678999879897599543265998934977567456789765399
+7765459876546999898654798989456998998767893446989796665678998768789987654399899949765432345996996989
+6984345995437898759995987892399999439978998669995689776889997656667998969989789899986645567895789878
+5493234989425789647889876891987899321989998778934578987999876543459549998875569789998786688934899767
+4321049875414678936979965789976678910198989989323469998967987652368932987654414579989887999023987656
+5493959954323469324767894679864567891987878993212378999545698710456891099843203458976998942125998543
+7989898965434568913456893589653456789876567992105567894434789322567992129874212367895459993349879432
+8979767996576679102378921098732345898676456789213458943226798763456789298765673456789345989659765310
+9865656889677889293467892129641237899545345698924567899012999654567899349876654597891299978978987821
+8654345679898999989679953498432356789321234567897698978929898765678998956987875698910987567899398932
+7543234578929898878989769976544578996532356878998789567998769888789987897898986789321297478921239543
+5432143456919657667899898989757689987653479989019893478987847999898796789949997996548396567890198656
+8961012367898943456789987698768789998954568998929989569876435445989654678929898987657987678954239967
+7642123456976432367893297569899898769765679456998678978987321334678965799898769598767998999876349879
+8843234568965321245892195479901989859887894367899568989765410123457896893799654329878999899987456989
+9754545678976432496789989567899876543998999578965467999876923245569987932679954212989898789998567894
+9898758789876545789897678998967989862369998679754345699989874356998898921569896102398767678999978943
+9998767894988656896935569549459898973456899789643234987998765459876789932499789213988654589989899432
+8789978943299767965423478921298767895569964996532146986799878598765999893987689929876542679878798921
+9689989652129878987314567890989856789678953987844299875989989679754666789986567898986321299767687899
+6567897541012989796205679999976545679999654598765987654678998798673245678965438957895410987954576778
+4489995432123497654317895798765432459898767679876798763567899899542134589875312346689929996543134567
+3235789543235698785456954349876721248789878789989899874698999998753234696543201234567898987654235678
+2124678965346789896787893212987210187678989892198942976789998769876545987654415345698976798966547899
+1014589878456893987899954301297321234589899999977893988894987456998668998765623466989765429987858943
+2123578989569902398978975212976542475789789998756789199953986568989889679876734569879954312398969652
+3234567897698943469869865323987643567898699999547894349992197689679995566987655698767893202459878943
+4345978998997899598756998764598764678987569898769976998989999796598754324499878999859994312378989965
+5656899569866968965431279879689985789998498769878989876865778965469843212347989898948975459459999876
+6787932499754357896542456998789699899886329856989999765954567894345954353456798797837988678969878997
+7898953987643239919757567899897543998765498745899886644212678901234969754668997655126898789998868998
+8999654996544128929898978934998631349877899635789765432103789212349898975678986543235679892987657899
+9998969875431017999939989325698752356989998523489876643214897423598787896999697655356799921098545989
+9997978996652126789129893216799763467899896412678999765625996545987676569896598766587898943985432877
+9886899429863245679399789109999878978998765324569769889436789679876543456789439898698987899874321466
+8765678910964376899987698998784989989549995445678945996547899798965432387696429999789556789766440355
+7654569899875487999896587899543494399929987678799434987667934977994321234597998998995445678954321234
+6543456789989568998785476998932359239898998989893223699788999866789410165789896987654324479765535445
+5432567899987678997665365767899498998767999699932104567999987654789421256899765698985212356986787568
+4321256789999789886543214456798997987656789569543213469765498765678933345998754109876323567897898679
+5434345678998998765432102349987856798545993498994999578954329878989654658987653212987434878998929989
+6565656799567899876545214498986534987656789597789878989865912989498768767899864324598546789989939999
+7676768923456999987756725987995423898967896986678767993999894994239989878998975435987659896765798989
+8787879734567898998998999876789545789989954965483458912987789892129796989787896745898789975454447678
+9898989656789987889999987494899656789195899754312379909876556789097645692546999856789897654322334589
+8969398797996545978899976323678967991024789876106567899985434567998732101235678969897998854310123459
+7654249899975323456789985214567898942195678998217879999876524567986544212346989989976799965924265678
+8652135987976896568999953107998929769989899999356989998765213456987656434587896492455678999895696799
+9543299876989987689659864315789319898878989876467999989874301345699786547998954321234589987689989892
+7654987664698998796549874323498901997659878987578997779765432456789987856899967432355678996578678921
+9965799543567899987856975434567892987543656898989986569876753697897598767977898645698789975457568910
+9899898632356792198977896565678969876532345689995987432987884789966449878956789876899899764325457891
+6678997653458999299989979876799349865431334678953294321098765789654323989345999988967998955212345789
+4599298964578998988998968987891234986210123689964498753129877897654312993234789999654987742101234699
+3989129765679997667987899998910129876433234589876569876534988998973209894365678919869876543232348789
+2878939876799896543566999879321236997645345679987893997699999529994698765489799201978997654343469892
+3467899987986789432355698765432345698987456789298932398988965410989989876569895412399989765499598921
+5679979999895678921234569989543456789998987891019643599877896329879879999678976523989878979988987932
+6789568987784569990146678998656567899969898989998754988756899499764768998789897949876767989877656893
+9893499976543478989236789239767898998756789878899869876645798987653456799898789498765456799765346789
+6912987665421299879345678949879989976545698765789979865434687898432567895965689398754345678974235699
+5439876543210987769967899999989567895431987543695491984323456989943458954397899999665265667895127678
+6545997654521976458899910989996468986532398654599392395664677979894568965989959876543123456789024568
+7666798766439894346778929878987347897747498765678989987775899866789789999878943997651016567892123456
+8789899876598789234567898969876456798856569876789778998986798754989899989766959898764323456789236768
+9898999987697655139879987655987898949987899987894566989987986543478999876745898759877467897897345679
+8967998799798743016791098943498929956798999898913455678999876542359998765636789542976578949985498789
+7649876549899752145892987632349547897899498769101234589212987656767899443323498931987989539876569893
+8432987632999863236789876545678956789902349854213455678903498987898954321014567890198994321987689912
diff --git a/2021/day9/src/lib.rs b/2021/day9/src/lib.rs
new file mode 100644
index 0000000..3391a74
--- /dev/null
+++ b/2021/day9/src/lib.rs
@@ -0,0 +1,90 @@
+use std::str::FromStr;
+
+#[derive(Debug)]
+struct Heightmap {
+ data: Vec<Vec<u8>>,
+ rows: usize,
+ cols: usize,
+}
+
+impl FromStr for Heightmap {
+ type Err = ();
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ let rows: Vec<_> = s.trim().split('\n').collect::<Vec<&str>>();
+ let mut data: Vec<Vec<u8>> = vec![];
+ for row in &rows {
+ data.push(
+ row.chars()
+ .map(|x| x.to_digit(10).unwrap() as u8)
+ .collect::<Vec<u8>>(),
+ );
+ }
+ Ok(Heightmap {
+ data,
+ rows: rows.len(),
+ cols: rows[0].chars().count(),
+ })
+ }
+}
+
+impl Heightmap {
+ fn resolve(&self) -> usize {
+ let mut count: usize = 0;
+
+ for i in 0..self.rows {
+ for j in 0..self.cols {
+ let top = if i > 0 { self.data[i - 1][j] } else { 10 };
+
+ let bottom = if i < self.rows - 1 {
+ self.data[i + 1][j]
+ } else {
+ 10
+ };
+
+ let left = if j > 0 { self.data[i][j - 1] } else { 10 };
+
+ let right = if j < self.cols - 1 {
+ self.data[i][j + 1]
+ } else {
+ 10
+ };
+ let center = self.data[i][j];
+
+ if center < top && center < bottom && center < left && center < right {
+ count += (center + 1) as usize;
+ }
+ }
+ }
+
+ count
+ }
+}
+
+pub fn part1(input: &str) -> usize {
+ let grid: Heightmap = input.parse().unwrap();
+ let result = grid.resolve();
+
+ result
+}
+
+#[cfg(test)]
+mod day9_test {
+ use super::*;
+
+ #[test]
+ fn test_with_example_data() {
+ let data = include_str!("../example.txt");
+ let result = part1(data);
+
+ assert_eq!(result, 15);
+ }
+
+ #[test]
+ fn test_puzzle_input_part1() {
+ let data = include_str!("../input.txt");
+ let result = part1(data);
+
+ assert_eq!(result, 541);
+ }
+}