import java.io.*
fun print_day_13() {
    val yellow = "\u001B[33m"
    val reset = "\u001b[0m"
    val green = "\u001B[32m"
    println(yellow + "-".repeat(25) + "Advent of Code - Day 13" + "-".repeat(25) + reset)
    println(green)
    val process = Runtime.getRuntime().exec("figlet Transparent Origami -c -f small")
    val reader = BufferedReader(InputStreamReader(process.inputStream))
    reader.forEachLine { println(it) }
    println(reset)
    println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
    print_day_13()
    Day13().part_1()
    Day13().part_2()
    println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}

class Day13 {
    private val lines = File("../Input/day13.txt").readLines()
    private val coords = lines.takeWhile { it.trim() != "" }.map {
        val (x, y) = it.split(",")
        x.toInt() to y.toInt()
    }
    private val folds = lines.drop(coords.size + 1)

    fun part_1() {

        val maxX = coords.maxOf { it.first }
        val maxY = coords.maxOf { it.second }

        val yFold = folds.first().startsWith("fold along y")
        val foldAmount = folds.first().split("=")[1].toInt()

        val afterFold = if (yFold) {
                val newCoords = coords.filter { it.second < foldAmount }.toMutableList()
                for (pair in coords.filter {it.second > foldAmount} ) {
                    newCoords.add(pair.first to maxY - pair.second)
                }
                newCoords
            }
            else  {
                val newCoords = coords.filter { it.first < foldAmount }.toMutableList()
                for (pair in coords.filter {it.first > foldAmount} ) {
                    newCoords.add(maxX - pair.first to pair.second)
                }
                newCoords
            }

        println("Puzzle 1: " + afterFold.distinct().size)
    }

    fun part_2() {

        var foldedCoords = coords
        folds.forEach { fold ->
            val maxX = foldedCoords.maxOf { it.first }
            val maxY = foldedCoords.maxOf { it.second }

            val yFold = fold.startsWith("fold along y")
            val foldAmount = fold.split("=")[1].toInt()

            val afterFold = if (yFold) {
                val newCoords = foldedCoords.filter { it.second < foldAmount }.toMutableList()
                for (pair in foldedCoords.filter {it.second > foldAmount} ) {
                    newCoords.add(pair.first to maxY - pair.second)
                }
                newCoords
            }
            else  {
                val newCoords = foldedCoords.filter { it.first < foldAmount }.toMutableList()
                for (pair in foldedCoords.filter {it.first > foldAmount} ) {
                    newCoords.add(maxX - pair.first to pair.second)
                }
                newCoords
            }

            foldedCoords = afterFold
        }

        val maxX = foldedCoords.maxOf { it.first }
        val maxY = foldedCoords.maxOf { it.second }
        println("Puzzle 2: ")
        for (y in 0..maxY) {
            for (x in 0..maxX) {
                print( if ((x to y) in foldedCoords) "#" else " ")
            }
            println()
        }
    }
}

Compiled from "day13.kt"
public final class Day13 {
  private final java.util.List<java.lang.String> lines;

  private final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> coords;

  private final java.util.List<java.lang.String> folds;

  public Day13();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: new           #10                 // class java/io/File
       8: dup
       9: ldc           #12                 // String ../Input/day13.txt
      11: invokespecial #15                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      14: aconst_null
      15: iconst_1
      16: aconst_null
      17: invokestatic  #21                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      20: putfield      #25                 // Field lines:Ljava/util/List;
      23: aload_0
      24: aload_0
      25: getfield      #25                 // Field lines:Ljava/util/List;
      28: checkcast     #27                 // class java/lang/Iterable
      31: astore_1
      32: astore        13
      34: iconst_0
      35: istore_2
      36: new           #29                 // class java/util/ArrayList
      39: dup
      40: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
      43: astore_3
      44: aload_1
      45: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        4
      52: aload         4
      54: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          121
      62: aload         4
      64: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        5
      71: aload         5
      73: checkcast     #46                 // class java/lang/String
      76: astore        6
      78: iconst_0
      79: istore        7
      81: aload         6
      83: checkcast     #48                 // class java/lang/CharSequence
      86: invokestatic  #54                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      89: invokevirtual #58                 // Method java/lang/Object.toString:()Ljava/lang/String;
      92: ldc           #60                 // String
      94: invokestatic  #66                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      97: ifne          104
     100: iconst_1
     101: goto          105
     104: iconst_0
     105: ifne          111
     108: goto          121
     111: aload_3
     112: aload         5
     114: invokevirtual #70                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     117: pop
     118: goto          52
     121: aload_3
     122: checkcast     #72                 // class java/util/List
     125: aload         13
     127: swap
     128: checkcast     #27                 // class java/lang/Iterable
     131: astore_1
     132: astore        13
     134: iconst_0
     135: istore_2
     136: aload_1
     137: astore_3
     138: new           #29                 // class java/util/ArrayList
     141: dup
     142: aload_1
     143: bipush        10
     145: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     148: invokespecial #81                 // Method java/util/ArrayList."<init>":(I)V
     151: checkcast     #83                 // class java/util/Collection
     154: astore        4
     156: iconst_0
     157: istore        5
     159: aload_3
     160: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     165: astore        6
     167: aload         6
     169: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     174: ifeq          286
     177: aload         6
     179: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     184: astore        7
     186: aload         4
     188: aload         7
     190: checkcast     #46                 // class java/lang/String
     193: astore        8
     195: astore        14
     197: iconst_0
     198: istore        9
     200: aload         8
     202: checkcast     #48                 // class java/lang/CharSequence
     205: iconst_1
     206: anewarray     #46                 // class java/lang/String
     209: astore        10
     211: aload         10
     213: iconst_0
     214: ldc           #85                 // String ,
     216: aastore
     217: aload         10
     219: iconst_0
     220: iconst_0
     221: bipush        6
     223: aconst_null
     224: invokestatic  #89                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     227: astore        11
     229: aload         11
     231: iconst_0
     232: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     237: checkcast     #46                 // class java/lang/String
     240: astore        10
     242: aload         11
     244: iconst_1
     245: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     250: checkcast     #46                 // class java/lang/String
     253: astore        12
     255: aload         10
     257: invokestatic  #99                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     260: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     263: aload         12
     265: invokestatic  #99                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     268: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     271: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     274: aload         14
     276: swap
     277: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     282: pop
     283: goto          167
     286: aload         4
     288: checkcast     #72                 // class java/util/List
     291: nop
     292: aload         13
     294: swap
     295: putfield      #113                // Field coords:Ljava/util/List;
     298: aload_0
     299: aload_0
     300: getfield      #25                 // Field lines:Ljava/util/List;
     303: checkcast     #27                 // class java/lang/Iterable
     306: aload_0
     307: getfield      #113                // Field coords:Ljava/util/List;
     310: invokeinterface #117,  1          // InterfaceMethod java/util/List.size:()I
     315: iconst_1
     316: iadd
     317: invokestatic  #121                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     320: putfield      #124                // Field folds:Ljava/util/List;
     323: return

