Преглед на файлове

Initial commit and Day01 P1+P2

Dorian Snowball преди 3 години
ревизия
e469ce20ff
променени са 12 файла, в които са добавени 2379 реда и са изтрити 0 реда
  1. 3 0
      .gitignore
  2. 29 0
      build.gradle.kts
  3. 1 0
      gradle.properties
  4. BIN
      gradle/wrapper/gradle-wrapper.jar
  5. 5 0
      gradle/wrapper/gradle-wrapper.properties
  6. 185 0
      gradlew
  7. 89 0
      gradlew.bat
  8. 2000 0
      puzzleInput/01-input.txt
  9. 10 0
      puzzleInput/01-test.txt
  10. 3 0
      settings.gradle.kts
  11. 47 0
      src/main/kotlin/Day01.kt
  12. 7 0
      src/main/kotlin/Main.kt

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+.idea/
+.gradle/
+build/

+ 29 - 0
build.gradle.kts

@@ -0,0 +1,29 @@
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+plugins {
+    kotlin("jvm") version "1.5.10"
+    application
+}
+
+group = "de.doriansnowball.adventofcode"
+version = "1.0-SNAPSHOT"
+
+repositories {
+    mavenCentral()
+}
+
+dependencies {
+    testImplementation(kotlin("test"))
+}
+
+tasks.test {
+    useJUnitPlatform()
+}
+
+tasks.withType<KotlinCompile> {
+    kotlinOptions.jvmTarget = "16"
+}
+
+application {
+    mainClass.set("MainKt")
+}

+ 1 - 0
gradle.properties

@@ -0,0 +1 @@
+kotlin.code.style=official

BIN
gradle/wrapper/gradle-wrapper.jar


+ 5 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists

+ 185 - 0
gradlew

@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MSYS* | MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=`expr $i + 1`
+    done
+    case $i in
+        0) set -- ;;
+        1) set -- "$args0" ;;
+        2) set -- "$args0" "$args1" ;;
+        3) set -- "$args0" "$args1" "$args2" ;;
+        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"

+ 89 - 0
gradlew.bat

@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem      https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 2000 - 0
puzzleInput/01-input.txt

