Browse Source

Solution to day1 and part I of day 2

AbdoFizzy 6 tháng trước cách đây
mục cha
commit
993c0a72ed
8 tập tin đã thay đổi với 2097 bổ sung0 xóa
  1. 3 0
      1/dune
  2. 1000 0
      1/input
  3. 23 0
      1/solve_1.ml
  4. 26 0
      1/solve_2.ml
  5. 3 0
      2/dune
  6. 1000 0
      2/input
  7. 40 0
      2/solve_1.ml
  8. 2 0
      dune-project

+ 3 - 0
1/dune

@@ -0,0 +1,3 @@
+(executables
+ (names  solve_1 solve_2)
+ (libraries base stdio str))

+ 1000 - 0
1/input

@@ -0,0 +1,1000 @@
+77710   11556
+22632   23674
+82229   77288
+35788   30924
+84000   63702
+28350   62605
+15185   47495
+59530   63702
+38142   60772
+53694   41728
+38645   53443
+14632   43457
+54935   60772
+80251   67650
+45254   80940
+92045   48739
+88570   62608
+36464   14863
+15072   50428
+47732   12515
+66594   38710
+49622   63960
+38988   83798
+80235   95974
+66138   48396
+24678   63702
+89750   21245
+49637   60225
+66174   33783
+31929   60355
+86217   38710
+63702   64237
+10029   40993
+18724   11247
+86376   33183
+38846   77319
+71807   81452
+95125   65995
+14313   48739
+43968   82639
+95579   67299
+34700   57990
+95295   86925
+77804   39861
+23393   68293
+16675   33218
+86282   15372
+23383   44772
+93238   77732
+48968   55633
+13865   82878
+94041   30924
+58961   57990
+95054   99680
+38556   11247
+49445   49423
+12517   17577
+16458   62967
+70240   11247
+70209   13865
+44469   37707
+44143   76913
+40530   67650
+77107   57609
+52160   33783
+21898   53452
+60672   67910
+78399   38710
+65701   18077
+44093   31621
+10717   89642
+61143   33783
+46421   36377
+25600   86925
+71610   67650
+84942   88880
+18709   63702
+35967   62840
+59430   33783
+99613   11247
+21285   53061
+45961   63960
+64708   61045
+18663   38142
+24076   81982
+65173   33218
+99985   38090
+54288   50656
+45599   57990
+71134   86925
+21756   47991
+61585   96229
+30625   28042
+20187   96905
+53557   36740
+97635   85201
+74537   26837
+47344   89993
+23434   81337
+22578   52652
+64334   95857
+31984   23357
+19285   91889
+89380   60225
+68178   55027
+60534   92951
+92947   36269
+19390   21611
+36751   61641
+46265   86925
+64682   62605
+82939   21611
+62893   68731
+80218   33783
+82578   47062
+38606   47991
+64066   32805
+73995   96279
+59980   81452
+35206   49067
+63735   22549
+69054   43457
+39028   33503
+47551   63960
+23082   33555
+46069   99239
+25862   21611
+29188   80530
+80159   72409
+89316   15281
+54325   96229
+20285   94652
+70669   60225
+38999   72702
+85965   38803
+29799   32822
+59668   67650
+51559   66111
+13066   40993
+83004   30924
+10791   93513
+49496   38142
+73531   13865
+69050   96905
+69139   86925
+38483   67650
+30305   30924
+81076   76125
+15160   86181
+16189   56515
+22900   81452
+73271   82195
+45974   47969
+36115   10740
+59422   43457
+85666   59898
+82750   60225
+40947   99239
+75465   61804
+54504   94607
+62259   57990
+61506   76849
+93497   89296
+86487   26837
+41882   90643
+88793   12950
+39763   99728
+93555   26837
+12393   94358
+74543   62605
+88378   13865
+50221   21611
+27299   21611
+11114   69673
+65791   40954
+83752   25848
+18745   66574
+74882   15777
+48692   92817
+44362   33783
+61242   33713
+75950   97325
+57627   78921
+27136   37764
+39092   75180
+57990   47495
+61045   38333
+92827   42676
+24438   68802
+47626   96905
+37175   21756
+73009   41330
+96229   91479
+11873   81197
+25332   28939
+93039   26837
+44499   54251
+19265   33218
+31294   48739
+21611   85477
+47571   35343
+41758   81197
+89804   57990
+48279   92182
+94594   66451
+57016   89158
+17266   86925
+81813   58727
+13336   38200
+94562   21611
+38748   27800
+43566   38115
+33641   16072
+32705   13865
+91130   23928
+25131   25225
+36909   58299
+42651   60225
+15671   86925
+55940   79543
+54192   93612
+35033   46154
+45535   93612
+67381   33783
+19212   43554
+61797   57334
+31432   63702
+67624   63702
+68653   21925
+68954   19906
+59967   19319
+92360   62605
+62287   81197
+45573   67650
+36328   86925
+61960   54935
+52269   30924
+29735   38710
+17036   86925
+41095   43262
+78536   69197
+66416   38710
+16855   26837
+34731   88069
+87905   57921
+94906   38142
+51691   60772
+23074   40993
+21975   30538
+98269   63247
+18510   11247
+75157   81452
+81502   96229
+42393   40392
+33218   59424
+27267   81197
+79787   64276
+93536   44879
+48011   86126
+31968   37764
+29136   93822
+31415   38142
+82576   57290
+52268   76837
+92810   86925
+72140   30880
+53488   77275
+92207   29581
+87280   30659
+37835   33783
+13844   33707
+36050   15281
+99005   47991
+28786   38142
+47468   63702
+25603   42097
+26727   78314
+49976   20189
+62921   45423
+52044   21611
+17790   89889
+88780   18585
+34331   38142
+67726   74641
+57916   47495
+63452   79115
+78967   39701
+94997   37764
+42030   96311
+60590   30659
+78384   86925
+92241   99239
+51851   98205
+35112   11955
+94174   93612
+56105   34772
+82931   83183
+85755   21756
+41762   11247
+29979   30538
+64165   50082
+70021   82923
+59604   50033
+13201   97846
+50277   79961
+50619   21580
+64368   62605
+83879   71346
+27839   21580
+26011   16779
+69345   93082
+41187   45082
+24601   57403
+89017   39275
+13283   63960
+31256   13865
+78623   40494
+39962   60772
+77663   75759
+26038   96905
+73316   33938
+92999   63310
+70166   81452
+76098   13228
+14891   73495
+28141   90952
+39299   28133
+15281   73967
+64842   69333
+95559   89761
+17538   13099
+76799   89172
+22138   21687
+49158   40993
+33693   62605
+55981   94587
+83142   79932
+21077   85487
+23175   30659
+80364   52407
+42472   57021
+29236   63702
+14255   81197
+38418   38658
+51859   99239
+45882   24944
+61324   62605
+61841   14654
+80388   49151
+29747   37942
+72476   85550
+16252   35104
+29781   40993
+44328   57990
+54660   26837
+59197   60225
+39215   26403
+29033   87810
+74751   13865
+11363   81452
+45067   13865
+69924   75263
+58362   14620
+99338   97975
+75898   43457
+96905   16625
+70983   76517
+14236   74084
+96360   24647
+86881   50855
+26274   21580
+40600   30924
+58564   40993
+99226   35194
+87750   47107
+97441   60772
+35567   84318
+21972   77712
+78537   60772
+67606   33783
+87472   54880
+40590   39337
+65012   40993
+34228   86925
+67523   60772
+59292   92825
+58678   51248
+84088   74861
+15637   67061
+84670   34083
+65027   35840
+36693   78427
+13907   63494
+21482   63960
+93441   20115
+52171   52940
+19489   81197
+15078   62605
+83077   30659
+63960   60225
+46050   80683
+38700   96905
+63198   38142
+41302   48739
+68920   57324
+45369   27878
+80613   35343
+42072   18174
+72266   67650
+33109   59561
+27044   94017
+58397   99239
+99287   26837
+75188   26837
+35603   96905
+72118   64189
+52217   89498
+22261   15916
+47554   64893
+37504   93612
+37585   81197
+57160   99788
+58979   86925
+86068   17478
+30924   67650
+91757   33783
+41612   62605
+49882   58770
+58123   91694
+19042   25712
+74025   54935
+72215   80755
+59251   94914
+51699   82641
+38983   81452
+52780   27519
+19446   23721
+44414   93461
+10848   63498
+13269   77958
+55135   86925
+94862   96905
+61608   71892
+32466   63702
+73641   77222
+88895   60772
+30659   43691
+79642   26837
+14338   62605
+64448   98623
+56553   26837
+40861   95000
+27892   38142
+66064   56112
+27121   67650
+47531   38710
+25848   38142
+14271   82868
+10228   60225
+87793   84307
+47175   11247
+17169   21756
+27721   32097
+92418   56108
+66355   95179
+44735   14992
+56507   47495
+28974   30659
+25283   47495
+49106   30659
+61397   20474
+57660   37764
+95424   82164
+10121   68532
+49037   21756
+16018   54935
+54171   21580
+80053   62605
+54412   86925
+43192   98063
+53374   30538
+65521   28042
+95061   23181
+94014   96905
+24774   45834
+28399   48739
+97698   26837
+46147   65487
+84884   13865
+52030   67650
+93282   25692
+79313   96229
+58667   57990
+47096   12206
+87391   13255
+99072   77986
+50703   38710
+87988   66679
+71641   20252
+59311   96905
+71220   26837
+67650   37764
+59553   50172
+31948   78353
+34761   62033
+87610   12483
+31841   10666
+94372   64616
+60219   93612
+22359   20993
+97102   38142
+77624   33783
+24951   60772
+37488   15301
+11723   48739
+39666   30924
+32108   63702
+83851   34362
+96210   93612
+86925   96905
+45896   30538
+65334   17294
+72470   70423
+30711   64283
+41405   14988
+43167   67650
+96945   74134
+86918   21648
+73197   99239
+12883   30924
+68421   66131
+52765   38142
+90834   21611
+45258   64964
+47579   75382
+32277   35346
+71673   46895
+37595   87784
+48519   41837
+29412   96905
+96414   21611
+61644   21815
+81808   62605
+30538   81530
+34537   63702
+93380   28460
+87906   60225
+10146   40993
+47991   40365
+67034   48739
+83743   12925
+10147   37764
+26378   87307
+40198   47495
+67130   54935
+83983   93612
+72931   59552
+95192   32462
+95378   15281
+96684   30924
+95810   94119
+84753   83149
+40769   68570
+17455   63702
+81452   30538
+10731   30614
+45236   60225
+86568   60225
+23497   40337
+51480   19838
+13760   33886
+45686   60296
+96295   75032
+76955   89344
+45913   68223
+87186   11247
+31427   71637
+55276   85526
+38894   67650
+21981   42123
+22349   96229
+57614   21611
+94900   30538
+66311   93612
+55885   89479
+50423   37764
+26215   21076
+48434   60772
+40955   26850
+39151   66713
+70875   94570
+27665   95982
+18538   40993
+13492   67650
+70499   47991
+77683   54750
+67747   30924
+71323   72807
+59706   24034
+38778   40993
+87807   25447
+70172   84749
+26837   38142
+23133   37764
+64159   37764
+52185   69425
+76687   41712
+63845   30659
+35561   13247
+43934   63702
+40181   85421
+32289   96905
+65398   67650
+71139   54935
+73790   47495
+45466   76229
+58332   67014
+61971   72358
+69121   63726
+39542   93612
+22484   68967
+55587   48739
+60432   18975
+94726   64078
+24284   14730
+14909   99239
+90684   11247
+32649   33783
+65137   47495
+77217   91427
+21116   47495
+83895   96905
+96601   27302
+55754   40024
+79944   85355
+16002   66193
+90129   11247
+30213   70372
+78641   83755
+63174   13530
+14543   10536
+90871   21580
+85852   79909
+34592   96905
+10211   33104
+97542   11247
+54594   33218
+63461   64351
+28007   25447
+99493   80756
+37563   33783
+81527   47495
+84654   81452
+18992   19077
+24263   25447
+69870   80090
+72716   33783
+97138   36996
+52068   63702
+29147   96229
+37530   64645
+33783   46150
+74846   60772
+16825   15281
+35345   62605
+69248   63960
+62605   40993
+48393   72178
+18517   63702
+83254   33783
+79495   30659
+66124   23376
+78999   80281
+96072   93612
+23506   12287
+28042   71962
+37764   29122
+27239   77167
+67379   96052
+50343   62639
+65800   37119
+73545   10601
+26147   48018
+11703   11247
+12981   63702
+10852   45862
+28206   37518
+98061   28757
+83811   58066
+23862   67650
+76612   22466
+10665   73928
+30081   85075
+63962   96905
+76010   84994
+27403   67650
+90077   63960
+74068   93612
+59069   67650
+48585   76889
+26308   62536
+94927   25428
+16522   88617
+42895   67650
+23882   25848
+88312   53998
+93856   55795
+37116   62605
+78120   42683
+79015   12949
+60074   54593
+41372   30538
+92369   25447
+46454   10552
+90499   13865
+95683   47495
+26207   15402
+41663   38142
+45778   96087
+82536   26837
+73671   62605
+90830   70767
+98755   11247
+40667   21580
+68269   68306
+27166   38710
+52502   36604
+90650   39860
+60073   67650
+82795   80557
+93494   67650
+61210   75404
+65316   65293
+31264   86574
+77373   98352
+30739   81452
+85346   62605
+66664   21611
+99662   37764
+29578   98074
+57246   60772
+29093   22422
+59393   33582
+69790   62469
+33276   30114
+80189   96666
+66119   26837
+19784   62605
+81184   41088
+35076   33783
+67704   61250
+48739   33218
+55762   13865
+89013   26837
+37137   21611
+88909   61336
+32196   30538
+86724   29523
+17981   54398
+56448   60256
+80823   54221
+83300   27328
+88026   38142
+58336   93612
+65810   77527
+24714   13865
+17929   86925
+11327   77128
+55034   58912
+44769   86797
+13322   55659
+64372   93494
+36477   21611
+23642   60772
+55724   60772
+26667   36225
+45210   96905
+11247   46836
+78918   90137
+13992   47495
+41326   60225
+47903   26837
+35926   77384
+27221   95442
+98695   63702
+93775   43732
+97744   78882
+81628   30659
+60225   63960
+36543   23250
+98904   30924
+79272   76007
+91916   45599
+21068   14578
+44525   49606
+26951   60225
+85562   81197
+79077   93612
+91418   74576
+64125   48739
+25949   65857
+36366   30045
+51836   21611
+59493   30924
+14600   31019
+51609   40993
+56673   93612
+85240   33218
+89574   15281
+30058   15281
+29464   46074
+94282   15086
+28521   53216
+85293   55577
+71182   37764
+14518   19328
+60810   64463
+44155   71652
+50352   30924
+81271   37520
+56005   73595
+93426   99239
+48196   49136
+80048   21611
+99240   42592
+20530   33783
+60772   53594
+43174   36790
+69363   14739
+77407   35483
+37644   60772
+86726   87246
+98832   40993
+26660   79340
+67933   26574
+74474   48739
+62414   49360
+20524   21580
+57665   50944
+49993   62605
+39330   74779
+95735   60225
+54490   60772
+42736   94550
+18812   33783
+83965   71738
+96638   78706
+75468   93612
+23757   37754
+69579   44683
+98297   75616
+49322   34521
+34698   29727
+99972   40993
+52254   74431
+85235   30538
+65740   30778
+52565   47991
+33052   78908
+60013   96229
+83067   99496
+85558   60225
+27244   96905
+72402   26837
+91813   99239
+65555   60225
+35968   25069
+53737   61662
+70451   46554
+78329   73260
+55609   74063
+12781   60772
+66272   49941
+16118   86925
+26033   49617
+48390   63702
+30003   23436
+41542   91300
+76570   93612
+67639   63960
+63930   11333
+22066   36920
+83376   74684
+16104   21611
+35185   56286
+95216   44366
+22605   62605
+80979   30538
+14635   94665
+83619   30924
+92781   98532
+78861   38764
+62770   19341
+39746   25447
+93612   38710
+44092   62605
+77918   96905
+80257   30580
+17590   99272
+68229   76224
+54001   85765
+97469   99239
+37205   30538
+69048   57990
+14872   60739
+48571   99239
+23974   91218
+38710   14364
+31301   26090
+68179   99207
+67300   99239
+33247   34833
+21580   99865
+74274   97554
+20411   47495
+40542   30538
+67917   89131
+99902   40838
+40993   21580
+97436   35819
+23800   60566
+86595   88748
+78666   19083
+47495   41135
+98215   38710
+22482   80507
+77086   67050
+53308   14323
+75294   88625
+82489   29928
+49093   32934
+96378   68073
+37250   71257
+16009   21611
+64164   47014
+69019   47495
+63457   43171
+50592   27922
+46024   70597
+49667   96082
+40856   11247
+42134   99956
+26021   55068
+20318   98162
+71497   13865
+43457   38142
+91041   26837
+16291   60225
+25447   98873
+79232   30924
+61697   96016
+46796   41899
+12977   58039
+62416   65959
+13416   27187
+61371   93612
+89884   50535
+62007   79719
+97904   65662
+69865   57990
+10288   21580
+71558   28042
+55800   30659
+23853   10422
+20471   13865
+20564   18219
+44027   13804
+46965   87046
+76735   64178
+95328   85608
+43478   40522
+26456   96905
+53931   30924
+81197   67359
+18024   63702
+34943   26837
+15279   44819
+91142   63960
+46127   30538
+31830   21574
+17905   63960
+35343   48107
+75727   87321
+77205   25447
+62962   11247
+79177   55811
+33599   83446
+18797   80213
+84721   86925
+50446   21611
+68889   26952
+91051   17166
+35127   29638
+99239   43522
+99122   27157
+29947   39341
+21459   97910
+22063   15281
+63297   43457
+42167   11247