  public final void part_1();
    Code:
       0: aload_0
       1: getfield      #113                // Field coords:Ljava/util/List;
       4: checkcast     #27                 // class java/lang/Iterable
       7: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      12: astore_3
      13: aload_3
      14: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      19: ifne          30
      22: new           #150                // class java/util/NoSuchElementException
      25: dup
      26: invokespecial #151                // Method java/util/NoSuchElementException."<init>":()V
      29: athrow
      30: aload_3
      31: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: checkcast     #153                // class kotlin/Pair
      39: astore        4
      41: iconst_0
      42: istore        5
      44: aload         4
      46: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      49: checkcast     #158                // class java/lang/Number
      52: invokevirtual #161                // Method java/lang/Number.intValue:()I
      55: istore        4
      57: aload_3
      58: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          107
      66: aload_3
      67: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      72: checkcast     #153                // class kotlin/Pair
      75: astore        5
      77: iconst_0
      78: istore        6
      80: aload         5
      82: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      85: checkcast     #158                // class java/lang/Number
      88: invokevirtual #161                // Method java/lang/Number.intValue:()I
      91: istore        5
      93: iload         4
      95: iload         5
      97: if_icmpge     57
     100: iload         5
     102: istore        4
     104: goto          57
     107: iload         4
     109: istore_1
     110: aload_0
     111: getfield      #113                // Field coords:Ljava/util/List;
     114: checkcast     #27                 // class java/lang/Iterable
     117: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     122: astore        4
     124: aload         4
     126: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     131: ifne          142
     134: new           #150                // class java/util/NoSuchElementException
     137: dup
     138: invokespecial #151                // Method java/util/NoSuchElementException."<init>":()V
     141: athrow
     142: aload         4
     144: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     149: checkcast     #153                // class kotlin/Pair
     152: astore        5
     154: iconst_0
     155: istore        6
     157: aload         5
     159: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     162: checkcast     #158                // class java/lang/Number
     165: invokevirtual #161                // Method java/lang/Number.intValue:()I
     168: istore        5
     170: aload         4
     172: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     177: ifeq          222
     180: aload         4
     182: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     187: checkcast     #153                // class kotlin/Pair
     190: astore        6
     192: iconst_0
     193: istore        7
     195: aload         6
     197: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     200: checkcast     #158                // class java/lang/Number
     203: invokevirtual #161                // Method java/lang/Number.intValue:()I
     206: istore        6
     208: iload         5
     210: iload         6
     212: if_icmpge     170
     215: iload         6
     217: istore        5
     219: goto          170
     222: iload         5
     224: istore_2
     225: aload_0
     226: getfield      #124                // Field folds:Ljava/util/List;
     229: invokestatic  #168                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     232: checkcast     #46                 // class java/lang/String
     235: ldc           #170                // String fold along y
     237: iconst_0
     238: iconst_2
     239: aconst_null
     240: invokestatic  #174                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     243: istore_3
     244: aload_0
     245: getfield      #124                // Field folds:Ljava/util/List;
     248: invokestatic  #168                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     251: checkcast     #48                 // class java/lang/CharSequence
     254: iconst_1
     255: anewarray     #46                 // class java/lang/String
     258: astore        5
     260: aload         5
     262: iconst_0
     263: ldc           #176                // String =
     265: aastore
     266: aload         5
     268: iconst_0
     269: iconst_0
     270: bipush        6
     272: aconst_null
     273: invokestatic  #89                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     276: iconst_1
     277: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     282: checkcast     #46                 // class java/lang/String
     285: invokestatic  #99                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     288: istore        4
     290: iload_3
     291: ifeq          595
     294: aload_0
     295: getfield      #113                // Field coords:Ljava/util/List;
     298: checkcast     #27                 // class java/lang/Iterable
     301: astore        7
     303: iconst_0
     304: istore        8
     306: aload         7
     308: astore        9
     310: new           #29                 // class java/util/ArrayList
     313: dup
     314: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     317: checkcast     #83                 // class java/util/Collection
     320: astore        10
     322: iconst_0
     323: istore        11
     325: aload         9
     327: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     332: astore        12
     334: aload         12
     336: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     341: ifeq          400
     344: aload         12
     346: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     351: astore        13
     353: aload         13
     355: checkcast     #153                // class kotlin/Pair
     358: astore        14
     360: iconst_0
     361: istore        15
     363: aload         14
     365: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     368: checkcast     #158                // class java/lang/Number
     371: invokevirtual #161                // Method java/lang/Number.intValue:()I
     374: iload         4
     376: if_icmpge     383
     379: iconst_1
     380: goto          384
     383: iconst_0
     384: ifeq          334
     387: aload         10
     389: aload         13
     391: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     396: pop
     397: goto          334
     400: aload         10
     402: checkcast     #72                 // class java/util/List
     405: nop
     406: checkcast     #83                 // class java/util/Collection
     409: invokestatic  #180                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     412: astore        6
     414: aload_0
     415: getfield      #113                // Field coords:Ljava/util/List;
     418: checkcast     #27                 // class java/lang/Iterable
     421: astore        8
     423: iconst_0
     424: istore        9
     426: aload         8
     428: astore        10
     430: new           #29                 // class java/util/ArrayList
     433: dup
     434: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     437: checkcast     #83                 // class java/util/Collection
     440: astore        11
     442: iconst_0
     443: istore        12
     445: aload         10
     447: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     452: astore        13
     454: aload         13
     456: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     461: ifeq          520
     464: aload         13
     466: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     471: astore        14
     473: aload         14
     475: checkcast     #153                // class kotlin/Pair
     478: astore        15
     480: iconst_0
     481: istore        16
     483: aload         15
     485: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     488: checkcast     #158                // class java/lang/Number
     491: invokevirtual #161                // Method java/lang/Number.intValue:()I
     494: iload         4
     496: if_icmple     503
     499: iconst_1
     500: goto          504
     503: iconst_0
     504: ifeq          454
     507: aload         11
     509: aload         14
     511: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     516: pop
     517: goto          454
     520: aload         11
     522: checkcast     #72                 // class java/util/List
     525: nop
     526: invokeinterface #181,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     531: astore        7
     533: aload         7
     535: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     540: ifeq          590
     543: aload         7
     545: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     550: checkcast     #153                // class kotlin/Pair
     553: astore        8
     555: aload         6
     557: aload         8
     559: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     562: iload_2
     563: aload         8
     565: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     568: checkcast     #158                // class java/lang/Number
     571: invokevirtual #161                // Method java/lang/Number.intValue:()I
     574: isub
     575: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     578: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     581: invokeinterface #182,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     586: pop
     587: goto          533
     590: aload         6
     592: goto          893
     595: aload_0
     596: getfield      #113                // Field coords:Ljava/util/List;
     599: checkcast     #27                 // class java/lang/Iterable
     602: astore        7
     604: iconst_0
     605: istore        8
     607: aload         7
     609: astore        9
     611: new           #29                 // class java/util/ArrayList
     614: dup
     615: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     618: checkcast     #83                 // class java/util/Collection
     621: astore        10
     623: iconst_0
     624: istore        11
     626: aload         9
     628: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     633: astore        12
     635: aload         12
     637: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     642: ifeq          701
     645: aload         12
     647: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     652: astore        13
     654: aload         13
     656: checkcast     #153                // class kotlin/Pair
     659: astore        14
     661: iconst_0
     662: istore        15
     664: aload         14
     666: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     669: checkcast     #158                // class java/lang/Number
     672: invokevirtual #161                // Method java/lang/Number.intValue:()I
     675: iload         4
     677: if_icmpge     684
     680: iconst_1
     681: goto          685
     684: iconst_0
     685: ifeq          635
     688: aload         10
     690: aload         13
     692: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     697: pop
     698: goto          635
     701: aload         10
     703: checkcast     #72                 // class java/util/List
     706: nop
     707: checkcast     #83                 // class java/util/Collection
     710: invokestatic  #180                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     713: astore        6
     715: aload_0
     716: getfield      #113                // Field coords:Ljava/util/List;
     719: checkcast     #27                 // class java/lang/Iterable
     722: astore        8
     724: iconst_0
     725: istore        9
     727: aload         8
     729: astore        10
     731: new           #29                 // class java/util/ArrayList
     734: dup
     735: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     738: checkcast     #83                 // class java/util/Collection
     741: astore        11
     743: iconst_0
     744: istore        12
     746: aload         10
     748: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     753: astore        13
     755: aload         13
     757: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     762: ifeq          821
     765: aload         13
     767: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     772: astore        14
     774: aload         14
     776: checkcast     #153                // class kotlin/Pair
     779: astore        15
     781: iconst_0
     782: istore        16
     784: aload         15
     786: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     789: checkcast     #158                // class java/lang/Number
     792: invokevirtual #161                // Method java/lang/Number.intValue:()I
     795: iload         4
     797: if_icmple     804
     800: iconst_1
     801: goto          805
     804: iconst_0
     805: ifeq          755
     808: aload         11
     810: aload         14
     812: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     817: pop
     818: goto          755
     821: aload         11
     823: checkcast     #72                 // class java/util/List
     826: nop
     827: invokeinterface #181,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     832: astore        7
     834: aload         7
     836: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     841: ifeq          891
     844: aload         7
     846: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     851: checkcast     #153                // class kotlin/Pair
     854: astore        8
     856: aload         6
     858: iload_1
     859: aload         8
     861: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     864: checkcast     #158                // class java/lang/Number
     867: invokevirtual #161                // Method java/lang/Number.intValue:()I
     870: isub
     871: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     874: aload         8
     876: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     879: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     882: invokeinterface #182,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     887: pop
     888: goto          834
     891: aload         6
     893: astore        5
     895: new           #184                // class java/lang/StringBuilder
     898: dup
     899: invokespecial #185                // Method java/lang/StringBuilder."<init>":()V
     902: ldc           #187                // String Puzzle 1:
     904: invokevirtual #191                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     907: aload         5
     909: checkcast     #27                 // class java/lang/Iterable
     912: invokestatic  #195                // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;
     915: invokeinterface #117,  1          // InterfaceMethod java/util/List.size:()I
     920: invokevirtual #198                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     923: invokevirtual #199                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     926: getstatic     #205                // Field java/lang/System.out:Ljava/io/PrintStream;
     929: swap
     930: invokevirtual #211                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     933: return