@@ -0,0 +1,2000 @@
+199
+203
+200
+201
+196
+195
+196
+214
+227
+225
+229
+260
+246
+253
+271
+281
+280
+295
+310
+293
+295
+297
+298
+297
+306
+299
+290
+292
+289
+287
+291
+296
+294
+287
+286
+287
+289
+290
+281
+283
+282
+275
+256
+265
+242
+231
+226
+216
+227
+226
+249
+238
+237
+247
+245
+250
+264
+267
+259
+258
+264
+261
+249
+246
+239
+240
+259
+258
+280
+279
+278
+281
+272
+256
+255
+271
+286
+290
+286
+288
+290
+294
+292
+294
+292
+293
+294
+291
+298
+303
+301
+330
+331
+336
+362
+371
+374
+368
+367
+368
+366
+364
+371
+377
+378
+384
+386
+388
+393
+409
+423
+422
+411
+412
+426
+430
+441
+460
+462
+464
+469
+461
+483
+452
+455
+457
+468
+506
+509
+514
+525
+512
+524
+523
+522
+531
+549
+548
+549
+548
+524
+525
+528
+526
+537
+544
+549
+546
+525
+532
+535
+543
+544
+545
+525
+536
+538
+541
+524
+534
+542
+538
+539
+544
+543
+539
+538
+527
+553
+552
+562
+560
+561
+573
+574
+570
+571
+568
+569
+571
+573
+566
+567
+584
+591
+607
+605
+604
+605
+617
+615
+617
+606
+608
+609
+613
+616
+635
+634
+637
+635
+634
+655
+639
+646
+637
+628
+622
+648
+645
+640
+652
+653
+659
+661
+658
+650
+667
+670
+668
+680
+682
+673
+668
+678
+677
+675
+676
+677
+675
+688
+681
+676
+684
+675
+664
+665
+654
+660
+664
+663
+667
+658
+661
+676
+675
+680
+681
+690
+693
+697
+721
+733
+739
+740
+739
+751
+765
+766
+752
+748
+763
+772
+771
+782
+784
+797
+799
+817
+812
+811
+795
+783
+785
+790
+785
+784
+782
+771
+756
+759
+783
+772
+774
+779
+783
+786
+780
+783
+779
+777
+778
+777
+762
+778
+777
+770
+773
+769
+770
+771
+764
+765
+761
+745
+754
+758
+759
+746
+738
+740
+742
+767
+765
+754
+755
+758
+762
+760
+761
+757
+761
+770
+773
+777
+776
+777
+769
+767
+793
+805
+798
+793
+803
+809
+808
+817
+804
+809
+805
+804
+806
+808
+812
+830
+831
+832
+831
+819
+820
+823
+822
+812
+814
+812
+842
+858
+855
+856
+862
+860
+855
+839
+840
+841
+840
+846
+850
+859
+861
+852
+846
+848
+845
+833
+843
+846
+849
+889
+890
+894
+904
+907
+904
+905
+906
+907
+910
+902
+906
+900
+907
+906
+899
+887
+867
+866
+873
+878
+885
+880
+890
+863
+860
+859
+885
+856
+853
+854
+852
+864
+855
+874
+875
+874
+875
+871
+872
+867
+870
+873
+874
+860
+862
+879
+878
+879
+880
+881
+882
+878
+882
+885
+890
+902
+903
+905
+906
+909
+917
+916
+934
+932
+935
+937
+935
+910
+911
+907
+902
+904
+910
+917
+918
+943
+945
+959
+973
+972
+969
+973
+972
+958
+957
+959
+963
+968
+961
+960
+973
+971
+970
+977
+1002
+1012
+1011
+1007
+1017
+1024
+1014
+1013
+1019
+1005
+984
+983
+980
+993
+999
+982
+988
+989
+990
+992
+988
+989
+988
+981
+958
+973
+966
+965
+942
+926
+933
+928
+932
+940
+927
+930
+920
+930
+897
+905
+907
+889
+882
+888
+889
+872
+873
+885
+884
+886
+887
+898
+901
+902
+895
+880
+894
+886
+882
+885
+890
+896
+880
+881
+866
+872
+875
+903
+901
+907
+899
+920
+921
+934
+935
+937
+928
+929
+927
+928
+935
+906
+908
+906
+882
+883
+887
+891
+892
+898
+903
+907
+909
+916
+917
+945
+935
+937
+928
+918
+927
+916
+929
+919
+931
+954
+953
+954
+956
+953
+947
+937
+941
+960
+968
+951
+955
+954
+938
+939
+946
+945
+947
+948
+951
+943
+949
+946
+954
+952
+949
+943
+936
+944
+941
+950
+952
+948
+947
+971
+970
+969
+974
+971
+1000
+1005
+1007
+1009
+1008
+1000
+998
+999
+1001
+1008
+1001
+1024
+1005
+998
+1016
+1018
+1019
+1020
+1021
+1057
+1056
+1052
+1044
+1045
+1057
+1058
+1074
+1075
+1069
+1056
+1055
+1056
+1052
+1059
+1070
+1043
+1039
+1035
+1025
+1015
+1018
+1029
+1033
+1042
+1038
+1031
+1033
+1023
+1016
+1019
+1018
+1016
+1018
+1020
+1009
+1008
+997
+973
+983
+990
+996
+1002
+1001
+1000
+1002
+1001
+1015
+1016
+1015
+1019
+1020
+1016
+1010
+1009
+1008
+1016
+1018
+1015
+1011
+1004
+999
+1000
+1027
+1035
+1050
+1051
+1068
+1058
+1072
+1086
+1089
+1060
+1043
+1028
+1026
+1028
+1052
+1050
+1042
+1040
+1036
+1055
+1050
+1051
+1049
+1053
+1054
+1059
+1058
+1066
+1059
+1061
+1070
+1071
+1068
+1059
+1060
+1065
+1066
+1068
+1060
+1059
+1070
+1069
+1068
+1067
+1068
+1070
+1069
+1066
+1073
+1065
+1066
+1050
+1052
+1050
+1056
+1055
+1063
+1062
+1057
+1054
+1048
+1047
+1051
+1049
+1043
+1017
+1016
+1002
+1005
+992
+994
+999
+1001
+1017
+1026
+1024
+1028
+1040
+1039
+1046
+1022
+1023
+992
+995
+1019
+1022
+1023
+1011
+1004
+1005
+993
+991
+992
+995
+996
+997
+1009
+1011
+1012
+1017
+1030
+1029
+1031
+1024
+1033
+1008
+1006
+1018
+1020
+1015
+1020
+1031
+1029
+1026
+1030
+1042
+1039
+1029
+1027
+1008
+1003
+1019
+1000
+1001
+995
+996
+994
+988
+989
+988
+987
+994
+997
+1000
+994
+997
+989
+991
+985
+975
+982
+981
+986
+980
+979
+973
+984
+985
+983
+981
+956
+925
+924
+919
+913
+915
+917
+914
+916
+895
+910
+924
+919
+914
+928
+935
+927
+930
+932
+936
+939
+944
+948
+947
+946
+945
+948
+944
+942
+944
+958
+956
+947
+955
+990
+995
+996
+1007
+1009
+1013
+1012
+1011
+1020
+1019
+1021
+1016
+1038
+1050
+1043
+1046
+1047
+1043
+1040
+1039
+1045
+1046
+1030
+1031
+1034
+1035
+1045
+1066
+1085
+1092
+1101
+1100
+1101
+1099
+1084
+1085
+1086
+1090
+1091
+1087
+1100
+1099
+1092
+1095
+1101
+1102
+1118
+1117
+1138
+1139
+1132
+1127
+1131
+1132
+1130
+1128
+1130
+1150
+1149
+1157
+1158
+1156
+1157
+1155
+1170
+1175
+1167
+1166
+1177
+1174
+1186
+1187
+1186
+1185
+1189
+1193
+1204
+1191
+1196
+1198
+1186
+1198
+1215
+1210
+1211
+1212
+1211
+1207
+1206
+1198
+1202
+1190
+1185
+1190
+1199
+1222
+1225
+1222
+1234
+1236
+1260
+1261
+1262
+1272
+1289
+1286
+1290
+1297
+1295
+1270
+1291
+1299
+1303
+1318
+1342
+1356
+1361
+1362
+1326
+1325
+1333
+1329
+1349
+1353
+1367
+1368
+1371
+1369
+1353
+1351
+1349
+1352
+1354
+1353
+1356
+1355
+1362
+1366
+1368
+1370
+1349
+1354
+1357
+1356
+1360
+1357
+1361
+1363
+1364
+1345
+1338
+1335
+1334
+1322
+1329
+1333
+1334
+1331
+1330
+1337
+1348
+1347
+1348
+1317
+1307
+1313
+1330
+1323
+1324
+1327
+1334
+1336
+1334
+1332
+1338
+1341
+1342
+1373
+1375
+1374
+1372
+1373
+1371
+1370
+1375
+1363
+1361
+1366
+1389
+1390
+1366
+1380
+1381
+1379
+1383
+1400
+1402
+1404
+1409
+1410
+1434
+1439
+1443
+1448
+1434
+1462
+1463
+1462
+1464
+1465
+1471
+1465
+1464
+1469
+1473
+1480
+1486
+1488
+1492
+1494
+1495
+1496
+1504
+1496
+1495
+1472
+1469
+1465
+1466
+1455
+1464
+1465
+1474
+1475
+1490
+1499
+1490
+1492
+1489
+1500
+1504
+1500
+1499
+1500
+1510
+1511
+1516
+1511
+1515
+1512
+1499
+1506
+1509
+1493
+1495
+1496
+1485
+1486
+1476
+1475
+1484
+1485
+1469
+1477
+1478
+1467
+1468
+1469
+1477
+1478
+1475
+1473
+1461
+1468
+1470
+1496
+1491
+1506
+1505
+1526
+1530
+1528
+1529
+1533
+1555
+1558
+1557
+1554
+1557
+1559
+1560
+1562
+1561
+1563
+1564
+1550
+1559
+1558
+1559
+1554
+1535
+1538
+1541
+1540
+1529
+1528
+1519
+1527
+1535
+1518
+1523
+1519
+1536
+1562
+1561
+1566
+1568
+1583
+1584
+1599
+1585
+1581
+1588
+1559
+1561
+1574
+1587
+1574
+1576
+1589
+1588
+1582
+1581
+1584
+1604
+1563
+1555
+1561
+1564
+1548
+1541
+1542
+1546
+1548
+1550
+1566
+1544
+1523
+1525
+1521
+1541
+1550
+1551
+1548
+1558
+1561
+1560
+1550
+1563
+1578
+1582
+1563
+1557
+1558
+1557
+1559
+1574
+1569
+1577
+1576
+1577
+1571
+1573
+1572
+1574
+1577
+1581
+1566
+1535
+1539
+1540
+1536
+1545
+1544
+1513
+1511
+1509
+1502
+1489
+1490
+1495
+1488
+1492
+1513
+1519
+1520
+1521
+1530
+1512
+1514
+1512
+1517
+1518
+1520
+1519
+1527
+1526
+1527
+1528
+1529
+1522
+1525
+1529
+1525
+1524
+1525
+1527
+1529
+1524
+1523
+1525
+1533
+1535
+1536
+1555
+1557
+1573
+1572
+1571
+1590
+1593
+1594
+1593
+1565
+1566
+1554
+1572
+1567
+1569
+1566
+1597
+1616
+1630
+1641
+1638
+1634
+1647
+1651
+1649
+1652
+1659
+1660
+1651
+1656
+1653
+1654
+1653
+1658
+1643
+1642
+1641
+1654
+1655
+1656
+1666
+1673
+1682
+1665
+1663
+1670
+1654
+1668
+1667
+1656
+1646
+1655
+1662
+1680
+1683
+1682
+1683
+1684
+1722
+1702
+1710
+1711
+1715
+1728
+1730
+1735
+1736
+1750
+1755
+1756
+1755
+1752
+1761
+1768
+1767
+1760
+1751
+1747
+1764
+1763
+1762
+1748
+1753
+1745
+1752
+1754
+1746
+1747
+1748
+1756
+1761
+1756
+1734
+1711
+1712
+1721
+1727
+1726
+1731
+1729
+1715
+1716
+1733
+1738
+1740
+1756
+1755
+1748
+1744
+1751
+1756
+1774
+1775
+1755
+1746
+1754
+1758
+1767
+1785
+1786
+1787
+1788
+1766
+1787
+1786
+1788
+1762
+1757
+1752
+1760
+1781
+1750
+1757
+1762
+1767
+1770
+1744
+1743
+1747
+1756
+1763
+1775
+1769
+1760
+1759
+1766
+1768
+1764
+1759
+1761
+1792
+1798
+1800
+1802
+1813
+1810
+1822
+1824
+1816
+1842
+1843
+1835
+1833
+1834
+1837
+1826
+1830
+1850
+1855
+1857
+1862
+1856
+1877
+1878
+1875
+1850
+1847
+1846
+1847
+1846
+1826
+1829
+1825
+1817
+1818
+1815
+1834
+1833
+1822
+1825
+1815
+1817
+1815
+1816
+1810
+1822
+1815
+1817
+1821
+1820
+1814
+1802
+1799
+1814
+1834
+1830
+1842
+1828
+1836
+1849
+1851
+1849
+1848
+1849
+1865
+1885
+1895
+1904
+1910
+1921
+1937
+1941
+1970
+1968
+1975
+1982
+2003
+2012
+2011
+2008
+2006
+1997
+1994
+1991
+1989
+1988
+1995
+1976
+2006
+2018
+2015
+2023
+2022
+2023
+2048
+2038
+2039
+2041
+2057
+2058
+2059
+2060
+2059
+2061
+2031
+2032
+2033
+2020
+2019
+2023
+2032
+2034
+2027
+2029
+2027
+2018
+2028
+2055
+2054
+2043
+2047
+2046
+2055
+2047
+2056
+2037
+2032
+2003
+2002
+1999
+2001
+1996
+2000
+2002
+2004
+1988
+1990
+1999
+1986
+1988
+1986
+1985
+1977
+1978
+1977
+1973
+1977
+1978
+1985
+1988
+1964
+1967
+1989
+1984
+1980
+1979
+1980
+1999
+2006
+2004
+2018
+2051
+2024
+2023
+2025
+2026
+2012
+2000
+2017
+2018
+2017
+2019
+2017
+2025
+2030
+2038
+2016
+2001
+2020
+2018
+2010
+2013
+2028
+2031
+2018
+2019
+2009
+2015
+2011
+2012
+2024
+2027
+2028
+2018
+2007
+2009
+2011
+2009
+2008
+2006
+2008
+2013
+2017
+2027
+2030
+2031
+2029
+2045
+2064
+2065
+2064
+2077
+2075
+2066
+2037
+2038
+2043
+2047
+2049
+2055
+2090
+2092
+2101
+2115
+2117
+2130
+2131
+2130
+2136
+2141
+2145
+2151
+2150
+2149
+2150
+2143
+2150
+2139
+2142
+2140
+2146
+2147
+2148
+2146
+2141
+2158
+2176
+2195
+2194
+2190
+2187
+2188
+2205
+2206
+2208
+2207
+2208
+2200
+2199
+2193
+2169
+2188
+2189
+2183
+2202
+2170
+2164
+2165
+2166
+2177
+2181
+2198
+2197
+2207
+2201
+2206
+2203
+2209
+2213
+2214
+2216
+2218
+2219
+2214
+2235
+2239
+2235
+2253
+2246
+2247
+2246
+2247
+2246
+2251
+2249
+2275
+2285
+2293
+2294
+2295
+2299
+2303
+2302
+2303
+2276
+2282
+2287
+2294
+2299
+2301
+2300
+2306
+2294
+2301
+2296
+2289
+2291
+2300
+2301
+2287
+2286
+2307
+2305
+2315
+2305
+2309
+2334
+2337
+2348
+2349
+2350
+2332
+2342
+2341
+2338
+2310
+2316
+2333
+2335
+2330
+2342
+2349
+2341
+2363
+2368
+2374
+2360
+2359
+2350
+2348
+2359
+2365
+2364
+2355
+2341
+2339
+2345
+2338
+2335
+2323
+2324
+2318
+2294
+2296
+2297
+2286
+2282
+2278
+2276
+2272
+2267
+2269
+2270
+2269
+2266
+2268
+2264
+2268
+2260
+2263
+2297
+2311
+2319
+2301
+2292
+2302
+2309
+2307
+2303
+2306
+2311
+2293
+2278
+2284
+2288
+2271
+2273
+2275
+2278
+2279
+2283
+2318
+2315
+2312
+2325
+2346
+2339
+2314
+2303
+2304
+2279
+2278
+2269
+2267
+2270
+2277
+2287
+2285
+2288
+2289
+2288
+2284
+2283
+2281
+2289
+2288
+2275
+2278
+2265
+2267
+2262
+2259
+2260
+2261
+2251
+2250
+2254
+2253
+2242
+2240
+2241
+2226
+2232
+2236
+2201
+2182
+2183
+2191
+2185
+2192
+2197
+2211
+2210
+2208
+2218
+2219
+2228
+2227
+2225
+2226
+2225
+2226
+2229
+2233
+2237
+2236
+2211
+2215
+2216
+2236
+2227
+2228
+2227
+2226
+2244
+2260
+2258
+2257
+2258
+2250
+2248
+2229
+2225
+2223
+2222
+2221
+2220
+2219
+2213
+2214
+2212
+2216
+2217
+2220
+2216
+2217
+2223
+2227
+2231
+2225
+2228
+2230
+2233
+2226
+2224
+2241
+2221
+2220
+2224
+2221
+2220
+2223
+2221
+2246
+2247
+2246
+2222
+2226
+2237
+2250
+2251
+2276
+2288
+2309
+2304
+2330
+2323
+2327
+2350
+2349
+2348
+2346
+2354
+2350
+2323
+2320
+2313
+2315
+2314
+2316
+2332
+2338
+2341