+ 23 - 0
1/solve_1.ml

@@ -0,0 +1,23 @@
+open Stdio
+open Str
+
+
+let rec construct_list l1 l2 =
+  let line = In_channel.input_line In_channel.stdin in
+  match line with
+  | None -> (List.sort compare l1, List.sort compare l2) 
+  | Some x -> if (Str.string_match (regexp {|\([0-9]+\) *\([0-9]+\)|}) x 0) then
+               construct_list ((Float.of_string (Str.matched_group 1 x))::l1)
+                              ((Float.of_string (Str.matched_group 2 x))::l2) 
+              else 
+                (List.sort compare l1, List.sort compare l2) 
+
+let rec solve accum = function
+  | (x::tl1, y::tl2) -> solve (accum + (abs 
+                                          (int_of_float (x -.y))
+                                        )) (tl1, tl2)
+  | ([],[]) | (_,[]) | ([],_) -> accum
+
+let () =
+  let (li1,li2) = construct_list [] [] in
+    printf "Total: %d\n" (solve 0 (li1,li2))

+ 26 - 0
1/solve_2.ml

@@ -0,0 +1,26 @@
+open Stdio
+open Str
+
+
+let rec construct_list l1 l2 =
+  let line = In_channel.input_line In_channel.stdin in
+  match line with
+  | None -> (l1, l2) 
+  | Some x -> if (Str.string_match (regexp {|\([0-9]+\) *\([0-9]+\)|}) x 0) then
+               construct_list ((Float.to_int (Float.of_string (Str.matched_group 1 x)))::l1)
+                              ((Float.to_int (Float.of_string (Str.matched_group 2 x)))::l2) 
+              else 
+                (l1, l2) 
+
+let rec count_occurence x accum = function
+| [] -> accum
+| hd :: tl -> if (hd == x) then count_occurence x (accum + 1) tl else count_occurence x accum tl
+
+let rec solve accum = function
+  | (hd1::tl1, li2) -> let nb_occurences = count_occurence hd1 0 li2 in
+                      solve (accum + (hd1 * nb_occurences)) (tl1, li2)
+  | ([],_) -> accum
+
+let () =
+  let (li1,li2) = construct_list [] [] in
+    printf "Total: %d\n" (solve 0 (li1,li2))