  public final void part_2();
    Code:
       0: aconst_null
       1: astore_1
       2: aload_0
       3: getfield      #113                // Field coords:Ljava/util/List;
       6: astore_1
       7: aload_0
       8: getfield      #124                // Field folds:Ljava/util/List;
      11: checkcast     #27                 // class java/lang/Iterable
      14: astore_2
      15: iconst_0
      16: istore_3
      17: aload_2
      18: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      23: astore        4
      25: aload         4
      27: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          937
      35: aload         4
      37: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        5
      44: aload         5
      46: checkcast     #46                 // class java/lang/String
      49: astore        6
      51: iconst_0
      52: istore        7
      54: aload_1
      55: checkcast     #27                 // class java/lang/Iterable
      58: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      63: astore        8
      65: aload         8
      67: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      72: ifne          83
      75: new           #150                // class java/util/NoSuchElementException
      78: dup
      79: invokespecial #151                // Method java/util/NoSuchElementException."<init>":()V
      82: athrow
      83: aload         8
      85: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: checkcast     #153                // class kotlin/Pair
      93: astore        9
      95: iconst_0
      96: istore        10
      98: aload         9
     100: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     103: checkcast     #158                // class java/lang/Number
     106: invokevirtual #161                // Method java/lang/Number.intValue:()I
     109: istore        9
     111: aload         8
     113: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     118: ifeq          163
     121: aload         8
     123: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     128: checkcast     #153                // class kotlin/Pair
     131: astore        10
     133: iconst_0
     134: istore        11
     136: aload         10
     138: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     141: checkcast     #158                // class java/lang/Number
     144: invokevirtual #161                // Method java/lang/Number.intValue:()I
     147: istore        10
     149: iload         9
     151: iload         10
     153: if_icmpge     111
     156: iload         10
     158: istore        9
     160: goto          111
     163: iload         9
     165: istore        12
     167: aload_1
     168: checkcast     #27                 // class java/lang/Iterable
     171: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     176: astore        9
     178: aload         9
     180: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     185: ifne          196
     188: new           #150                // class java/util/NoSuchElementException
     191: dup
     192: invokespecial #151                // Method java/util/NoSuchElementException."<init>":()V
     195: athrow
     196: aload         9
     198: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     203: checkcast     #153                // class kotlin/Pair
     206: astore        10
     208: iconst_0
     209: istore        11
     211: aload         10
     213: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     216: checkcast     #158                // class java/lang/Number
     219: invokevirtual #161                // Method java/lang/Number.intValue:()I
     222: istore        10
     224: aload         9
     226: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     231: ifeq          276
     234: aload         9
     236: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     241: checkcast     #153                // class kotlin/Pair
     244: astore        11
     246: iconst_0
     247: istore        13
     249: aload         11
     251: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     254: checkcast     #158                // class java/lang/Number
     257: invokevirtual #161                // Method java/lang/Number.intValue:()I
     260: istore        11
     262: iload         10
     264: iload         11
     266: if_icmpge     224
     269: iload         11
     271: istore        10
     273: goto          224
     276: iload         10
     278: istore        14
     280: aload         6
     282: ldc           #170                // String fold along y
     284: iconst_0
     285: iconst_2
     286: aconst_null
     287: invokestatic  #174                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     290: istore        8
     292: aload         6
     294: checkcast     #48                 // class java/lang/CharSequence
     297: iconst_1
     298: anewarray     #46                 // class java/lang/String
     301: astore        10
     303: aload         10
     305: iconst_0
     306: ldc           #176                // String =
     308: aastore
     309: aload         10
     311: iconst_0
     312: iconst_0
     313: bipush        6
     315: aconst_null
     316: invokestatic  #89                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     319: iconst_1
     320: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     325: checkcast     #46                 // class java/lang/String
     328: invokestatic  #99                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     331: istore        9
     333: iload         8
     335: ifeq          634
     338: aload_1
     339: checkcast     #27                 // class java/lang/Iterable
     342: astore        13
     344: iconst_0
     345: istore        15
     347: aload         13
     349: astore        16
     351: new           #29                 // class java/util/ArrayList
     354: dup
     355: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     358: checkcast     #83                 // class java/util/Collection
     361: astore        17
     363: iconst_0
     364: istore        18
     366: aload         16
     368: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     373: astore        19
     375: aload         19
     377: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     382: ifeq          441
     385: aload         19
     387: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     392: astore        20
     394: aload         20
     396: checkcast     #153                // class kotlin/Pair
     399: astore        21
     401: iconst_0
     402: istore        22
     404: aload         21
     406: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     409: checkcast     #158                // class java/lang/Number
     412: invokevirtual #161                // Method java/lang/Number.intValue:()I
     415: iload         9
     417: if_icmpge     424
     420: iconst_1
     421: goto          425
     424: iconst_0
     425: ifeq          375
     428: aload         17
     430: aload         20
     432: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     437: pop
     438: goto          375
     441: aload         17
     443: checkcast     #72                 // class java/util/List
     446: nop
     447: checkcast     #83                 // class java/util/Collection
     450: invokestatic  #180                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     453: astore        11
     455: aload_1
     456: checkcast     #27                 // class java/lang/Iterable
     459: astore        15
     461: iconst_0
     462: istore        16
     464: aload         15
     466: astore        17
     468: new           #29                 // class java/util/ArrayList
     471: dup
     472: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     475: checkcast     #83                 // class java/util/Collection
     478: astore        18
     480: iconst_0
     481: istore        19
     483: aload         17
     485: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     490: astore        20
     492: aload         20
     494: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     499: ifeq          558
     502: aload         20
     504: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     509: astore        21
     511: aload         21
     513: checkcast     #153                // class kotlin/Pair
     516: astore        22
     518: iconst_0
     519: istore        23
     521: aload         22
     523: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     526: checkcast     #158                // class java/lang/Number
     529: invokevirtual #161                // Method java/lang/Number.intValue:()I
     532: iload         9
     534: if_icmple     541
     537: iconst_1
     538: goto          542
     541: iconst_0
     542: ifeq          492
     545: aload         18
     547: aload         21
     549: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     554: pop
     555: goto          492
     558: aload         18
     560: checkcast     #72                 // class java/util/List
     563: nop
     564: invokeinterface #181,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     569: astore        13
     571: aload         13
     573: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     578: ifeq          629
     581: aload         13
     583: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     588: checkcast     #153                // class kotlin/Pair
     591: astore        15
     593: aload         11
     595: aload         15
     597: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     600: iload         14
     602: aload         15
     604: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     607: checkcast     #158                // class java/lang/Number
     610: invokevirtual #161                // Method java/lang/Number.intValue:()I
     613: isub
     614: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     617: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     620: invokeinterface #182,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     625: pop
     626: goto          571
     629: aload         11
     631: goto          927
     634: aload_1
     635: checkcast     #27                 // class java/lang/Iterable
     638: astore        13
     640: iconst_0
     641: istore        15
     643: aload         13
     645: astore        16
     647: new           #29                 // class java/util/ArrayList
     650: dup
     651: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     654: checkcast     #83                 // class java/util/Collection
     657: astore        17
     659: iconst_0
     660: istore        18
     662: aload         16
     664: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     669: astore        19
     671: aload         19
     673: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     678: ifeq          737
     681: aload         19
     683: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     688: astore        20
     690: aload         20
     692: checkcast     #153                // class kotlin/Pair
     695: astore        21
     697: iconst_0
     698: istore        22
     700: aload         21
     702: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     705: checkcast     #158                // class java/lang/Number
     708: invokevirtual #161                // Method java/lang/Number.intValue:()I
     711: iload         9
     713: if_icmpge     720
     716: iconst_1
     717: goto          721
     720: iconst_0
     721: ifeq          671
     724: aload         17
     726: aload         20
     728: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     733: pop
     734: goto          671
     737: aload         17
     739: checkcast     #72                 // class java/util/List
     742: nop
     743: checkcast     #83                 // class java/util/Collection
     746: invokestatic  #180                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     749: astore        11
     751: aload_1
     752: checkcast     #27                 // class java/lang/Iterable
     755: astore        15
     757: iconst_0
     758: istore        16
     760: aload         15
     762: astore        17
     764: new           #29                 // class java/util/ArrayList
     767: dup
     768: invokespecial #30                 // Method java/util/ArrayList."<init>":()V
     771: checkcast     #83                 // class java/util/Collection
     774: astore        18
     776: iconst_0
     777: istore        19
     779: aload         17
     781: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     786: astore        20
     788: aload         20
     790: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     795: ifeq          854
     798: aload         20
     800: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     805: astore        21
     807: aload         21
     809: checkcast     #153                // class kotlin/Pair
     812: astore        22
     814: iconst_0
     815: istore        23
     817: aload         22
     819: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     822: checkcast     #158                // class java/lang/Number
     825: invokevirtual #161                // Method java/lang/Number.intValue:()I
     828: iload         9
     830: if_icmple     837
     833: iconst_1
     834: goto          838
     837: iconst_0
     838: ifeq          788
     841: aload         18
     843: aload         21
     845: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     850: pop
     851: goto          788
     854: aload         18
     856: checkcast     #72                 // class java/util/List
     859: nop
     860: invokeinterface #181,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     865: astore        13
     867: aload         13
     869: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     874: ifeq          925
     877: aload         13
     879: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     884: checkcast     #153                // class kotlin/Pair
     887: astore        15
     889: aload         11
     891: iload         12
     893: aload         15
     895: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     898: checkcast     #158                // class java/lang/Number
     901: invokevirtual #161                // Method java/lang/Number.intValue:()I
     904: isub
     905: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     908: aload         15
     910: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     913: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     916: invokeinterface #182,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     921: pop
     922: goto          867
     925: aload         11
     927: astore        10
     929: aload         10
     931: astore_1
     932: nop
     933: nop
     934: goto          25
     937: nop
     938: aload_1
     939: checkcast     #27                 // class java/lang/Iterable
     942: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     947: astore        4
     949: aload         4
     951: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     956: ifne          967
     959: new           #150                // class java/util/NoSuchElementException
     962: dup
     963: invokespecial #151                // Method java/util/NoSuchElementException."<init>":()V
     966: athrow
     967: aload         4
     969: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     974: checkcast     #153                // class kotlin/Pair
     977: astore        5
     979: iconst_0
     980: istore        6
     982: aload         5
     984: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     987: checkcast     #158                // class java/lang/Number
     990: invokevirtual #161                // Method java/lang/Number.intValue:()I
     993: istore        5
     995: aload         4
     997: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1002: ifeq          1047
    1005: aload         4
    1007: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1012: checkcast     #153                // class kotlin/Pair
    1015: astore        6
    1017: iconst_0
    1018: istore        7
    1020: aload         6
    1022: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1025: checkcast     #158                // class java/lang/Number
    1028: invokevirtual #161                // Method java/lang/Number.intValue:()I
    1031: istore        6
    1033: iload         5
    1035: iload         6
    1037: if_icmpge     995
    1040: iload         6
    1042: istore        5
    1044: goto          995
    1047: iload         5
    1049: istore_2
    1050: aload_1
    1051: checkcast     #27                 // class java/lang/Iterable
    1054: invokeinterface #34,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1059: astore        5
    1061: aload         5
    1063: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1068: ifne          1079
    1071: new           #150                // class java/util/NoSuchElementException
    1074: dup
    1075: invokespecial #151                // Method java/util/NoSuchElementException."<init>":()V
    1078: athrow
    1079: aload         5
    1081: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1086: checkcast     #153                // class kotlin/Pair
    1089: astore        6
    1091: iconst_0
    1092: istore        7
    1094: aload         6
    1096: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1099: checkcast     #158                // class java/lang/Number
    1102: invokevirtual #161                // Method java/lang/Number.intValue:()I
    1105: istore        6
    1107: aload         5
    1109: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1114: ifeq          1159
    1117: aload         5
    1119: invokeinterface #44,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1124: checkcast     #153                // class kotlin/Pair
    1127: astore        7
    1129: iconst_0
    1130: istore        8
    1132: aload         7
    1134: invokevirtual #164                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1137: checkcast     #158                // class java/lang/Number
    1140: invokevirtual #161                // Method java/lang/Number.intValue:()I
    1143: istore        7
    1145: iload         6
    1147: iload         7
    1149: if_icmpge     1107
    1152: iload         7
    1154: istore        6
    1156: goto          1107
    1159: iload         6
    1161: istore_3
    1162: ldc           #236                // String Puzzle 2:
    1164: getstatic     #205                // Field java/lang/System.out:Ljava/io/PrintStream;
    1167: swap
    1168: invokevirtual #211                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1171: iconst_0
    1172: istore        4
    1174: iload         4
    1176: iload_3
    1177: if_icmpgt     1255
    1180: iconst_0
    1181: istore        5
    1183: iload         5
    1185: iload_2
    1186: if_icmpgt     1237
    1189: aload_1
    1190: iload         5
    1192: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1195: iload         4
    1197: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1200: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1203: invokeinterface #239,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
    1208: ifeq          1216
    1211: ldc           #241                // String #
    1213: goto          1218
    1216: ldc           #243                // String
    1218: getstatic     #205                // Field java/lang/System.out:Ljava/io/PrintStream;
    1221: swap
    1222: invokevirtual #246                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
    1225: iload         5
    1227: iload_2
    1228: if_icmpeq     1237
    1231: iinc          5, 1
    1234: goto          1189
    1237: getstatic     #205                // Field java/lang/System.out:Ljava/io/PrintStream;
    1240: invokevirtual #248                // Method java/io/PrintStream.println:()V
    1243: iload         4
    1245: iload_3
    1246: if_icmpeq     1255
    1249: iinc          4, 1
    1252: goto          1180
    1255: return
}

