import java.io.*
fun print_day_14() {
    val yellow = "\u001B[33m"
    val reset = "\u001b[0m"
    val green = "\u001B[32m"
    println(yellow + "-".repeat(25) + "Advent of Code - Day 14" + "-".repeat(25) + reset)
    println(green)
    val process = Runtime.getRuntime().exec("figlet Extended Polymerization -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_14()
    Day14().part_1()
    Day14().part_2()
    println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}

class Day14 {
    val lines = File("../Input/day14.txt").readLines()
    val polyTemplate = lines.first()

    fun part_1() {
        val pairInsertions = lines.drop(2).map {
            val (pair, insertion) = it.split(" -> ")
            pair to insertion
        }

        var polyIteration = polyTemplate
        for (step in 1..10) {
            polyIteration = polyIteration.fold("") { str, curr ->
                val pairCheck = "" + (str.lastOrNull() ?: "") + curr
                val insert = pairInsertions.find { it.first == pairCheck } ?.second ?: ""

                str + insert + curr
            }
        }

        val elementCounts = polyIteration.groupBy { it }.map { it.key to it.value.size }.sortedBy { it.second }
        val ans = elementCounts.last().second - elementCounts.first().second
        println("Puzzle 1: $ans")
    }

    fun part_2() {
        val insertPattern = lines.drop(2).map { it.split(" -> ") }.associate { it[0] to it[1] }
        var pairFrequency = mutableMapOf<String, Long>()
        polyTemplate.windowed(2).forEach{ pairFrequency.put(it, pairFrequency.getOrDefault(it, 0) + 1) }
        for (step in 1..40) {
            val updatedFrequencies = mutableMapOf<String, Long>()
            pairFrequency.forEach {
                val key1 = it.key[0] + insertPattern[it.key]!!
                val key2 = insertPattern[it.key]!! + it.key[1]
                updatedFrequencies.put(key1, updatedFrequencies.getOrDefault(key1, 0) + it.value)
                updatedFrequencies.put(key2, updatedFrequencies.getOrDefault(key2, 0) + it.value)
            }
            pairFrequency = updatedFrequencies
        }
        val charFrequency = pairFrequency.toList().fold(mutableMapOf<Char, Long>()) { acc, pair ->
            acc.put(pair.first[0], acc.getOrDefault(pair.first[0], 0) + pair.second)
            acc
        }
        charFrequency.put(polyTemplate.last(), charFrequency.getOrDefault(polyTemplate.last(), 0) + 1)
        val sorted = charFrequency.values.sorted()
        val ans = sorted.last() - sorted.first()
        println("Puzzle 2: $ans")
    }
}

Compiled from "day14.kt"
public final class Day14Kt {
  public static final void print_day_14();
    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 14
      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 Extended Polymerization -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_14:()V
       3: new           #122                // class Day14
       6: dup
       7: invokespecial #123                // Method Day14."<init>":()V
      10: invokevirtual #126                // Method Day14.part_1:()V
      13: new           #122                // class Day14
      16: dup
      17: invokespecial #123                // Method Day14."<init>":()V
      20: invokevirtual #129                // Method Day14.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_14$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
}

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

  private final java.lang.String polyTemplate;

  public Day14();
    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/day14.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: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      31: checkcast     #33                 // class java/lang/String
      34: putfield      #37                 // Field polyTemplate:Ljava/lang/String;
      37: return

  public final java.util.List<java.lang.String> getLines();
    Code:
       0: aload_0
       1: getfield      #25                 // Field lines:Ljava/util/List;
       4: areturn

  public final java.lang.String getPolyTemplate();
    Code:
       0: aload_0
       1: getfield      #37                 // Field polyTemplate:Ljava/lang/String;
       4: areturn

  public final void part_1();
    Code:
       0: aload_0
       1: getfield      #25                 // Field lines:Ljava/util/List;
       4: checkcast     #48                 // class java/lang/Iterable
       7: iconst_2
       8: invokestatic  #52                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      11: checkcast     #48                 // class java/lang/Iterable
      14: astore_2
      15: iconst_0
      16: istore_3
      17: aload_2
      18: astore        4
      20: new           #54                 // class java/util/ArrayList
      23: dup
      24: aload_2
      25: bipush        10
      27: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      30: invokespecial #61                 // Method java/util/ArrayList."<init>":(I)V
      33: checkcast     #63                 // class java/util/Collection
      36: astore        5
      38: iconst_0
      39: istore        6
      41: aload         4
      43: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        7
      50: aload         7
      52: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          157
      60: aload         7
      62: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        8
      69: aload         5
      71: aload         8
      73: checkcast     #33                 // class java/lang/String
      76: astore        9
      78: astore        20
      80: iconst_0
      81: istore        10
      83: aload         9
      85: checkcast     #79                 // class java/lang/CharSequence
      88: iconst_1
      89: anewarray     #33                 // class java/lang/String
      92: astore        11
      94: aload         11
      96: iconst_0
      97: ldc           #81                 // String  ->
      99: aastore
     100: aload         11
     102: iconst_0
     103: iconst_0
     104: bipush        6
     106: aconst_null
     107: invokestatic  #87                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     110: astore        12
     112: aload         12
     114: iconst_0
     115: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     120: checkcast     #33                 // class java/lang/String
     123: astore        11
     125: aload         12
     127: iconst_1
     128: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     133: checkcast     #33                 // class java/lang/String
     136: astore        13
     138: aload         11
     140: aload         13
     142: invokestatic  #99                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     145: aload         20
     147: swap
     148: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     153: pop
     154: goto          50
     157: aload         5
     159: checkcast     #89                 // class java/util/List
     162: nop
     163: astore_1
     164: aload_0
     165: getfield      #37                 // Field polyTemplate:Ljava/lang/String;
     168: astore_2
     169: iconst_1
     170: istore_3
     171: iload_3
     172: bipush        11
     174: if_icmpge     398
     177: aload_2
     178: checkcast     #79                 // class java/lang/CharSequence
     181: astore        4
     183: ldc           #105                // String
     185: astore        5
     187: iconst_0
     188: istore        6
     190: aload         5
     192: astore        7
     194: iconst_0
     195: istore        8
     197: iload         8
     199: aload         4
     201: invokeinterface #109,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     206: if_icmpge     389
     209: aload         4
     211: iload         8
     213: invokeinterface #113,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     218: istore        9
     220: aload         7
     222: iload         9
     224: istore        10
     226: astore        11
     228: iconst_0
     229: istore        12
     231: new           #115                // class java/lang/StringBuilder
     234: dup
     235: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     238: ldc           #105                // String
     240: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     243: aload         11
     245: checkcast     #79                 // class java/lang/CharSequence
     248: invokestatic  #124                // Method kotlin/text/StringsKt.lastOrNull:(Ljava/lang/CharSequence;)Ljava/lang/Character;
     251: dup
     252: ifnonnull     258
     255: pop
     256: ldc           #105                // String
     258: invokevirtual #127                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     261: iload         10
     263: invokevirtual #130                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     266: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     269: astore        13
     271: aload_1
     272: checkcast     #48                 // class java/lang/Iterable
     275: astore        14
     277: aload         14
     279: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     284: astore        15
     286: aload         15
     288: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     293: ifeq          333
     296: aload         15
     298: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     303: astore        16
     305: aload         16
     307: checkcast     #135                // class kotlin/Pair
     310: astore        17
     312: iconst_0
     313: istore        18
     315: aload         17
     317: invokevirtual #138                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     320: aload         13
     322: invokestatic  #144                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     325: ifeq          286
     328: aload         16
     330: goto          334
     333: aconst_null
     334: checkcast     #135                // class kotlin/Pair
     337: dup
     338: ifnull        351
     341: invokevirtual #147                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     344: checkcast     #33                 // class java/lang/String
     347: dup
     348: ifnonnull     354
     351: pop
     352: ldc           #105                // String
     354: astore        19
     356: new           #115                // class java/lang/StringBuilder
     359: dup
     360: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     363: aload         11
     365: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     368: aload         19
     370: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     373: iload         10
     375: invokevirtual #130                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     378: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     381: astore        7
     383: iinc          8, 1
     386: goto          197
     389: aload         7
     391: astore_2
     392: iinc          3, 1
     395: goto          171
     398: aload_2
     399: checkcast     #79                 // class java/lang/CharSequence
     402: astore        4
     404: iconst_0
     405: istore        5
     407: aload         4
     409: astore        6
     411: new           #149                // class java/util/LinkedHashMap
     414: dup
     415: invokespecial #150                // Method java/util/LinkedHashMap."<init>":()V
     418: checkcast     #152                // class java/util/Map
     421: astore        7
     423: iconst_0
     424: istore        8
     426: iconst_0
     427: istore        9
     429: iload         9
     431: aload         6
     433: invokeinterface #109,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     438: if_icmpge     548
     441: aload         6
     443: iload         9
     445: invokeinterface #113,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     450: istore        10
     452: iload         10
     454: istore        11
     456: iconst_0
     457: istore        12
     459: iload         11
     461: invokestatic  #158                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     464: astore        13
     466: aload         7
     468: astore        14
     470: iconst_0
     471: istore        15
     473: aload         14
     475: aload         13
     477: invokeinterface #161,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     482: astore        16
     484: aload         16
     486: ifnonnull     521
     489: iconst_0
     490: istore        17
     492: new           #54                 // class java/util/ArrayList
     495: dup
     496: invokespecial #162                // Method java/util/ArrayList."<init>":()V
     499: checkcast     #89                 // class java/util/List
     502: astore        17
     504: aload         14
     506: aload         13
     508: aload         17
     510: invokeinterface #166,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     515: pop
     516: aload         17
     518: goto          523
     521: aload         16
     523: nop
     524: checkcast     #89                 // class java/util/List
     527: astore        11
     529: aload         11
     531: iload         10
     533: invokestatic  #158                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     536: invokeinterface #167,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     541: pop
     542: iinc          9, 1
     545: goto          429
     548: aload         7
     550: nop
     551: astore        4
     553: nop
     554: iconst_0
     555: istore        5
     557: aload         4
     559: astore        6
     561: new           #54                 // class java/util/ArrayList
     564: dup
     565: aload         4
     567: invokeinterface #170,  1          // InterfaceMethod java/util/Map.size:()I
     572: invokespecial #61                 // Method java/util/ArrayList."<init>":(I)V
     575: checkcast     #63                 // class java/util/Collection
     578: astore        7
     580: iconst_0
     581: istore        8
     583: aload         6
     585: invokeinterface #174,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     590: invokeinterface #177,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     595: astore        9
     597: aload         9
     599: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     604: ifeq          670
     607: aload         9
     609: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     614: checkcast     #179                // class java/util/Map$Entry
     617: astore        10
     619: aload         7
     621: aload         10
     623: astore        11
     625: astore        20
     627: iconst_0
     628: istore        12
     630: aload         11
     632: invokeinterface #182,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     637: aload         11
     639: invokeinterface #185,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     644: checkcast     #89                 // class java/util/List
     647: invokeinterface #186,  1          // InterfaceMethod java/util/List.size:()I
     652: invokestatic  #191                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     655: invokestatic  #99                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     658: aload         20
     660: swap
     661: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     666: pop
     667: goto          597
     670: aload         7
     672: checkcast     #89                 // class java/util/List
     675: nop
     676: checkcast     #48                 // class java/lang/Iterable
     679: astore        4
     681: nop
     682: iconst_0
     683: istore        5
     685: aload         4
     687: new           #193                // class Day14$part_1$$inlined$sortedBy$1
     690: dup
     691: invokespecial #194                // Method Day14$part_1$$inlined$sortedBy$1."<init>":()V
     694: checkcast     #196                // class java/util/Comparator
     697: invokestatic  #200                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     700: astore_3
     701: aload_3
     702: invokestatic  #203                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     705: checkcast     #135                // class kotlin/Pair
     708: invokevirtual #147                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     711: checkcast     #205                // class java/lang/Number
     714: invokevirtual #208                // Method java/lang/Number.intValue:()I
     717: aload_3
     718: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     721: checkcast     #135                // class kotlin/Pair
     724: invokevirtual #147                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     727: checkcast     #205                // class java/lang/Number
     730: invokevirtual #208                // Method java/lang/Number.intValue:()I
     733: isub
     734: istore        4
     736: new           #115                // class java/lang/StringBuilder
     739: dup
     740: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     743: ldc           #210                // String Puzzle 1:
     745: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     748: iload         4
     750: invokevirtual #213                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     753: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     756: getstatic     #219                // Field java/lang/System.out:Ljava/io/PrintStream;
     759: swap
     760: invokevirtual #225                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     763: return

  public final void part_2();
    Code:
       0: aload_0
       1: getfield      #25                 // Field lines:Ljava/util/List;
       4: checkcast     #48                 // class java/lang/Iterable
       7: iconst_2
       8: invokestatic  #52                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      11: checkcast     #48                 // class java/lang/Iterable
      14: astore_2
      15: iconst_0
      16: istore_3
      17: aload_2
      18: astore        4
      20: new           #54                 // class java/util/ArrayList
      23: dup
      24: aload_2
      25: bipush        10
      27: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      30: invokespecial #61                 // Method java/util/ArrayList."<init>":(I)V
      33: checkcast     #63                 // class java/util/Collection
      36: astore        5
      38: iconst_0
      39: istore        6
      41: aload         4
      43: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        7
      50: aload         7
      52: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          122
      60: aload         7
      62: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        8
      69: aload         5
      71: aload         8
      73: checkcast     #33                 // class java/lang/String
      76: astore        9
      78: astore        14
      80: iconst_0
      81: istore        10
      83: aload         9
      85: checkcast     #79                 // class java/lang/CharSequence
      88: iconst_1
      89: anewarray     #33                 // class java/lang/String
      92: astore        11
      94: aload         11
      96: iconst_0
      97: ldc           #81                 // String  ->
      99: aastore
     100: aload         11
     102: iconst_0
     103: iconst_0
     104: bipush        6
     106: aconst_null
     107: invokestatic  #87                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     110: aload         14
     112: swap
     113: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     118: pop
     119: goto          50
     122: aload         5
     124: checkcast     #89                 // class java/util/List
     127: nop
     128: checkcast     #48                 // class java/lang/Iterable
     131: astore_2
     132: nop
     133: iconst_0
     134: istore_3
     135: aload_2
     136: bipush        10
     138: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     141: invokestatic  #283                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     144: bipush        16
     146: invokestatic  #289                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     149: istore        4
     151: aload_2
     152: astore        5
     154: new           #149                // class java/util/LinkedHashMap
     157: dup
     158: iload         4
     160: invokespecial #290                // Method java/util/LinkedHashMap."<init>":(I)V
     163: checkcast     #152                // class java/util/Map
     166: astore        6
     168: iconst_0
     169: istore        7
     171: aload         5
     173: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     178: astore        8
     180: aload         8
     182: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     187: ifeq          255
     190: aload         8
     192: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     197: astore        9
     199: aload         6
     201: astore        10
     203: aload         9
     205: checkcast     #89                 // class java/util/List
     208: astore        11
     210: iconst_0
     211: istore        12
     213: aload         11
     215: iconst_0
     216: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     221: aload         11
     223: iconst_1
     224: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     229: invokestatic  #99                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     232: astore        11
     234: aload         10
     236: aload         11
     238: invokevirtual #138                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     241: aload         11
     243: invokevirtual #147                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     246: invokeinterface #166,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     251: pop
     252: goto          180
     255: aload         6
     257: nop
     258: astore_1
     259: aconst_null
     260: astore_2
     261: new           #149                // class java/util/LinkedHashMap
     264: dup
     265: invokespecial #150                // Method java/util/LinkedHashMap."<init>":()V
     268: checkcast     #152                // class java/util/Map
     271: astore_2
     272: aload_0
     273: getfield      #37                 // Field polyTemplate:Ljava/lang/String;
     276: checkcast     #79                 // class java/lang/CharSequence
     279: iconst_2
     280: iconst_0
     281: iconst_0
     282: bipush        6
     284: aconst_null
     285: invokestatic  #294                // Method kotlin/text/StringsKt.windowed$default:(Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;
     288: checkcast     #48                 // class java/lang/Iterable
     291: astore_3
     292: iconst_0
     293: istore        4
     295: aload_3
     296: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     301: astore        5
     303: aload         5
     305: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     310: ifeq          368
     313: aload         5
     315: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     320: astore        6
     322: aload         6
     324: checkcast     #33                 // class java/lang/String
     327: astore        7
     329: iconst_0
     330: istore        8
     332: aload_2
     333: aload         7
     335: aload_2
     336: aload         7
     338: lconst_0
     339: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     342: invokeinterface #302,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     347: checkcast     #205                // class java/lang/Number
     350: invokevirtual #306                // Method java/lang/Number.longValue:()J
     353: lconst_1
     354: ladd
     355: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     358: invokeinterface #166,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     363: pop
     364: nop
     365: goto          303
     368: nop
     369: iconst_1
     370: istore_3
     371: iload_3
     372: bipush        41
     374: if_icmpge     657
     377: new           #149                // class java/util/LinkedHashMap
     380: dup
     381: invokespecial #150                // Method java/util/LinkedHashMap."<init>":()V
     384: checkcast     #152                // class java/util/Map
     387: astore        4
     389: aload_2
     390: astore        5
     392: iconst_0
     393: istore        6
     395: aload         5
     397: invokeinterface #174,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     402: invokeinterface #177,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     407: astore        7
     409: aload         7
     411: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     416: ifeq          647
     419: aload         7
     421: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     426: checkcast     #179                // class java/util/Map$Entry
     429: astore        8
     431: aload         8
     433: astore        9
     435: iconst_0
     436: istore        10
     438: aload         9
     440: invokeinterface #182,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     445: checkcast     #33                 // class java/lang/String
     448: iconst_0
     449: invokevirtual #307                // Method java/lang/String.charAt:(I)C
     452: istore        11
     454: aload_1
     455: aload         9
     457: invokeinterface #182,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     462: invokeinterface #161,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     467: dup
     468: invokestatic  #310                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     471: checkcast     #33                 // class java/lang/String
     474: astore        12
     476: new           #115                // class java/lang/StringBuilder
     479: dup
     480: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     483: iload         11
     485: invokevirtual #130                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     488: aload         12
     490: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     493: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     496: astore        13
     498: new           #115                // class java/lang/StringBuilder
     501: dup
     502: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     505: aload_1
     506: aload         9
     508: invokeinterface #182,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     513: invokeinterface #161,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     518: dup
     519: invokestatic  #310                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     522: checkcast     #33                 // class java/lang/String
     525: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     528: aload         9
     530: invokeinterface #182,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     535: checkcast     #33                 // class java/lang/String
     538: iconst_1
     539: invokevirtual #307                // Method java/lang/String.charAt:(I)C
     542: invokevirtual #130                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     545: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     548: astore        11
     550: aload         4
     552: aload         13
     554: aload         4
     556: aload         13
     558: lconst_0
     559: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     562: invokeinterface #302,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     567: checkcast     #205                // class java/lang/Number
     570: invokevirtual #306                // Method java/lang/Number.longValue:()J
     573: aload         9
     575: invokeinterface #185,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     580: checkcast     #205                // class java/lang/Number
     583: invokevirtual #306                // Method java/lang/Number.longValue:()J
     586: ladd
     587: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     590: invokeinterface #166,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     595: pop
     596: aload         4
     598: aload         11
     600: aload         4
     602: aload         11
     604: lconst_0
     605: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     608: invokeinterface #302,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     613: checkcast     #205                // class java/lang/Number
     616: invokevirtual #306                // Method java/lang/Number.longValue:()J
     619: aload         9
     621: invokeinterface #185,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     626: checkcast     #205                // class java/lang/Number
     629: invokevirtual #306                // Method java/lang/Number.longValue:()J
     632: ladd
     633: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     636: invokeinterface #166,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     641: pop
     642: nop
     643: nop
     644: goto          409
     647: nop
     648: aload         4
     650: astore_2
     651: iinc          3, 1
     654: goto          371
     657: aload_2
     658: invokestatic  #314                // Method kotlin/collections/MapsKt.toList:(Ljava/util/Map;)Ljava/util/List;
     661: checkcast     #48                 // class java/lang/Iterable
     664: astore        4
     666: new           #149                // class java/util/LinkedHashMap
     669: dup
     670: invokespecial #150                // Method java/util/LinkedHashMap."<init>":()V
     673: checkcast     #152                // class java/util/Map
     676: astore        5
     678: nop
     679: iconst_0
     680: istore        6
     682: aload         5
     684: astore        7
     686: aload         4
     688: invokeinterface #67,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     693: astore        8
     695: aload         8
     697: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     702: ifeq          805
     705: aload         8
     707: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     712: astore        9
     714: aload         7
     716: aload         9
     718: checkcast     #135                // class kotlin/Pair
     721: astore        10
     723: astore        11
     725: iconst_0
     726: istore        12
     728: aload         11
     730: aload         10
     732: invokevirtual #138                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     735: checkcast     #33                 // class java/lang/String
     738: iconst_0
     739: invokevirtual #307                // Method java/lang/String.charAt:(I)C
     742: invokestatic  #158                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     745: aload         11
     747: aload         10
     749: invokevirtual #138                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     752: checkcast     #33                 // class java/lang/String
     755: iconst_0
     756: invokevirtual #307                // Method java/lang/String.charAt:(I)C
     759: invokestatic  #158                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     762: lconst_0
     763: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     766: invokeinterface #302,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     771: checkcast     #205                // class java/lang/Number
     774: invokevirtual #306                // Method java/lang/Number.longValue:()J
     777: aload         10
     779: invokevirtual #147                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     782: checkcast     #205                // class java/lang/Number
     785: invokevirtual #306                // Method java/lang/Number.longValue:()J
     788: ladd
     789: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     792: invokeinterface #166,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     797: pop
     798: aload         11
     800: astore        7
     802: goto          695
     805: aload         7
     807: astore_3
     808: aload_3
     809: aload_0
     810: getfield      #37                 // Field polyTemplate:Ljava/lang/String;
     813: checkcast     #79                 // class java/lang/CharSequence
     816: invokestatic  #317                // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C
     819: invokestatic  #158                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     822: aload_3
     823: aload_0
     824: getfield      #37                 // Field polyTemplate:Ljava/lang/String;
     827: checkcast     #79                 // class java/lang/CharSequence
     830: invokestatic  #317                // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C
     833: invokestatic  #158                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     836: lconst_0
     837: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     840: invokeinterface #302,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     845: checkcast     #205                // class java/lang/Number
     848: invokevirtual #306                // Method java/lang/Number.longValue:()J
     851: lconst_1
     852: ladd
     853: invokestatic  #299                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     856: invokeinterface #166,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     861: pop
     862: aload_3
     863: invokeinterface #321,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     868: checkcast     #48                 // class java/lang/Iterable
     871: invokestatic  #325                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     874: astore        4
     876: aload         4
     878: invokestatic  #203                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     881: checkcast     #205                // class java/lang/Number
     884: invokevirtual #306                // Method java/lang/Number.longValue:()J
     887: aload         4
     889: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     892: checkcast     #205                // class java/lang/Number
     895: invokevirtual #306                // Method java/lang/Number.longValue:()J
     898: lsub
     899: lstore        5
     901: new           #115                // class java/lang/StringBuilder
     904: dup
     905: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     908: ldc_w         #327                // String Puzzle 2:
     911: invokevirtual #120                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     914: lload         5
     916: invokevirtual #330                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     919: invokevirtual #133                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     922: getstatic     #219                // Field java/lang/System.out:Ljava/io/PrintStream;
     925: swap
     926: invokevirtual #225                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     929: return
}