+ 10 - 0
puzzleInput/01-test.txt

@@ -0,0 +1,10 @@
+199
+200
+208
+210
+200
+207
+240
+269
+260
+263

+ 3 - 0
settings.gradle.kts

@@ -0,0 +1,3 @@
+
+rootProject.name = "AdventofCode2021"
+

+ 47 - 0
src/main/kotlin/Day01.kt

@@ -0,0 +1,47 @@
+import java.nio.file.Files
+import kotlin.io.path.Path
+
+fun main() {
+
+    val lines = Files.readAllLines(Path("puzzleInput/01-input.txt"))
+    println(lines)
+    val day = Day01(lines)
+    day.solvePuzzlePartOne()
+    day.solvePuzzlePartTwo()
+}
+class Day01(val lines: MutableList<String>) {
+
+    fun solvePuzzlePartOne() {
+        var lastDepth: Int? = null;
+        var count = 0;
+        for (line in lines) {
+            var depth = line.toInt();
+            if (lastDepth != null) {
+                if (lastDepth<depth)
+                    count++
+            }
+            lastDepth = line.toInt();
+        }
+        println("PartOne: $count")
+    }
+
+    fun solvePuzzlePartTwo() {
+        var lastDepth: IntArray = intArrayOf(-1,-1,-1)
+        var count = 0;
+        lines.forEachIndexed { i, line ->
+            run {
+                if (i+2 < lines.size) {
+                    val depth: IntArray = intArrayOf(line.toInt(), lines[i+1].toInt(), lines[i+2].toInt())
+//                    println("Window: ${i}, ${i+1}, ${i+2}: ${depth.sum()}")
+                    if (lastDepth[0] != -1)
+                    if (depth.sum()>lastDepth.sum())
+                        count++
+                    lastDepth = depth;
+                }
+
+            }
+        }
+
+        println("PartTwo: $count")
+    }
+}

+ 7 - 0
src/main/kotlin/Main.kt

@@ -0,0 +1,7 @@
+fun main(args: Array<String>) {
+    println("Hello World!")
+
+    // Try adding program arguments via Run/Debug configuration.
+    // Learn more about running applications: https://www.jetbrains.com/help/idea/running-applications.html.
+    println("Program arguments: ${args.joinToString()}")
+}