Compiled from "day13.kt"
public final class Day13Kt {
  public static final void print_day_13();
    Code:
       0: ldc           #8                  // String \u001b[33m
       2: astore_0
       3: ldc           #10                 // String \u001b[0m
       5: astore_1
       6: ldc           #12                 // String \u001b[32m
       8: astore_2
       9: new           #14                 // class java/lang/StringBuilder
      12: dup
      13: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      16: aload_0
      17: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      20: ldc           #23                 // String -
      22: checkcast     #25                 // class java/lang/CharSequence
      25: bipush        25
      27: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      30: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      33: ldc           #33                 // String Advent of Code - Day 13
      35: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: ldc           #23                 // String -
      40: checkcast     #25                 // class java/lang/CharSequence
      43: bipush        25
      45: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      48: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      51: aload_1
      52: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      55: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      58: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      61: swap
      62: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      65: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      68: aload_2
      69: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      72: invokestatic  #55                 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;
      75: ldc           #57                 // String figlet Transparent Origami -c -f small
      77: invokevirtual #61                 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;
      80: astore_3
      81: new           #63                 // class java/io/BufferedReader
      84: dup
      85: new           #65                 // class java/io/InputStreamReader
      88: dup
      89: aload_3
      90: invokevirtual #71                 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;
      93: invokespecial #74                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;)V
      96: checkcast     #76                 // class java/io/Reader
      99: invokespecial #79                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;)V
     102: astore        4
     104: aload         4
     106: checkcast     #76                 // class java/io/Reader
     109: invokedynamic #98,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     114: invokestatic  #104                // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V
     117: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     120: aload_1
     121: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     124: new           #14                 // class java/lang/StringBuilder
     127: dup
     128: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
     131: aload_0
     132: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     135: ldc           #23                 // String -
     137: checkcast     #25                 // class java/lang/CharSequence
     140: bipush        33
     142: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
     145: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     148: ldc           #106                // String Output
     150: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     153: ldc           #23                 // String -
     155: checkcast     #25                 // class java/lang/CharSequence
     158: bipush        33
     160: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
     163: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     166: aload_1
     167: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     170: bipush        10
     172: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     175: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     178: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     181: swap
     182: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     185: return