Compiled from "Comparisons.kt"
public final class Day14$part_1$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public Day14$part_1$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class kotlin/Pair
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      12: checkcast     #29                 // class java/lang/Integer
      15: checkcast     #31                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class kotlin/Pair
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      32: checkcast     #29                 // class java/lang/Integer
      35: aload         5
      37: swap
      38: checkcast     #31                 // class java/lang/Comparable
      41: invokestatic  #37                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}


import java.io.*

fun print_day_4() {

    val yellow = "\u001B[33m"
    val reset = "\u001b[0m"
    val green = "\u001B[32m"
    println(yellow + "-".repeat(25) + "Advent of Code - Day 4" + "-".repeat(25) + reset)
    println(green)
    val process = Runtime.getRuntime().exec("figlet Giant Squid -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_4()
    print("Puzzle 1: ")
    Day4().part_1()
    print("Puzzle 2: ")
    Day4().part_2()
    println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}

class Day4 {

    private val lines = File("../Input/day4.txt").readLines()

    private val drawOrder = lines[0].split(",").map { it.toInt() }
    private val boards =
            lines.drop(1).windowed(6, 6) {
                it.drop(1).map { line ->
                    line.trim().split("  ", " ").map { numStr -> numStr.toInt() }
                }
            }

    fun checkLine(line: List<Int>, drawn: List<Int>) = drawn.containsAll(line)
    fun checkBoard(board: List<List<Int>>, drawn: List<Int>): Boolean {

        val hasHorizontalLine = board.any { checkLine(it, drawn) }
        val flippedBoard =
                (board[0].indices).map { outer ->
                    (board.indices).map { inner -> board[inner][outer] }
                }
        val hasVerticalLine = flippedBoard.any { checkLine(it, drawn) }

        return hasHorizontalLine || hasVerticalLine
    }

    fun part_1() {

        for (i in 5..drawOrder.size) {
            val currentDraw = drawOrder.take(i)
            boards.forEach() {
                if (checkBoard(it, currentDraw)) {
                    return calculateWinner(it, currentDraw)
                }
            }
        }
    }

    private fun calculateWinner(board: List<List<Int>>, currentDraw: List<Int>) {
        println(board.flatten().filter { !currentDraw.contains(it) }.sum() * currentDraw.last())
    }

    fun part_2() {
        val winners = mutableListOf<Int>()

        for (i in 5..drawOrder.size) {
            val currentDraw = drawOrder.take(i)
            boards.forEachIndexed() { index, board ->
                if (!winners.contains(index) && checkBoard(board, currentDraw)) {
                    winners.add(index)
                    if (winners.size == boards.size) {
                        return calculateWinner(board, currentDraw)
                    }
                }
            }
        }
    }
}

Compiled from "day04.kt"
public final class Day04Kt {
  public static final void print_day_4();
    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 4
      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 Giant Squid -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_4:()V
       3: ldc           #122                // String Puzzle 1:
       5: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
       8: swap
       9: invokevirtual #125                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      12: new           #127                // class Day4
      15: dup
      16: invokespecial #128                // Method Day4."<init>":()V
      19: invokevirtual #131                // Method Day4.part_1:()V
      22: ldc           #133                // String Puzzle 2:
      24: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      27: swap
      28: invokevirtual #125                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      31: new           #127                // class Day4
      34: dup
      35: invokespecial #128                // Method Day4."<init>":()V
      38: invokevirtual #136                // Method Day4.part_2:()V
      41: new           #14                 // class java/lang/StringBuilder
      44: dup
      45: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      48: ldc           #138                // String \n\u001b[33m
      50: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      53: ldc           #140                // String =
      55: checkcast     #25                 // class java/lang/CharSequence
      58: bipush        72
      60: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      63: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      66: ldc           #142                // String \u001b[0m\n
      68: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      71: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      74: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: return

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

  private static final kotlin.Unit print_day_4$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #149                // String it
       3: invokestatic  #155                // 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     #161                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      16: areturn
}