+ 3 - 0
2/dune

@@ -0,0 +1,3 @@
+(executables
+ (names  solve_1 solve_2)
+ (libraries base stdio str))

+ 1000 - 0
2/input

@@ -0,0 +1,1000 @@
+16 19 21 24 21
+15 18 19 22 24 25 25
+80 81 83 84 87 89 93
+6 7 8 9 10 13 18
+60 62 61 64 66 67
+76 79 81 84 82 80
+70 73 72 74 74
+67 68 71 74 73 77
+56 57 60 59 61 64 67 74
+37 38 39 40 40 43
+90 92 95 95 96 97 94
+80 83 86 86 86
+44 47 49 49 51 54 58
+69 71 74 74 81
+66 68 72 75 77
+34 35 39 41 38
+58 60 63 67 70 72 72
+43 46 47 51 52 53 56 60
+35 36 37 41 44 50
+63 64 67 69 71 72 78 80
+19 22 23 30 28
+20 21 24 30 30
+75 78 80 83 90 91 95
+16 17 20 22 23 29 31 36
+22 21 24 26 28
+87 84 87 88 86
+48 46 48 51 51
+40 37 40 43 44 48
+77 75 78 79 81 84 86 91
+43 41 40 42 44
+32 30 31 32 35 32 29
+87 84 81 83 83
+43 41 44 47 48 45 49
+49 48 51 53 54 57 54 61
+68 66 69 69 72 75 77
+9 7 8 10 10 12 11
+77 74 77 77 77
+5 2 4 4 8
+34 33 36 36 42
+11 9 13 15 18 21
+22 21 22 23 27 24
+68 67 70 74 77 80 82 82
+87 86 87 91 95
+26 23 27 28 30 35
+23 20 21 28 31
+85 83 89 92 95 96 94
+32 31 38 40 40
+40 38 40 41 43 49 51 55
+22 19 21 23 29 35
+86 86 89 91 94 96 98
+72 72 73 75 77 78 76
+42 42 45 48 49 49
+41 41 43 46 48 49 53
+35 35 37 39 41 43 48
+85 85 86 83 86 87 88 91
+20 20 19 20 21 20
+13 13 14 13 15 18 18
+48 48 50 48 50 54
+26 26 23 25 30
+62 62 64 66 66 67
+31 31 32 34 35 35 38 37
+11 11 14 14 14
+6 6 9 12 12 13 14 18
+5 5 5 7 9 14
+87 87 91 92 95 96 99
+61 61 65 67 64
+77 77 78 82 85 85
+48 48 52 53 57
+69 69 70 74 81
+29 29 30 32 35 37 44 46
+52 52 54 56 57 63 64 62
+42 42 45 47 48 51 57 57
+57 57 60 65 69
+28 28 33 34 36 38 44
+41 45 48 50 52 55 58
+79 83 84 85 86 83
+69 73 74 77 79 81 81
+14 18 21 22 24 28
+26 30 33 36 43
+8 12 13 12 14 16 17
+84 88 91 92 89 92 94 92
+30 34 32 34 37 37
+3 7 5 6 9 10 14
+31 35 37 35 36 39 45
+59 63 65 66 67 67 68
+13 17 18 21 21 18
+72 76 78 79 82 82 82
+4 8 9 9 10 13 14 18
+42 46 49 49 52 57
+17 21 24 28 29
+64 68 69 73 75 78 77
+57 61 63 67 67
+11 15 19 22 26
+78 82 83 87 94
+34 38 45 47 48 49 52
+44 48 55 56 55
+45 49 52 57 59 60 63 63
+48 52 55 62 66
+14 18 20 27 34
+9 15 18 20 23 25
+4 10 11 12 14 17 18 16
+4 10 12 13 15 17 17
+18 23 24 25 27 31
+27 33 35 37 40 42 47
+16 22 24 21 22 25 27
+42 49 52 49 47
+39 44 45 43 44 46 49 49
+29 36 39 42 45 46 43 47
+37 42 43 42 45 48 53
+54 60 63 63 65
+66 71 73 76 76 79 77
+56 62 62 64 66 66
+69 76 79 82 83 83 87
+77 84 84 87 93
+76 81 85 87 89 91 94
+70 77 81 82 85 87 89 87
+14 20 22 26 28 28
+56 61 65 68 72
+78 85 86 90 95
+22 29 30 36 39 40 42 44
+18 25 27 28 35 38 39 38
+15 21 24 25 27 34 34
+21 26 27 33 36 40
+42 48 49 51 52 57 64
+97 96 94 91 88 89
+74 71 68 67 66 66
+67 64 61 58 57 53
+63 61 60 57 54 52 51 44
+41 40 37 35 34 35 33
+53 50 52 51 52
+31 28 25 24 23 20 22 22
+25 24 27 25 24 21 18 14
+82 80 78 81 78 76 70
+36 33 32 31 31 30
+66 65 65 64 63 61 59 61
+82 79 79 76 75 72 72
+94 92 90 90 87 85 81
+22 19 19 18 13
+39 38 35 34 31 29 25 24
+72 70 67 63 62 59 58 59
+28 26 23 19 19
+24 22 20 16 13 10 9 5
+63 62 58 57 52
+27 25 23 21 16 14 13 11
+76 74 72 65 64 65
+25 23 17 14 14
+78 77 76 69 68 67 64 60
+78 76 70 68 66 65 63 58
+63 66 64 63 62 61 60 57
+61 63 60 57 54 53 56
+90 92 89 88 85 83 82 82
+41 42 39 38 36 35 33 29
+15 17 15 12 11 9 3
+77 79 78 77 80 79 76
+43 46 44 45 44 41 42
+27 30 33 32 32
+18 19 16 13 16 12
+16 17 14 12 10 8 11 6
+77 80 80 78 75
+31 34 34 32 34
+3 6 5 5 2 2
+76 78 75 72 69 69 65
+43 45 43 43 41 35
+36 39 38 35 33 29 28
+81 84 81 77 75 78
+40 42 38 36 33 32 29 29
+29 31 29 28 25 24 20 16
+80 82 79 76 75 71 69 63
+49 52 50 47 46 41 39
+78 79 78 77 72 69 66 67
+12 13 11 5 5
+12 15 14 9 8 7 6 2
+44 46 45 43 38 36 30
+61 61 58 56 53 52 50 47
+35 35 32 31 28 30
+46 46 44 42 42
+80 80 77 76 72
+63 63 60 59 56 55 49
+77 77 80 78 75 73
+52 52 51 52 53
+12 12 11 9 10 10
+60 60 63 61 58 54
+67 67 69 67 62
+95 95 93 93 92 91
+53 53 52 52 51 48 51
+67 67 67 66 63 63
+11 11 10 7 7 3
+26 26 23 21 20 20 13
+80 80 78 74 73 72 70 67
+54 54 53 49 52
+63 63 62 59 55 53 53
+61 61 57 55 51
+69 69 68 66 62 55
+85 85 82 75 74 73 72
+47 47 42 40 39 37 34 36
+60 60 59 58 55 52 47 47
+77 77 75 69 68 64
+53 53 52 45 44 43 36
+43 39 36 33 30 29 26 23
+65 61 60 57 54 56
+55 51 48 47 45 42 42
+52 48 47 45 43 41 37
+29 25 24 23 22 17
+38 34 37 35 32 29 28 26
+24 20 19 17 15 14 17 20
+33 29 28 25 26 26
+38 34 35 32 31 27
+33 29 27 24 23 24 23 17
+36 32 32 31 29 26
+13 9 8 5 3 1 1 4
+6 2 1 1 1
+78 74 73 72 72 70 69 65
+44 40 40 37 30
+41 37 33 30 28
+88 84 83 79 78 75 73 74
+12 8 4 2 1 1
+65 61 57 54 50
+85 81 77 74 68
+76 72 66 64 62
+97 93 90 87 81 84
+64 60 53 51 48 48
+56 52 50 45 43 39
+56 52 49 43 40 39 36 30
+60 53 51 50 48
+36 31 29 26 25 24 26
+55 50 48 47 44 42 41 41
+90 85 83 81 77
+89 82 80 77 70
+56 49 52 49 47
+9 3 5 3 6
+9 4 5 4 4
+18 12 14 12 8
+66 59 58 56 53 54 49
+97 90 88 87 84 82 82 80
+60 55 53 52 52 54
+12 5 5 4 4
+26 19 19 16 15 11
+68 62 60 57 56 56 54 47
+59 52 48 46 45 42
+21 16 12 9 12
+99 92 91 88 84 81 81
+58 52 49 45 43 42 38
+48 41 38 36 35 34 30 23
+31 26 24 18 15 13
+18 13 11 6 8
+99 93 88 85 84 84
+85 78 75 73 68 64
+86 81 75 72 66
+5 9 7 9 6
+22 26 29 32 29 31 34 34
+22 29 30 32 34 39 45
+52 45 43 41 40 37 32 34
+30 32 34 39 43
+11 16 18 22 22
+68 72 75 76 79 82 86 85
+69 74 76 80 84
+65 65 63 61 57 55 53 48
+26 25 20 17 15 12 9
+27 29 28 23 21 16
+49 53 54 57 59 62 66
+72 72 73 80 82 85
+44 47 49 50 54 55 57 57
+20 19 17 19 21
+18 18 22 24 26 29 31 32
+48 52 54 54 56 56
+72 76 79 78 84
+64 60 57 53 48
+48 44 42 40 37 33 32 35
+52 52 48 45 44 41 38 40
+70 76 78 80 80 87
+55 54 52 48 44
+39 38 32 31 30 28 22
+8 8 5 1 1
+43 48 50 53 57
+29 32 29 27 28 26 27
+44 49 51 53 60 61 65
+16 17 10 8 8
+36 31 28 25 22 20 20 17
+61 54 51 44 42 39 35
+96 90 88 84 83 80 79
+55 58 57 53 50 50
+41 46 48 50 48 54
+7 11 12 14 14 17 23
+79 82 81 77 74 77
+34 28 24 21 22
+77 81 84 86 87 90 94 94
+67 74 77 79 80 83 87 90
+94 90 89 84 80
+65 64 63 60 60
+40 44 47 48 52 53 55
+35 35 34 33 32 29 27 29
+75 82 85 88 90 89 88
+92 88 88 87 86 83 80
+99 92 91 86 84
+11 9 6 2 5
+57 57 50 48 44
+21 18 19 23 28
+30 33 31 31 30 27 23
+22 22 22 19 14
+61 57 54 54 52 45
+81 81 84 82 80
+93 93 90 88 91 90 87 83
+29 36 40 41 47
+84 83 84 86 86 88
+33 37 38 45 52
+56 60 64 65 66 67 71
+98 98 97 96 96 94 94
+96 89 86 84 77 74 68
+51 45 44 43 36 36
+66 63 70 73 79
+84 79 76 74 71 71 70 70
+27 23 22 19 14 13 10 5
+91 84 83 82 80 76
+13 14 17 20 21 26 26
+96 97 96 93 89 88 86
+39 45 46 43 44 45
+87 80 76 75 72 72
+86 88 89 90 92 93 92 91
+45 45 48 50 57 54
+65 63 65 67 70 67
+38 34 32 32 30 27 25 21
+17 21 23 20 22 23 26 28
+65 66 71 74 75
+6 6 9 12 15 18 22
+76 78 76 78 80 81 88
+32 25 24 22 21 21
+49 50 52 54 54 56 59 59
+16 13 16 19 20 27 29
+71 71 73 71 70
+75 69 66 66 65 58
+58 55 57 60 61 64 66 73
+52 53 53 51 48 47 44
+28 21 19 17 15 11 7
+57 60 61 64 61 63 65 69
+8 5 8 9 10 14
+65 58 56 56 53 51 54
+68 67 69 76 80
+21 21 21 18 17 14 12 8
+67 66 68 66 63 60 54
+26 27 25 20 19 17 14 16
+31 30 33 34 34
+53 55 59 62 60
+96 92 95 93 90 89 83
+13 18 20 23 26 25 29
+36 36 36 35 36
+61 61 58 56 52 49 46
+38 35 38 41 38 40 39
+11 14 13 10 8 2
+11 14 15 21 18
+50 53 53 51 48 47 47
+27 25 23 25 23 26
+48 48 45 44 45 42 45
+66 62 61 59 54 51 53
+6 6 8 5 7 8 9 14
+67 67 65 68 69 72 72
+66 64 65 66 73 70
+94 92 94 95 97 99
+90 89 86 85 84 82 82 78
+77 77 81 84 87 87
+31 36 38 36 39 41 42 42
+73 69 68 67 68 66 66
+14 12 11 10 7 4 6 6
+29 25 23 22 19 17 16 10
+80 81 80 78 79 79
+9 7 7 9 10 7
+88 84 81 79 79 79
+27 28 29 32 33 35 38 42
+13 11 8 8 6 5 8
+30 37 44 47 48
+53 54 61 62 65 68 74
+54 54 51 44 41 38 35 35
+38 38 35 30 28 25 28
+83 90 93 96 94
+70 74 75 77 80 81 82
+71 74 71 70 68 67 68
+35 35 33 36 39 41 45
+32 29 27 23 23
+45 49 51 53 56 61 61
+20 20 18 19 13
+64 60 58 55 52
+2 2 2 5 6 10
+68 69 67 65 63 63
+67 71 74 76 79 79
+42 37 34 32 31 29 28 26
+24 28 31 35 37 40 42 49
+79 77 80 80 80
+58 51 50 50 47 46 42
+23 28 35 37 40 43 43
+26 30 31 33 32 35 39
+53 55 58 58 62
+88 82 80 78 75 77 75
+70 68 69 70 70 72 79
+27 29 31 31 34 36 38 39
+3 4 5 6 7 9 9 15
+46 45 41 38 37 31
+51 52 52 55 56 59 56
+69 68 69 73 73
+78 84 86 86 88 89 93
+14 7 9 8 6 3 6
+28 26 24 22 19 16 15 11
+86 86 81 78 75 74
+50 43 39 37 35 30
+54 60 64 65 66 63
+54 54 51 48 45
+74 74 74 77 80 81 82 81
+21 21 18 14 11 9 5
+49 54 55 57 57
+79 78 77 75 74 71 70 64
+15 15 18 20 22
+98 91 90 89 87 86 89 83
+95 91 90 86 83
+69 67 71 73 76 80
+57 57 55 52 52
+74 74 75 78 82 79
+47 43 45 43 41 40 38 39
+70 74 76 78 79 79 83
+88 88 90 93 94 93
+83 83 85 86 86
+55 56 57 58 62 64 67 68
+86 86 91 94 94
+75 76 77 74 77 80 83 86
+51 58 58 61 64 67 68 68
+67 63 62 61 59 56 54 50
+97 91 89 88 87 86 79
+54 47 45 48 47 44 42 38
+22 19 22 19 20 22 26
+29 26 24 23 20 13 11 11
+3 3 4 6 10 16
+52 56 57 62 66
+94 96 96 93 88
+70 70 70 73 76 79 79
+36 35 38 37 36 33 31
+31 31 32 35 36 41
+17 14 12 11 8 6 9 5
+96 92 91 84 81 81
+76 72 68 66 65 65
+1 4 6 7 11 12 16
+57 52 51 50 52 51 51
+1 5 6 7 9 12 15 14
+66 66 69 68 70
+47 43 42 35 33
+59 57 59 64 65 67 67
+19 19 19 21 24 26 28
+51 51 49 47 40
+52 50 47 47 47
+92 89 89 86 81
+34 30 33 32 29 25
+6 10 13 14 15 20
+51 47 46 44 40 37 36 32
+62 58 58 56 53 50 52
+26 26 24 23 20 19 15
+36 34 33 32 25 24 23 26
+53 54 55 56 56
+29 29 30 27 25 25
+70 75 77 79 85
+18 18 16 16 13 10
+80 85 87 90 91 94
+56 59 56 56 54 52 55
+22 18 20 18 17 16
+12 10 11 14 18 20 21 22
+94 96 93 86 85 83
+54 56 54 52 51 53 51 49
+72 75 71 69 66 64 58
+41 45 46 47 54 56 59
+71 71 75 77 81
+14 17 16 13 15 11
+4 4 9 10 12 16
+71 72 73 76 79 76
+67 69 66 67 65 58
+32 34 31 30 29 28 25 23
+38 35 35 33 30
+48 49 52 55 58 59 62 67
+45 51 52 52 54
+28 34 36 38 38 36
+12 15 11 9 5
+36 33 36 37 41 43 46 43
+91 90 86 83 80 77
+48 55 61 63 64 66 65
+55 55 56 56 62
+64 64 59 58 57 56 50
+16 13 11 10 7 5 8
+26 26 31 32 34 41
+58 57 50 48 46 42
+23 19 18 16 17
+15 18 21 24 27 29 32
+63 60 57 55 54 52 51
+84 82 80 77 76 75
+40 42 44 46 48 51 53
+91 89 86 84 81
+37 40 41 42 45 46 49 52
+90 87 85 84 83 81 78 76
+9 10 11 13 14 16
+35 34 31 28 26 24 22 21
+96 95 93 90 87 86
+45 46 49 52 53 55 57
+54 56 58 61 62
+44 47 48 50 53
+79 81 82 83 86 87
+15 17 18 19 22 25 26 27
+26 29 30 33 35
+90 89 87 86 85 83 80
+79 80 82 83 84
+42 45 47 49 50
+89 88 87 86 83 82 80
+22 23 24 26 28
+51 48 46 43 40 37 36
+1 3 5 7 8 10 12
+87 84 83 81 80 78 77 76
+76 74 71 69 66 63 61
+20 21 23 26 29 31 33 34
+48 47 45 42 41 40 39
+56 53 52 51 48 45 42 39
+31 32 34 36 39 41
+40 37 35 33 30 27 25 22
+76 74 73 70 68 66
+67 64 62 60 59
+35 34 31 28 25 22
+93 91 90 88 85 83 81
+7 10 11 14 16 17 20
+37 35 34 31 28
+58 59 60 63 64 66 68
+13 12 11 9 7 5 4 1
+80 77 74 73 71 68 65 63
+93 91 89 88 87 84 81 79
+87 84 81 78 77 75
+70 72 75 78 80 82 83 86
+69 67 65 63 60 59 56 53
+23 20 17 16 15
+64 65 68 70 71 72
+79 80 81 84 86
+15 18 21 23 25 27
+39 36 35 33 30 27 24 22
+54 53 51 50 47
+68 67 65 63 61 59
+99 97 95 93 92 91 88
+71 68 65 63 61 59
+66 64 63 60 58 57
+51 53 56 58 61 63
+84 87 89 91 92 95
+30 31 34 37 38 39
+57 58 59 61 63 66
+62 64 65 68 70 71 72 73
+23 21 20 17 15 14 12 11
+53 56 58 60 62 63 64
+76 74 72 70 68 66 64 61
+88 85 84 83 80 78
+41 38 37 34 33 31 29
+33 35 37 39 42 45
+34 32 29 26 24
+95 93 90 87 84 82 79 78
+21 24 25 28 31
+83 86 88 91 94 96 98
+83 81 79 78 77 74 71 69
+84 83 80 79 76 75 74
+35 32 31 28 26 23 22 20
+48 46 44 41 38 37
+89 91 93 94 97 99
+14 16 17 18 20
+23 22 19 16 13 10
+78 80 81 82 84 85 88
+25 23 22 21 20
+33 32 29 28 26 24 21 19
+80 78 76 73 72 69
+82 81 79 78 76 73
+54 51 48 45 44
+34 32 29 27 24 21 19 16
+70 69 66 63 61 58 55 52
+29 26 24 21 18 15 13 12
+81 84 86 87 88 91 93 94
+85 82 79 76 73 70 68 67
+82 81 80 77 76 75 72
+42 39 38 36 35
+71 74 77 80 81 83
+32 35 36 37 40
+59 57 54 53 52
+36 33 31 30 27 25 23
+89 86 83 81 79 76 74 73
+76 77 80 83 86 88
+72 70 69 66 65
+27 25 24 21 19 16
+57 60 63 66 69 70 73 75
+34 35 36 38 40 43 46
+26 28 29 32 35 37 38 41
+14 12 9 7 5
+11 14 17 18 21 24
+47 45 42 39 36 33
+52 55 58 59 60 63
+83 81 80 78 76 74 71 70
+10 11 13 15 16 17 20 22
+67 66 63 61 58 55
+83 86 89 91 93
+78 81 84 87 89
+51 49 46 45 42 40 38
+69 66 63 62 61 60 58
+69 70 72 75 78 80 83
+26 29 30 33 34 35
+48 45 43 41 38
+76 73 70 69 67 66
+67 70 73 76 78 81
+48 46 43 41 38 36
+77 75 73 70 69
+4 6 9 10 12 14 17 20
+21 23 24 27 29 30 31
+77 75 74 73 70 69 66
+18 17 16 14 12
+46 44 41 39 38
+29 26 25 24 21 19
+5 7 9 10 11 12 14 15
+67 64 63 60 57 55 54
+26 29 30 31 33 36 38
+27 29 30 32 35
+27 25 23 22 20 19 16 14
+51 53 55 58 59 60
+22 19 17 16 15 12 11
+29 26 23 22 19 16 14 12
+5 7 9 10 13
+51 52 55 56 57 58 59
+46 49 50 53 54 57 58
+48 47 46 45 43 42 40 37
+57 59 61 63 66 69
+60 58 55 53 51 48 47
+89 88 86 85 82 80 79
+47 45 42 41 38 36 34
+93 92 89 86 85 83
+46 49 52 54 55 57 58 60
+47 49 51 54 57 58 61 62
+35 38 41 42 45 48 49
+45 47 49 52 55 58
+60 57 55 52 51 49 47 44
+62 61 58 56 55 53 50 47
+49 47 44 43 40 39 38 37
+56 53 50 49 48 46 44 41
+42 41 39 37 34 33
+57 55 52 50 47 45
+86 83 81 78 75 73 70
+13 12 9 8 7 4
+4 5 6 8 11 13 16
+25 23 22 19 17 16 14
+85 88 89 90 91 92 93 96
+89 88 85 84 81 79 78
+37 39 42 43 46 49 50
+78 76 73 71 68 67 66
+44 45 48 49 51 54 57
+61 60 58 56 55 54 52 50
+13 16 19 20 23 24
+50 47 44 43 41
+21 23 24 27 28 31 34
+22 25 28 31 32
+25 26 29 31 33 35
+87 89 91 93 95 98
+16 17 20 21 23 24
+71 72 75 78 80 81
+79 82 84 85 88
+69 66 63 60 59 57 54 53
+42 40 39 37 34 33 30
+62 64 67 68 70 71 74
+22 24 27 30 33 34 35
+13 11 10 8 7 5
+98 97 94 92 91 90
+24 27 30 32 34 36 38 40
+7 10 11 12 14 15 18
+75 76 79 80 83 86 89 90
+17 14 12 11 8 7
+60 61 62 64 65 66 68
+67 68 71 72 74
+50 53 54 55 56 58
+68 65 64 61 60 58 55 54
+85 84 83 82 79
+54 57 58 60 61
+70 71 74 76 78 81 84 86
+28 27 26 23 22 21
+88 90 91 93 96 99
+39 38 37 36 33 31 30
+41 43 44 46 47
+70 68 65 63 60 59 58 55
+61 60 59 57 55 53 52 49
+54 52 51 50 47 45 44
+11 14 15 18 19 20 21
+76 73 70 68 65 64 61
+45 46 49 52 53 54
+51 50 47 44 41
+27 29 30 33 36 38 39
+27 25 22 21 20
+56 57 58 60 63 65 66 67
+8 6 5 3 1
+51 49 46 45 42 39 38 36
+75 73 71 68 65
+77 78 81 82 83
+74 72 69 68 65 63 61
+19 21 24 25 27
+24 26 28 29 32 33 36 39
+57 56 55 52 49
+63 62 59 57 56 53
+44 47 49 51 53 54 55
+26 25 22 19 16
+78 76 73 71 68 66
+74 72 69 68 66 63 60
+32 33 35 36 37 39 40 41
+24 26 28 29 32 35
+65 63 62 61 60 59 56 54
+53 50 48 47 46 43
+61 58 56 55 53 52 51 49
+48 46 45 43 40 38
+15 12 11 8 6 5 4
+31 28 26 23 22
+54 55 56 58 60 62 63 66
+65 67 69 72 74 76
+46 49 52 54 56
+35 34 32 29 26
+12 11 9 6 4
+19 18 16 13 10 9
+35 32 31 30 29
+51 53 55 56 58 60 62
+23 20 19 16 14 11
+14 17 18 19 21 23
+3 4 7 9 10 13
+37 35 32 31 28 26 24 22
+17 20 21 23 24 27
+37 40 42 44 47 48 51 52
+77 76 73 71 70 69 66
+91 90 88 87 86 85 82 80
+71 68 65 62 59 58 57
+6 8 10 11 13 16 17
+28 29 31 34 37 39 41 44
+2 5 8 9 10 13 15
+67 65 63 62 59 56 53 51
+5 6 9 10 13 16 19 21
+84 86 87 90 91 93 95 97
+46 47 49 52 54
+74 72 71 70 69
+8 9 11 14 17 19 20 23
+28 25 22 19 18 16 15
+29 30 32 33 34 36 37 40
+73 74 75 77 79 82
+37 36 35 34 32 30 27
+15 16 17 18 20
+71 70 69 66 65 63 61
+26 24 21 18 15
+66 69 72 75 78
+94 91 90 89 87 86
+46 48 49 51 52 55 58
+27 24 22 19 17 16 13
+65 66 68 71 73 76 79
+59 58 56 54 53 51
+35 36 39 40 41 43 45
+22 25 27 29 31 34 36 39
+33 35 36 37 38
+88 87 86 84 81 79
+43 40 38 35 32 30 27
+34 36 39 40 43 45 47
+27 26 24 23 21 18 15 14
+56 55 54 52 49 48 45 43
+26 27 30 33 36 39
+87 90 92 93 94 97 98 99
+67 66 63 62 60 58 55
+86 84 81 80 77 75 73
+64 61 58 57 55
+64 65 67 70 72 73
+86 89 92 94 96 99
+50 47 46 44 42 39 37 36
+77 80 82 85 87 89
+69 66 65 63 60
+33 36 37 39 41 43 45 46
+73 74 75 78 81 82
+52 49 48 45 42 41 38 35
+23 20 19 18 17
+34 36 37 38 41 44
+52 54 56 57 60 62 64 67
+15 18 19 20 23 25
+13 12 11 8 6 3
+15 16 18 21 24 26 27
+64 66 69 72 73 76 79 80
+40 41 43 45 46 48 50 52
+24 26 29 31 33 34 36
+52 50 48 46 44 41 40 37
+24 21 18 15 12 11
+77 80 81 82 84 85 87 88
+59 56 55 54 53
+51 50 47 45 42 40
+66 69 70 73 75 77 79 80
+43 46 49 50 51
+62 64 67 69 71 73 75
+66 68 71 74 76 78 79 80
+14 12 9 7 4
+26 29 31 33 36 39
+70 71 74 76 77
+82 83 86 89 91 93 95
+55 52 51 49 48
+18 17 16 13 11
+26 28 29 32 35 36 39
+34 37 38 41 43 44 47 48
+61 64 65 68 69 71 73
+84 86 88 90 93
+52 55 56 59 61 64 65 68
+16 18 21 23 26 28 30 32
+9 12 13 16 18
+20 21 23 26 28 29 30 33
+89 88 85 84 83 80 78 76
+71 70 67 65 62
+36 34 32 29 27 25
+86 84 82 81 78 77
+36 39 40 43 45 47 48
+80 77 76 73 72 71
+24 21 20 19 17 14 12 9
+39 37 35 34 33 30 27
+44 47 50 51 53 56 58 61
+66 64 62 59 58 56 53 50
+62 60 58 56 55 52
+67 69 72 75 77
+62 64 66 67 68 69 70 73
+41 43 45 48 51
+40 42 43 45 47
+33 35 37 38 40 41
+17 18 20 23 24 25 28 30
+16 17 19 21 23
+57 59 61 64 66 68 69 72
+99 96 94 93 90
+76 77 80 81 82 83 85
+21 19 17 15 12 11
+65 68 71 73 76 79
+7 10 11 14 17 20 21
+80 79 76 73 70
+76 79 81 83 84 87 89
+82 81 79 76 75
+50 47 45 44 43 42 40
+97 95 93 91 89 86 83
+88 89 91 93 95 96
+13 11 9 7 6 3 2
+74 76 79 82 85 87 90 93
+93 90 88 87 85
+51 49 46 44 43 40 39
+6 7 10 13 16 17 20
+77 75 73 70 69 66 64 63
+30 33 34 35 38
+49 51 52 54 56
+22 24 25 28 30
+18 19 22 24 27 30 33 35
+83 84 87 89 92
+32 35 36 37 40 43
+18 17 16 14 13 10 9
+53 51 49 46 45 42
+64 65 68 70 72
+72 69 68 65 64
+55 53 50 49 46 43 42 39
+53 52 50 48 45 42 39
+71 73 75 78 81
+83 85 86 89 91 94
+84 85 87 89 92 93
+27 24 23 22 19 18
+19 22 24 26 27
+58 57 56 55 52 49 47
+80 79 76 75 74
+89 86 83 80 77 74
+18 20 21 22 25
+30 29 27 26 24
+79 80 81 82 83 86 88
+83 81 78 77 76 73 71
+7 8 11 13 16
+28 27 26 25 22
+27 30 31 32 34 37
+87 86 83 81 80 79 78 75
+19 21 23 26 27 30 32
+38 40 43 45 48 51 52 55
+1 2 3 5 6 8 10
+24 21 19 16 14
+61 59 56 54 52 51 49 48
+39 37 34 32 30 27 24
+41 43 44 45 47
+86 85 84 81 80 79 76 74
+38 41 44 45 46 49 51
+50 53 54 57 58 59 62 65
+88 89 90 91 94 95 98 99
+73 76 78 81 83 85
+34 35 36 39 41 42
+26 29 30 33 34
+49 46 44 41 40
+66 69 70 73 75 76 77 78
+31 34 37 38 39 41
+58 60 63 65 66 68
+75 73 72 71 70 69 66 63
+68 71 73 76 79 81
+50 52 55 56 57 58 61 64
+98 95 94 93 90
+40 37 34 32 30
+73 76 77 80 81 84 85
+65 64 63 61 59 58
+52 53 55 57 58 60 61 63
+66 69 72 73 74 77
+77 76 73 71 68 67 66 63
+20 17 15 14 12 10 8
+69 67 65 63 62 61 59 56
+89 86 84 82 80
+46 47 48 51 53 54 56
+72 69 68 65 64 61 59 56
+33 35 37 40 43 46 48
+62 60 58 56 55 54 53 50
+99 97 96 93 92 90 88
+39 42 45 47 48 51
+74 75 76 79 81 82 83 86
+64 66 67 69 72
+38 35 34 33 30
+19 16 14 11 9 7 6 5
+66 65 62 60 57 55
+34 32 31 30 27
+76 75 74 73 71
+29 30 33 34 36 38
+33 36 39 41 44
+25 26 28 29 31 33 36
+13 11 8 7 6 4
+94 92 89 86 84 82
+54 51 50 49 46 44 43 41
+2 3 5 8 11 12 15
+30 31 34 36 38
+20 23 26 29 30 32 35 36
+61 64 65 68 71
+51 54 57 60 63
+21 22 23 26 27 30 33 35
+17 20 22 25 28 29
+44 42 39 36 34 31 30 29
+27 24 21 20 19 17
+32 30 29 28 26 24 21 19
+44 45 48 50 53 54 56
+89 86 83 81 80 78 75 72
+70 67 64 63 62 60
+52 53 54 57 59
+27 29 32 33 36 39 40 42
+32 34 35 36 39 42 45 48
+61 64 66 68 71 72 74
+33 30 28 27 24 23 20
+31 29 27 24 21 19
+21 20 19 17 15 12
+42 44 47 50 53 55 56
+77 79 80 83 86 87 88 91
+37 36 33 31 30 28 27 24
+13 16 19 22 25 26 29
+35 34 33 32 29 27 25
+50 52 53 56 57 59
+77 74 72 70 69 68 65
+88 91 92 93 96
+76 78 81 82 83
+64 66 68 69 70 73 74 75
+68 67 66 65 62 60 58
+57 56 55 52 50 48 46
+61 59 58 56 53
+15 12 9 6 5 3
+70 68 66 64 61 60 57 54
+75 78 81 83 84 85 87
+24 26 27 29 30 31 34 36
+53 56 59 60 63 66
+1 3 5 7 8 9
+89 87 84 82 79 78 76 75
+30 27 25 22 21
+37 36 34 31 30 29
+19 18 15 12 11 8 7 6
+60 58 55 54 52 50 48
+7 8 9 12 15 17
+89 90 93 94 96
+27 24 23 22 21 19 17 16
+22 20 19 18 15 14 12
+85 86 88 90 92 95 96
+38 39 40 42 45
+24 25 28 31 33 34
+70 69 68 67 65 63 62
+15 13 12 9 7 4 2
+49 48 45 42 41
+57 60 62 63 66 68
+31 34 37 38 40
+27 28 29 30 33 36
+36 34 31 30 29 28 27
+53 51 49 46 43
+95 92 90 88 85 83
+74 73 72 70 67 64
+23 20 17 16 14 13
+95 92 89 87 85 82 81 79
+36 35 34 32 31 30 29
+50 52 54 57 60 63 64
+58 61 62 63 64 65 68 70
+39 40 42 43 45 48 51
+85 84 81 79 77 74
+45 46 47 49 52
+15 16 17 20 21 22
+86 83 80 78 76 73 70 68
+51 54 57 59 62
+71 73 76 77 79 80
+68 69 72 74 77 78 79 81
+13 11 8 6 5 3
+50 52 53 56 57 59 60
+60 62 64 66 69
+80 83 84 86 88
+8 10 11 14 16
+43 46 47 50 53 56
+55 54 51 50 48 45 43
+66 68 71 74 75
+84 86 87 88 90 93
+38 37 36 33 30 27 26
+29 31 34 37 39
+12 10 9 6 4
+72 69 67 65 63 62
+23 25 26 29 30 32
+70 71 74 77 80 81 84 87