  public static final void main();
    Code:
       0: invokestatic  #120                // Method print_day_13:()V
       3: new           #122                // class Day13
       6: dup
       7: invokespecial #123                // Method Day13."<init>":()V
      10: invokevirtual #126                // Method Day13.part_1:()V
      13: new           #122                // class Day13
      16: dup
      17: invokespecial #123                // Method Day13."<init>":()V
      20: invokevirtual #129                // Method Day13.part_2:()V
      23: new           #14                 // class java/lang/StringBuilder
      26: dup
      27: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      30: ldc           #131                // String \n\u001b[33m
      32: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      35: ldc           #133                // String =
      37: checkcast     #25                 // class java/lang/CharSequence
      40: bipush        72
      42: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      45: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: ldc           #135                // String \u001b[0m\n
      50: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      53: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      56: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      59: swap
      60: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      63: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #138                // Method main:()V
       3: return

  private static final kotlin.Unit print_day_13$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #142                // String it
       3: invokestatic  #148                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
       9: aload_0
      10: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      13: getstatic     #154                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      16: areturn
}


import java.io.*
import kotlin.math.abs

fun print_day_5() {

    val yellow = "\u001B[33m"
    val reset = "\u001b[0m"
    val green = "\u001B[32m"
    println(yellow + "-".repeat(25) + "Advent of Code - Day 5" + "-".repeat(25) + reset)
    println(green)
    val process = Runtime.getRuntime().exec("figlet Hydrothermal Venture -c -f small")
    val reader = BufferedReader(InputStreamReader(process.inputStream))
    reader.forEachLine { println(it) }
    println(reset)

    println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}

fun main() {
    print_day_5()
    Day5().puzzle1()
    Day5().puzzle2()
    println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}

class Day5 {
    data class Point(val x:Int, val y: Int)

    private val lines = File("../Input/day5.txt").readLines()
    private val points = lines.map { line ->
        line.split(" -> ").map { point ->
            val pairs = point.split(",")
            Point(pairs[0].toInt(), pairs[1].toInt())
        }
    }

    fun puzzle1() {

        val map2d = Array(1000) { Array(1000) { 0 } }

        points.forEach() {
            if (it[0].x == it[1].x) {
                val min = Math.min(it[0].y, it[1].y)
                val max = Math.max(it[0].y, it[1].y)

                for(i in min..max) {
                    map2d[i][it[0].x]++
                }
            }
            else if (it[0].y == it[1].y) {
                val min = Math.min(it[0].x, it[1].x)
                val max = Math.max(it[0].x, it[1].x)

                for(i in min..max) {
                    map2d[it[0].y][i]++
                }
            }
        }

        val overlaps = map2d.sumOf { it.count { point -> point >= 2 } }

        println("Puzzle 1: " + overlaps)

    }

    fun puzzle2() {

        val map2d = Array(1000) { Array(1000) { 0 } }
        points.forEach() {
            if (it[0].x == it[1].x) {
                val min = Math.min(it[0].y, it[1].y)
                val max = Math.max(it[0].y, it[1].y)

                for(i in min..max) {
                    map2d[i][it[0].x]++
                }
            }
            else if (it[0].y == it[1].y) {
                val min = Math.min(it[0].x, it[1].x)
                val max = Math.max(it[0].x, it[1].x)

                for(i in min..max) {
                    map2d[it[0].y][i]++
                }
            }
            else if ( isDiagonal(it[0], it[1]) ) {
                val len = abs(it[0].x - it[1].x)
                val xStep = if (it[1].x - it[0].x > 0) 1 else -1
                val yStep = if (it[1].y - it[0].y > 0) 1 else -1

                for(i in 0..len) {
                    val y = it[0].y + (i*yStep)
                    val x = it[0].x + (i*xStep)
                    map2d[y][x]++
                }
            }
        }

        val overlaps = map2d.sumOf { it.count { point -> point >= 2 } }
        println("Puzzle 2: " + overlaps)
    }
    private fun isDiagonal(p1: Point, p2: Point): Boolean = abs(p1.x - p2.x) == abs(p1.y - p2.y)
}