+ 40 - 0
2/solve_1.ml

@@ -0,0 +1,40 @@
+open Stdio
+open Str
+
+
+let rec construct_list l1=
+  let line = In_channel.input_line In_channel.stdin in
+  match line with
+  | None -> l1
+  | Some x -> let report = List.map int_of_string (Str.split (regexp {| |}) x) in
+              construct_list (report::l1)
+;;
+
+let rec is_safe status l = match status with
+| "ko"         -> false
+| "increasing" -> (match l with
+                              | a :: b :: tl -> if ( (a < b) && ((abs (a - b)) < 4)) then (is_safe "increasing" (b::tl)) else (is_safe "ko" [])
+                              | _ :: [] | [] -> is_safe "ok" [])
+| "decreasing" -> (match l with
+                              | a :: b :: tl -> if ( (a > b) && ((abs (a - b)) < 4)) then (is_safe "decreasing" (b::tl)) else (is_safe "ko" [])
+                              | _ :: [] | [] -> is_safe "ok" [])
+| "init"       -> (match l with
+                              | a :: b :: tl -> if ((abs (a - b)) < 4) then 
+                                                 (if (a < b) then (is_safe "increasing" (b::tl)) 
+                                                  else 
+                                                    (if (a == b) then (is_safe "ko" [])
+                                                     else (is_safe "decreasing" (b::tl)))) 
+                                                else 
+                                                  (is_safe "ko" []) 
+                              | _ :: [] | [] -> is_safe "ok" [])
+| _            -> true (*any other value is considered ok*)
+;;
+
+let rec solve accum = function
+  | hd :: tl -> if (is_safe "init" hd) then solve (accum + 1) tl else solve accum tl
+  | [] -> accum
+;;
+
+let () =
+  let li = construct_list [] in
+    printf "Total: %d\n" (solve 0 li)

+ 2 - 0
dune-project

@@ -0,0 +1,2 @@
+(lang dune 2.9)
+(name adventofcode24)