Compiled from "day05.kt"
public final class Day05Kt {
  public static final void print_day_5();
    Code:
       0: ldc           #8                  // String \u001b[33m
       2: astore_0
       3: ldc           #10                 // String \u001b[0m
       5: astore_1
       6: ldc           #12                 // String \u001b[32m
       8: astore_2
       9: new           #14                 // class java/lang/StringBuilder
      12: dup
      13: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      16: aload_0
      17: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      20: ldc           #23                 // String -
      22: checkcast     #25                 // class java/lang/CharSequence
      25: bipush        25
      27: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      30: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      33: ldc           #33                 // String Advent of Code - Day 5
      35: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: ldc           #23                 // String -
      40: checkcast     #25                 // class java/lang/CharSequence
      43: bipush        25
      45: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      48: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      51: aload_1
      52: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      55: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      58: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      61: swap
      62: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      65: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      68: aload_2
      69: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      72: invokestatic  #55                 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;
      75: ldc           #57                 // String figlet Hydrothermal Venture -c -f small
      77: invokevirtual #61                 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;
      80: astore_3
      81: new           #63                 // class java/io/BufferedReader
      84: dup
      85: new           #65                 // class java/io/InputStreamReader
      88: dup
      89: aload_3
      90: invokevirtual #71                 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;
      93: invokespecial #74                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;)V
      96: checkcast     #76                 // class java/io/Reader
      99: invokespecial #79                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;)V
     102: astore        4
     104: aload         4
     106: checkcast     #76                 // class java/io/Reader
     109: invokedynamic #98,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     114: invokestatic  #104                // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V
     117: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     120: aload_1
     121: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     124: new           #14                 // class java/lang/StringBuilder
     127: dup
     128: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
     131: aload_0
     132: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     135: ldc           #23                 // String -
     137: checkcast     #25                 // class java/lang/CharSequence
     140: bipush        33
     142: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
     145: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     148: ldc           #106                // String Output
     150: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     153: ldc           #23                 // String -
     155: checkcast     #25                 // class java/lang/CharSequence
     158: bipush        33
     160: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
     163: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     166: aload_1
     167: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     170: bipush        10
     172: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     175: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     178: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     181: swap
     182: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     185: return

  public static final void main();
    Code:
       0: invokestatic  #120                // Method print_day_5:()V
       3: new           #122                // class Day5
       6: dup
       7: invokespecial #123                // Method Day5."<init>":()V
      10: invokevirtual #126                // Method Day5.puzzle1:()V
      13: new           #122                // class Day5
      16: dup
      17: invokespecial #123                // Method Day5."<init>":()V
      20: invokevirtual #129                // Method Day5.puzzle2:()V
      23: new           #14                 // class java/lang/StringBuilder
      26: dup
      27: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      30: ldc           #131                // String \n\u001b[33m
      32: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      35: ldc           #133                // String =
      37: checkcast     #25                 // class java/lang/CharSequence
      40: bipush        72
      42: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      45: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: ldc           #135                // String \u001b[0m\n
      50: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      53: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      56: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      59: swap
      60: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      63: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #138                // Method main:()V
       3: return

  private static final kotlin.Unit print_day_5$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #142                // String it
       3: invokestatic  #148                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
       9: aload_0
      10: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      13: getstatic     #154                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      16: areturn
}