package com.adventofcode

import kotlin.math.roundToInt

data class Point(val x: Int, val y: Int) : Comparable<Point> {
  override fun compareTo(other: Point): Int {
    val xeq = x.compareTo(other.x)
    return if (xeq != 0) xeq else y.compareTo(other.y)
  }
}

data class Line(val start: Point, val end: Point) {
  val isHorizontal: Boolean = start.y == end.y
  val isVertical: Boolean = start.x == end.x
  private val slope: Double
    get() =
      if (isVertical) Double.NaN
      else (start.y - end.y).toDouble() / (start.x - end.x)

  val points: List<Point> by lazy {
    when {
      isVertical -> (minOf(start.y, end.y)..maxOf(start.y, end.y)).map { y -> Point(start.x, y) }
      isHorizontal -> (minOf(start.x, end.x)..maxOf(start.x, end.x)).map { x -> Point(x, start.y) }
      else -> interpolate()
    }
  }

  private fun interpolate(): List<Point> {
    val (x1, y1) = minOf(start, end)
    val (x2, _) = maxOf(start, end)
    return (x1..x2).map { x ->
      Point(x, (y1 + (x - x1) * slope).roundToInt())
    }
  }
}

private fun parse(input: String): List<Line> = input.lines()
  .map { line ->
    val (a, _, b) = line.split(" ")
    val (x1, y1) = a.split(",").map { it.toInt() }
    val (x2, y2) = b.split(",").map { it.toInt() }
    Line(Point(x1, y1), Point(x2, y2))
  }

fun findVents(input: String, excludeDiagonals: Boolean) = when (excludeDiagonals) {
  true -> findVents(input) { it.isVertical || it.isHorizontal }
  false -> findVents(input) { true }
}

private fun findVents(input: String, filter: (Line) -> Boolean): Int = parse(input)
  .filter(filter)
  .flatMap { it.points }
  .fold(mutableMapOf<Point, Int>()) { acc, point ->
    acc.apply { merge(point, 1) { v, _ -> v + 1 } }
  }
  .count { it.value > 1 }

fun day05(input: String, args: List<String> = listOf("p1")) {
  when (args.first().lowercase()) {
    "p1" -> println(findVents(input, excludeDiagonals = true))
    "p2" -> println(findVents(input, excludeDiagonals = false))
  }
}

Compiled from "Day05.kt"
public final class com.adventofcode.Day05Kt {
  private static final java.util.List<com.adventofcode.Line> parse(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #9                  // class java/lang/CharSequence
       4: invokestatic  #15                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
       7: checkcast     #17                 // class java/lang/Iterable
      10: astore_1
      11: nop
      12: iconst_0
      13: istore_2
      14: aload_1
      15: astore_3
      16: new           #19                 // class java/util/ArrayList
      19: dup
      20: aload_1
      21: bipush        10
      23: invokestatic  #25                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #29                 // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #31                 // class java/util/Collection
      32: astore        4
      34: iconst_0
      35: istore        5
      37: aload_3
      38: invokeinterface #35,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      43: astore        6
      45: aload         6
      47: invokeinterface #41,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          502
      55: aload         6
      57: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      62: astore        7
      64: aload         4
      66: aload         7
      68: checkcast     #47                 // class java/lang/String
      71: astore        8
      73: astore        27
      75: iconst_0
      76: istore        9
      78: aload         8
      80: checkcast     #9                  // class java/lang/CharSequence
      83: iconst_1
      84: anewarray     #47                 // class java/lang/String
      87: astore        10
      89: aload         10
      91: iconst_0
      92: ldc           #49                 // String
      94: aastore
      95: aload         10
      97: iconst_0
      98: iconst_0
      99: bipush        6
     101: aconst_null
     102: invokestatic  #53                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     105: astore        11
     107: aload         11
     109: iconst_0
     110: invokeinterface #59,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     115: checkcast     #47                 // class java/lang/String
     118: astore        10
     120: aload         11
     122: iconst_2
     123: invokeinterface #59,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     128: checkcast     #47                 // class java/lang/String
     131: astore        12
     133: aload         10
     135: checkcast     #9                  // class java/lang/CharSequence
     138: iconst_1
     139: anewarray     #47                 // class java/lang/String
     142: astore        13
     144: aload         13
     146: iconst_0
     147: ldc           #61                 // String ,
     149: aastore
     150: aload         13
     152: iconst_0
     153: iconst_0
     154: bipush        6
     156: aconst_null
     157: invokestatic  #53                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     160: checkcast     #17                 // class java/lang/Iterable
     163: astore        13
     165: iconst_0
     166: istore        14
     168: aload         13
     170: astore        15
     172: new           #19                 // class java/util/ArrayList
     175: dup
     176: aload         13
     178: bipush        10
     180: invokestatic  #25                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     183: invokespecial #29                 // Method java/util/ArrayList."<init>":(I)V
     186: checkcast     #31                 // class java/util/Collection
     189: astore        16
     191: iconst_0
     192: istore        17
     194: aload         15
     196: invokeinterface #35,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     201: astore        18
     203: aload         18
     205: invokeinterface #41,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     210: ifeq          257
     213: aload         18
     215: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     220: astore        19
     222: aload         16
     224: aload         19
     226: checkcast     #47                 // class java/lang/String
     229: astore        20
     231: astore        21
     233: iconst_0
     234: istore        22
     236: aload         20
     238: invokestatic  #67                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     241: nop
     242: invokestatic  #71                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     245: aload         21
     247: swap
     248: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     253: pop
     254: goto          203
     257: aload         16
     259: checkcast     #55                 // class java/util/List
     262: nop
     263: astore        23
     265: aload         23
     267: iconst_0
     268: invokeinterface #59,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     273: checkcast     #77                 // class java/lang/Number
     276: invokevirtual #81                 // Method java/lang/Number.intValue:()I
     279: istore        13
     281: aload         23
     283: iconst_1
     284: invokeinterface #59,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     289: checkcast     #77                 // class java/lang/Number
     292: invokevirtual #81                 // Method java/lang/Number.intValue:()I
     295: istore        14
     297: aload         12
     299: checkcast     #9                  // class java/lang/CharSequence
     302: iconst_1
     303: anewarray     #47                 // class java/lang/String
     306: astore        16
     308: aload         16
     310: iconst_0
     311: ldc           #61                 // String ,
     313: aastore
     314: aload         16
     316: iconst_0
     317: iconst_0
     318: bipush        6
     320: aconst_null
     321: invokestatic  #53                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     324: checkcast     #17                 // class java/lang/Iterable
     327: astore        16
     329: iconst_0
     330: istore        17
     332: aload         16
     334: astore        18
     336: new           #19                 // class java/util/ArrayList
     339: dup
     340: aload         16
     342: bipush        10
     344: invokestatic  #25                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     347: invokespecial #29                 // Method java/util/ArrayList."<init>":(I)V
     350: checkcast     #31                 // class java/util/Collection
     353: astore        19
     355: iconst_0
     356: istore        20
     358: aload         18
     360: invokeinterface #35,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     365: astore        22
     367: aload         22
     369: invokeinterface #41,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     374: ifeq          421
     377: aload         22
     379: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     384: astore        24
     386: aload         19
     388: aload         24
     390: checkcast     #47                 // class java/lang/String
     393: astore        25
     395: astore        21
     397: iconst_0
     398: istore        26
     400: aload         25
     402: invokestatic  #67                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     405: nop
     406: invokestatic  #71                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     409: aload         21
     411: swap
     412: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     417: pop
     418: goto          367
     421: aload         19
     423: checkcast     #55                 // class java/util/List
     426: nop
     427: astore        15
     429: aload         15
     431: iconst_0
     432: invokeinterface #59,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     437: checkcast     #77                 // class java/lang/Number
     440: invokevirtual #81                 // Method java/lang/Number.intValue:()I
     443: istore        16
     445: aload         15
     447: iconst_1
     448: invokeinterface #59,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     453: checkcast     #77                 // class java/lang/Number
     456: invokevirtual #81                 // Method java/lang/Number.intValue:()I
     459: istore        17
     461: new           #83                 // class com/adventofcode/Line
     464: dup
     465: new           #85                 // class com/adventofcode/Point
     468: dup
     469: iload         13
     471: iload         14
     473: invokespecial #88                 // Method com/adventofcode/Point."<init>":(II)V
     476: new           #85                 // class com/adventofcode/Point
     479: dup
     480: iload         16
     482: iload         17
     484: invokespecial #88                 // Method com/adventofcode/Point."<init>":(II)V
     487: invokespecial #91                 // Method com/adventofcode/Line."<init>":(Lcom/adventofcode/Point;Lcom/adventofcode/Point;)V
     490: aload         27
     492: swap
     493: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     498: pop
     499: goto          45
     502: aload         4
     504: checkcast     #55                 // class java/util/List
     507: nop
     508: areturn

  public static final int findVents(java.lang.String, boolean);
    Code:
       0: aload_0
       1: ldc           #118                // String input
       3: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: istore_2
       8: iload_2
       9: iconst_1
      10: if_icmpne     25
      13: aload_0
      14: invokedynamic #144,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      19: invokestatic  #147                // Method findVents:(Ljava/lang/String;Lkotlin/jvm/functions/Function1;)I
      22: goto          49
      25: iload_2
      26: ifne          41
      29: aload_0
      30: invokedynamic #152,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      35: invokestatic  #147                // Method findVents:(Ljava/lang/String;Lkotlin/jvm/functions/Function1;)I
      38: goto          49
      41: new           #154                // class kotlin/NoWhenBranchMatchedException
      44: dup
      45: invokespecial #157                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
      48: athrow
      49: ireturn

  private static final int findVents(java.lang.String, kotlin.jvm.functions.Function1<? super com.adventofcode.Line, java.lang.Boolean>);
    Code:
       0: aload_0
       1: invokestatic  #162                // Method parse:(Ljava/lang/String;)Ljava/util/List;
       4: checkcast     #17                 // class java/lang/Iterable
       7: astore_2
       8: nop
       9: iconst_0
      10: istore_3
      11: aload_2
      12: astore        4
      14: new           #19                 // class java/util/ArrayList
      17: dup
      18: invokespecial #163                // Method java/util/ArrayList."<init>":()V
      21: checkcast     #31                 // class java/util/Collection
      24: astore        5
      26: iconst_0
      27: istore        6
      29: aload         4
      31: invokeinterface #35,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        7
      38: aload         7
      40: invokeinterface #41,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          87
      48: aload         7
      50: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        8
      57: aload_1
      58: aload         8
      60: invokeinterface #167,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      65: checkcast     #169                // class java/lang/Boolean
      68: invokevirtual #172                // Method java/lang/Boolean.booleanValue:()Z
      71: ifeq          38
      74: aload         5
      76: aload         8
      78: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      83: pop
      84: goto          38
      87: aload         5
      89: checkcast     #55                 // class java/util/List
      92: nop
      93: checkcast     #17                 // class java/lang/Iterable
      96: astore_2
      97: nop
      98: iconst_0
      99: istore_3
     100: aload_2
     101: astore        4
     103: new           #19                 // class java/util/ArrayList
     106: dup
     107: invokespecial #163                // Method java/util/ArrayList."<init>":()V
     110: checkcast     #31                 // class java/util/Collection
     113: astore        5
     115: iconst_0
     116: istore        6
     118: aload         4
     120: invokeinterface #35,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     125: astore        7
     127: aload         7
     129: invokeinterface #41,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     134: ifeq          177
     137: aload         7
     139: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     144: astore        8
     146: aload         8
     148: checkcast     #83                 // class com/adventofcode/Line
     151: astore        9
     153: iconst_0
     154: istore        10
     156: aload         9
     158: invokevirtual #176                // Method com/adventofcode/Line.getPoints:()Ljava/util/List;
     161: checkcast     #17                 // class java/lang/Iterable
     164: astore        9
     166: aload         5
     168: aload         9
     170: invokestatic  #180                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     173: pop
     174: goto          127
     177: aload         5
     179: checkcast     #55                 // class java/util/List
     182: nop
     183: checkcast     #17                 // class java/lang/Iterable
     186: astore_2
     187: new           #182                // class java/util/LinkedHashMap
     190: dup
     191: invokespecial #183                // Method java/util/LinkedHashMap."<init>":()V
     194: checkcast     #185                // class java/util/Map
     197: astore_3
     198: nop
     199: iconst_0
     200: istore        4
     202: aload_3
     203: astore        5
     205: aload_2
     206: invokeinterface #35,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     211: astore        6
     213: aload         6
     215: invokeinterface #41,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     220: ifeq          289
     223: aload         6
     225: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     230: astore        7
     232: aload         5
     234: aload         7
     236: checkcast     #85                 // class com/adventofcode/Point
     239: astore        8
     241: astore        9
     243: iconst_0
     244: istore        10
     246: aload         9
     248: astore        11
     250: aload         11
     252: astore        12
     254: iconst_0
     255: istore        13
     257: aload         12
     259: aload         8
     261: iconst_1
     262: invokestatic  #71                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     265: invokedynamic #196,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function2;
     270: invokedynamic #207,  0            // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;
     275: invokeinterface #211,  4          // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
     280: pop
     281: aload         11
     283: nop
     284: astore        5
     286: goto          213
     289: aload         5
     291: astore_2
     292: nop
     293: iconst_0
     294: istore_3
     295: aload_2
     296: invokeinterface #214,  1          // InterfaceMethod java/util/Map.isEmpty:()Z
     301: ifeq          308
     304: iconst_0
     305: goto          386
     308: iconst_0
     309: istore        4
     311: aload_2
     312: invokeinterface #218,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     317: invokeinterface #221,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     322: astore        5
     324: aload         5
     326: invokeinterface #41,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     331: ifeq          384
     334: aload         5
     336: invokeinterface #45,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     341: checkcast     #223                // class java/util/Map$Entry
     344: astore        6
     346: aload         6
     348: astore        7
     350: iconst_0
     351: istore        8
     353: aload         7
     355: invokeinterface #226,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     360: checkcast     #77                 // class java/lang/Number
     363: invokevirtual #81                 // Method java/lang/Number.intValue:()I
     366: iconst_1
     367: if_icmple     374
     370: iconst_1
     371: goto          375
     374: iconst_0
     375: ifeq          324
     378: iinc          4, 1
     381: goto          324
     384: iload         4
     386: ireturn

  public static final void day05(java.lang.String, java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #118                // String input
       3: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc_w         #262                // String args
      10: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      13: aload_1
      14: invokestatic  #266                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      17: checkcast     #47                 // class java/lang/String
      20: getstatic     #272                // Field java/util/Locale.ROOT:Ljava/util/Locale;
      23: invokevirtual #276                // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;
      26: dup
      27: ldc_w         #278                // String toLowerCase(...)
      30: invokestatic  #281                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      33: astore_2
      34: aload_2
      35: ldc_w         #283                // String p1
      38: invokestatic  #287                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      41: ifeq          60
      44: aload_0
      45: iconst_1
      46: invokestatic  #289                // Method findVents:(Ljava/lang/String;Z)I
      49: istore_3
      50: getstatic     #295                // Field java/lang/System.out:Ljava/io/PrintStream;
      53: iload_3
      54: invokevirtual #300                // Method java/io/PrintStream.println:(I)V
      57: goto          83
      60: aload_2
      61: ldc_w         #302                // String p2
      64: invokestatic  #287                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      67: ifeq          83
      70: aload_0
      71: iconst_0
      72: invokestatic  #289                // Method findVents:(Ljava/lang/String;Z)I
      75: istore_3
      76: getstatic     #295                // Field java/lang/System.out:Ljava/io/PrintStream;
      79: iload_3
      80: invokevirtual #300                // Method java/io/PrintStream.println:(I)V
      83: return

  public static void day05$default(java.lang.String, java.util.List, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          13
       6: ldc_w         #283                // String p1
       9: invokestatic  #309                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      12: astore_1
      13: aload_0
      14: aload_1
      15: invokestatic  #311                // Method day05:(Ljava/lang/String;Ljava/util/List;)V
      18: return

  private static final boolean findVents$lambda$3(com.adventofcode.Line);
    Code:
       0: aload_0
       1: ldc_w         #312                // String it
       4: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #315                // Method com/adventofcode/Line.isVertical:()Z
      11: ifne          21
      14: aload_0
      15: invokevirtual #318                // Method com/adventofcode/Line.isHorizontal:()Z
      18: ifeq          25
      21: iconst_1
      22: goto          26
      25: iconst_0
      26: ireturn

  private static final boolean findVents$lambda$4(com.adventofcode.Line);
    Code:
       0: aload_0
       1: ldc_w         #312                // String it
       4: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_1
       8: ireturn

  private static final java.lang.Integer findVents$lambda$9$lambda$8$lambda$6(java.lang.Integer, java.lang.Integer);
    Code:
       0: aload_0
       1: ldc_w         #320                // String v
       4: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc_w         #322                // String <unused var>
      11: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      14: aload_0
      15: invokevirtual #323                // Method java/lang/Integer.intValue:()I
      18: iconst_1
      19: iadd
      20: invokestatic  #71                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      23: areturn

  private static final java.lang.Integer findVents$lambda$9$lambda$8$lambda$7(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #328,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #63                 // class java/lang/Integer
      11: areturn
}


package com.adventofcode

private const val DAYS_TO_REPRODUCE = 7
private const val DAYS_TO_MATURE = 2

data class Generation(val distribution: Map<Int, Long>) {
  private fun fillGaps(sparseMap: Map<Int, Long>): Map<Int, Long> {
    val result = mutableMapOf<Int, Long>()
    for (i in 0..DAYS_TO_MATURE + DAYS_TO_REPRODUCE) {
      result[i] = sparseMap[i] ?: 0
    }
    return result
  }

  val size: Long = distribution.values.sum()

  fun next(): Generation {
    val generation = fillGaps(distribution).toSortedMap().values.toList()
    val toReproduce = generation[0]
    val nextGeneration = generation.drop(1).toMutableList()
    nextGeneration[DAYS_TO_REPRODUCE - 1] += toReproduce
    nextGeneration[DAYS_TO_REPRODUCE + DAYS_TO_MATURE - 1] = toReproduce
    return Generation(nextGeneration.mapIndexed { idx, it -> idx to it }.toMap())
  }
}

fun computeFishPopulation(input: String, afterDays: Int = 80) =
  computeFishPopulation(parse(input), afterDays)

private fun computeFishPopulation(initialPopulation: List<Int>, afterDays: Int = 80): Long {
  val populationFreqMap = initialPopulation.groupingBy { it }
    .eachCount()
    .map { (k, v) -> k to v.toLong() }
    .toMap()
  var generation = Generation(populationFreqMap)
  for (i in 1..afterDays) {
    generation = generation.next()
  }
  return generation.size
}

private fun parse(input: String): List<Int> =
  input.lineSequence()
    .flatMap { it.split(",") }
    .map { it.toInt() }
    .toList()

fun day06(input: String, args: List<String> = listOf()) {
  when (args[0].lowercase()) {
    "p1" -> computeFishPopulation(input, 80)
    "p2" -> computeFishPopulation(input, 256)
  }
}

Compiled from "Day06.kt"
public final class com.adventofcode.Day06Kt {
  private static final int DAYS_TO_REPRODUCE;

  private static final int DAYS_TO_MATURE;

  public static final long computeFishPopulation(java.lang.String, int);
    Code:
       0: aload_0
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #19                 // Method parse:(Ljava/lang/String;)Ljava/util/List;
      10: iload_1
      11: invokestatic  #22                 // Method computeFishPopulation:(Ljava/util/List;I)J
      14: lreturn

  public static long computeFishPopulation$default(java.lang.String, int, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          9
       6: bipush        80
       8: istore_1
       9: aload_0
      10: iload_1
      11: invokestatic  #29                 // Method computeFishPopulation:(Ljava/lang/String;I)J
      14: lreturn

  private static final long computeFishPopulation(java.util.List<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: checkcast     #32                 // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: new           #34                 // class com/adventofcode/Day06Kt$computeFishPopulation$$inlined$groupingBy$1
      11: dup
      12: aload_3
      13: invokespecial #38                 // Method com/adventofcode/Day06Kt$computeFishPopulation$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
      16: checkcast     #40                 // class kotlin/collections/Grouping
      19: invokestatic  #46                 // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
      22: astore_3
      23: nop
      24: iconst_0
      25: istore        4
      27: aload_3
      28: astore        5
      30: new           #48                 // class java/util/ArrayList
      33: dup
      34: aload_3
      35: invokeinterface #54,  1           // InterfaceMethod java/util/Map.size:()I
      40: invokespecial #57                 // Method java/util/ArrayList."<init>":(I)V
      43: checkcast     #59                 // class java/util/Collection
      46: astore        6
      48: iconst_0
      49: istore        7
      51: aload         5
      53: invokeinterface #63,  1           // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      58: invokeinterface #69,  1           // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      63: astore        8
      65: aload         8
      67: invokeinterface #75,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      72: ifeq          154
      75: aload         8
      77: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      82: checkcast     #81                 // class java/util/Map$Entry
      85: astore        9
      87: aload         6
      89: aload         9
      91: astore        10
      93: astore        14
      95: iconst_0
      96: istore        11
      98: aload         10
     100: invokeinterface #84,  1           // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     105: checkcast     #86                 // class java/lang/Number
     108: invokevirtual #89                 // Method java/lang/Number.intValue:()I
     111: istore        12
     113: aload         10
     115: invokeinterface #92,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     120: checkcast     #86                 // class java/lang/Number
     123: invokevirtual #89                 // Method java/lang/Number.intValue:()I
     126: istore        13
     128: iload         12
     130: invokestatic  #98                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     133: iload         13
     135: i2l
     136: invokestatic  #103                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     139: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     142: aload         14
     144: swap
     145: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     150: pop
     151: goto          65
     154: aload         6
     156: checkcast     #115                // class java/util/List
     159: nop
     160: checkcast     #32                 // class java/lang/Iterable
     163: invokestatic  #121                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
     166: astore_2
     167: new           #123                // class com/adventofcode/Generation
     170: dup
     171: aload_2
     172: invokespecial #126                // Method com/adventofcode/Generation."<init>":(Ljava/util/Map;)V
     175: astore_3
     176: iconst_1
     177: istore        4
     179: iload         4
     181: iload_1
     182: if_icmpgt     202
     185: aload_3
     186: invokevirtual #129                // Method com/adventofcode/Generation.next:()Lcom/adventofcode/Generation;
     189: astore_3
     190: iload         4
     192: iload_1
     193: if_icmpeq     202
     196: iinc          4, 1
     199: goto          185
     202: aload_3
     203: invokevirtual #133                // Method com/adventofcode/Generation.getSize:()J
     206: lreturn

  static long computeFishPopulation$default(java.util.List, int, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          9
       6: bipush        80
       8: istore_1
       9: aload_0
      10: iload_1
      11: invokestatic  #22                 // Method computeFishPopulation:(Ljava/util/List;I)J
      14: lreturn

  private static final java.util.List<java.lang.Integer> parse(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #158                // class java/lang/CharSequence
       4: invokestatic  #164                // Method kotlin/text/StringsKt.lineSequence:(Ljava/lang/CharSequence;)Lkotlin/sequences/Sequence;
       7: invokedynamic #183,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      12: invokestatic  #189                // Method kotlin/sequences/SequencesKt.flatMapIterable:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      15: invokedynamic #197,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      20: invokestatic  #200                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      23: invokestatic  #204                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      26: areturn

  public static final void day06(java.lang.String, java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #209                // String args
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: iconst_0
      14: invokeinterface #213,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      19: checkcast     #215                // class java/lang/String
      22: getstatic     #221                // Field java/util/Locale.ROOT:Ljava/util/Locale;
      25: invokevirtual #225                // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;
      28: dup
      29: ldc           #227                // String toLowerCase(...)
      31: invokestatic  #230                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      34: astore_2
      35: aload_2
      36: ldc           #232                // String p1
      38: invokestatic  #236                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      41: ifeq          54
      44: aload_0
      45: bipush        80
      47: invokestatic  #29                 // Method computeFishPopulation:(Ljava/lang/String;I)J
      50: pop2
      51: goto          71
      54: aload_2
      55: ldc           #238                // String p2
      57: invokestatic  #236                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      60: ifeq          71
      63: aload_0
      64: sipush        256
      67: invokestatic  #29                 // Method computeFishPopulation:(Ljava/lang/String;I)J
      70: pop2
      71: return

  public static void day06$default(java.lang.String, java.util.List, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          10
       6: invokestatic  #246                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
       9: astore_1
      10: aload_0
      11: aload_1
      12: invokestatic  #248                // Method day06:(Ljava/lang/String;Ljava/util/List;)V
      15: return

  private static final java.lang.Iterable parse$lambda$2(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #250                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #158                // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #215                // class java/lang/String
      14: astore_1
      15: aload_1
      16: iconst_0
      17: ldc           #252                // String ,
      19: aastore
      20: aload_1
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #256                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #32                 // class java/lang/Iterable
      32: areturn

  private static final int parse$lambda$3(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #250                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #259                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      10: ireturn
}

Compiled from "_Collections.kt"
public final class com.adventofcode.Day06Kt$computeFishPopulation$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.Integer, java.lang.Integer> {
  final java.lang.Iterable $this_groupingBy;

  public com.adventofcode.Day06Kt$computeFishPopulation$$inlined$groupingBy$1(java.lang.Iterable);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<java.lang.Integer> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       4: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: areturn

  public java.lang.Integer keyOf(java.lang.Integer);
    Code:
       0: aload_1
       1: checkcast     #37                 // class java/lang/Number
       4: invokevirtual #41                 // Method java/lang/Number.intValue:()I
       7: istore_2
       8: iconst_0
       9: istore_3
      10: iload_2
      11: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: areturn
}


package com.adventofcode

data class Diagnostic(val rowView: List<String>) {
  private val colView: List<String> by lazy { readColumns(rowView) }

  private fun readColumns(rows: List<String>): List<String> {
    val columns = mutableMapOf<Int, String>()
    for (row in rows) {
      for (j in row.indices) {
        columns.merge(j, "${row[j]}") { v, _ -> v + row[j] }
      }
    }
    return columns.entries.map { it.value }
  }

  private fun mostCommonBit(bitString: String): Char? {
    val counts = bitString.groupingBy { it }.eachCount()
    return when {
      counts['1']!! > counts['0']!! -> '1'
      counts['0']!! > counts['1']!! -> '0'
      else -> null
    }
  }

  private fun negateBit(bit: Char) = when (bit) {
    '1' -> '0'
    '0' -> '1'
    else -> error("Expected bit")
  }

  val powerConsumption: Int
    get() {
      val (gamma, epsilon) = colView.fold("" to "") { (gamma, epsilon), column ->
        val most = mostCommonBit(column) ?: '1'
        (gamma + most) to (epsilon + negateBit(most))
      }

      return gamma.toInt(2) * epsilon.toInt(2)
    }

  private fun o2RatingStrategy(bitString: String): Char =
    mostCommonBit(bitString) ?: '1'

  private fun co2RatingStrategy(bitString: String): Char =
    negateBit(o2RatingStrategy(bitString))

  private fun getRating(strategy: (String) -> Char): Int {
    var readings = rowView
    var step = 0
    var columns = readColumns(readings)
    do {
      val bit = strategy(columns[step])
      readings = readings.filter { it[step] == bit }
      columns = readColumns(readings)
      step += 1
    } while (readings.size > 1)
    return readings.first().toInt(2)
  }

  val o2Rating: Int get() = getRating(this::o2RatingStrategy)

  val co2Rating: Int get() = getRating(this::co2RatingStrategy)

  val lifeSupportRating: Int get() = o2Rating * co2Rating
}

fun day03(input: String, args: List<String> = listOf("p1")) {
  when (args.first().lowercase()) {
    "p1" -> println(Diagnostic(input.lines()).powerConsumption)
    "p2" -> println(Diagnostic(input.lines()).lifeSupportRating)
  }
}

Compiled from "Day03.kt"
public final class com.adventofcode.Day03Kt {
  public static final void day03(java.lang.String, java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #18                 // String args
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      16: checkcast     #26                 // class java/lang/String
      19: getstatic     #32                 // Field java/util/Locale.ROOT:Ljava/util/Locale;
      22: invokevirtual #36                 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;
      25: dup
      26: ldc           #38                 // String toLowerCase(...)
      28: invokestatic  #41                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      31: astore_2
      32: aload_2
      33: ldc           #43                 // String p1
      35: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      38: ifeq          69
      41: new           #49                 // class com/adventofcode/Diagnostic
      44: dup
      45: aload_0
      46: checkcast     #51                 // class java/lang/CharSequence
      49: invokestatic  #57                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
      52: invokespecial #61                 // Method com/adventofcode/Diagnostic."<init>":(Ljava/util/List;)V
      55: invokevirtual #65                 // Method com/adventofcode/Diagnostic.getPowerConsumption:()I
      58: istore_3
      59: getstatic     #71                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: iload_3
      63: invokevirtual #77                 // Method java/io/PrintStream.println:(I)V
      66: goto          103
      69: aload_2
      70: ldc           #79                 // String p2
      72: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      75: ifeq          103
      78: new           #49                 // class com/adventofcode/Diagnostic
      81: dup
      82: aload_0
      83: checkcast     #51                 // class java/lang/CharSequence
      86: invokestatic  #57                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
      89: invokespecial #61                 // Method com/adventofcode/Diagnostic."<init>":(Ljava/util/List;)V
      92: invokevirtual #82                 // Method com/adventofcode/Diagnostic.getLifeSupportRating:()I
      95: istore_3
      96: getstatic     #71                 // Field java/lang/System.out:Ljava/io/PrintStream;
      99: iload_3
     100: invokevirtual #77                 // Method java/io/PrintStream.println:(I)V
     103: return

  public static void day03$default(java.lang.String, java.util.List, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          12
       6: ldc           #43                 // String p1
       8: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      11: astore_1
      12: aload_0
      13: aload_1
      14: invokestatic  #92                 // Method day03:(Ljava/lang/String;Ljava/util/List;)V
      17: return
}


package com.adventofcode

/**
 * [https://adventofcode.com/2021/day/2]
 */
enum class Command {
  FORWARD, DOWN, UP;

  companion object {
    fun of(string: String) = when (string) {
      "forward" -> FORWARD
      "down" -> DOWN
      "up" -> UP
      else -> error("Unknown command")
    }
  }
}

private data class Position(val x: Int, val y: Int, val aim: Int)

fun commands(input: String): List<Pair<Command, Int>> = input.trim().lines()
  .map {
    val (first, second) = it.trim().split(" ", "\t")
    Command.of(first) to second.toInt()
  }

private fun diveBadly(pos: Position, command: Command, magnitude: Int): Position {
  return when (command) {
    Command.FORWARD -> pos.copy(x = pos.x + magnitude)
    Command.UP -> pos.copy(y = pos.y - magnitude)
    Command.DOWN -> pos.copy(y = pos.y + magnitude)
  }
}

private fun diveCorrectly(pos: Position, command: Command, magnitude: Int): Position {
  return when (command) {
    Command.FORWARD -> pos.copy(x = pos.x + magnitude, y = pos.y + magnitude * pos.aim)
    Command.UP -> pos.copy(aim = pos.aim - magnitude)
    Command.DOWN -> pos.copy(aim = pos.aim + magnitude)
  }
}

fun dive(commands: List<Pair<Command, Int>>, strategy: Strategy): Int = commands
  .fold(Position(0, 0, 0)) { pos, (command, magnitude) ->
    when (strategy) {
      Strategy.BADLY -> diveBadly(pos, command, magnitude)
      Strategy.CORRECTLY -> diveCorrectly(pos, command, magnitude)
    }
  }
  .run { x * y }

enum class Strategy { BADLY, CORRECTLY }

fun day02(input: String, args: List<String> = listOf("p1")) {
  when (args.first().lowercase()) {
    "p1" -> println(dive(commands(input), Strategy.BADLY))
    "p2" -> println(dive(commands(input), Strategy.CORRECTLY))
  }
}

Compiled from "Day02.kt"
public final class com.adventofcode.Day02Kt {
  public static final java.util.List<kotlin.Pair<com.adventofcode.Command, java.lang.Integer>> commands(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #18                 // class java/lang/CharSequence
      10: invokestatic  #24                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      13: invokevirtual #28                 // Method java/lang/Object.toString:()Ljava/lang/String;
      16: checkcast     #18                 // class java/lang/CharSequence
      19: invokestatic  #32                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
      22: checkcast     #34                 // class java/lang/Iterable
      25: astore_1
      26: nop
      27: iconst_0
      28: istore_2
      29: aload_1
      30: astore_3
      31: new           #36                 // class java/util/ArrayList
      34: dup
      35: aload_1
      36: bipush        10
      38: invokestatic  #42                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      41: invokespecial #46                 // Method java/util/ArrayList."<init>":(I)V
      44: checkcast     #48                 // class java/util/Collection
      47: astore        4
      49: iconst_0
      50: istore        5
      52: aload_3
      53: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      58: astore        6
      60: aload         6
      62: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      67: ifeq          194
      70: aload         6
      72: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      77: astore        7
      79: aload         4
      81: aload         7
      83: checkcast     #64                 // class java/lang/String
      86: astore        8
      88: astore        13
      90: iconst_0
      91: istore        9
      93: aload         8
      95: checkcast     #18                 // class java/lang/CharSequence
      98: invokestatic  #24                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     101: invokevirtual #28                 // Method java/lang/Object.toString:()Ljava/lang/String;
     104: checkcast     #18                 // class java/lang/CharSequence
     107: iconst_2
     108: anewarray     #64                 // class java/lang/String
     111: astore        10
     113: aload         10
     115: iconst_0
     116: ldc           #66                 // String
     118: aastore
     119: aload         10
     121: iconst_1
     122: ldc           #68                 // String \t
     124: aastore
     125: aload         10
     127: iconst_0
     128: iconst_0
     129: bipush        6
     131: aconst_null
     132: invokestatic  #72                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     135: astore        11
     137: aload         11
     139: iconst_0
     140: invokeinterface #78,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     145: checkcast     #64                 // class java/lang/String
     148: astore        10
     150: aload         11
     152: iconst_1
     153: invokeinterface #78,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     158: checkcast     #64                 // class java/lang/String
     161: astore        12
     163: getstatic     #84                 // Field com/adventofcode/Command.Companion:Lcom/adventofcode/Command$Companion;
     166: aload         10
     168: invokevirtual #90                 // Method com/adventofcode/Command$Companion.of:(Ljava/lang/String;)Lcom/adventofcode/Command;
     171: aload         12
     173: invokestatic  #96                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     176: invokestatic  #100                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     179: invokestatic  #106                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     182: aload         13
     184: swap
     185: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     190: pop
     191: goto          60
     194: aload         4
     196: checkcast     #74                 // class java/util/List
     199: nop
     200: areturn

  private static final com.adventofcode.Position diveBadly(com.adventofcode.Position, com.adventofcode.Command, int);
    Code:
       0: aload_1
       1: getstatic     #133                // Field com/adventofcode/Day02Kt$WhenMappings.$EnumSwitchMapping$0:[I
       4: swap
       5: invokevirtual #137                // Method com/adventofcode/Command.ordinal:()I
       8: iaload
       9: tableswitch   { // 1 to 3
                     1: 36
                     2: 54
                     3: 71
               default: 88
          }
      36: aload_0
      37: aload_0
      38: invokevirtual #142                // Method com/adventofcode/Position.getX:()I
      41: iload_2
      42: iadd
      43: iconst_0
      44: iconst_0
      45: bipush        6
      47: aconst_null
      48: invokestatic  #146                // Method com/adventofcode/Position.copy$default:(Lcom/adventofcode/Position;IIIILjava/lang/Object;)Lcom/adventofcode/Position;
      51: goto          96
      54: aload_0
      55: iconst_0
      56: aload_0
      57: invokevirtual #149                // Method com/adventofcode/Position.getY:()I
      60: iload_2
      61: isub
      62: iconst_0
      63: iconst_5
      64: aconst_null
      65: invokestatic  #146                // Method com/adventofcode/Position.copy$default:(Lcom/adventofcode/Position;IIIILjava/lang/Object;)Lcom/adventofcode/Position;
      68: goto          96
      71: aload_0
      72: iconst_0
      73: aload_0
      74: invokevirtual #149                // Method com/adventofcode/Position.getY:()I
      77: iload_2
      78: iadd
      79: iconst_0
      80: iconst_5
      81: aconst_null
      82: invokestatic  #146                // Method com/adventofcode/Position.copy$default:(Lcom/adventofcode/Position;IIIILjava/lang/Object;)Lcom/adventofcode/Position;
      85: goto          96
      88: new           #151                // class kotlin/NoWhenBranchMatchedException
      91: dup
      92: invokespecial #154                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
      95: athrow
      96: areturn

  private static final com.adventofcode.Position diveCorrectly(com.adventofcode.Position, com.adventofcode.Command, int);
    Code:
       0: aload_1
       1: getstatic     #133                // Field com/adventofcode/Day02Kt$WhenMappings.$EnumSwitchMapping$0:[I
       4: swap
       5: invokevirtual #137                // Method com/adventofcode/Command.ordinal:()I
       8: iaload
       9: tableswitch   { // 1 to 3
                     1: 36
                     2: 63
                     3: 80
               default: 97
          }
      36: aload_0
      37: aload_0
      38: invokevirtual #142                // Method com/adventofcode/Position.getX:()I
      41: iload_2
      42: iadd
      43: aload_0
      44: invokevirtual #149                // Method com/adventofcode/Position.getY:()I
      47: iload_2
      48: aload_0
      49: invokevirtual #163                // Method com/adventofcode/Position.getAim:()I
      52: imul
      53: iadd
      54: iconst_0
      55: iconst_4
      56: aconst_null
      57: invokestatic  #146                // Method com/adventofcode/Position.copy$default:(Lcom/adventofcode/Position;IIIILjava/lang/Object;)Lcom/adventofcode/Position;
      60: goto          105
      63: aload_0
      64: iconst_0
      65: iconst_0
      66: aload_0
      67: invokevirtual #163                // Method com/adventofcode/Position.getAim:()I
      70: iload_2
      71: isub
      72: iconst_3
      73: aconst_null
      74: invokestatic  #146                // Method com/adventofcode/Position.copy$default:(Lcom/adventofcode/Position;IIIILjava/lang/Object;)Lcom/adventofcode/Position;
      77: goto          105
      80: aload_0
      81: iconst_0
      82: iconst_0
      83: aload_0
      84: invokevirtual #163                // Method com/adventofcode/Position.getAim:()I
      87: iload_2
      88: iadd
      89: iconst_3
      90: aconst_null
      91: invokestatic  #146                // Method com/adventofcode/Position.copy$default:(Lcom/adventofcode/Position;IIIILjava/lang/Object;)Lcom/adventofcode/Position;
      94: goto          105
      97: new           #151                // class kotlin/NoWhenBranchMatchedException
     100: dup
     101: invokespecial #154                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     104: athrow
     105: areturn

  public static final int dive(java.util.List<? extends kotlin.Pair<? extends com.adventofcode.Command, java.lang.Integer>>, com.adventofcode.Strategy);
    Code:
       0: aload_0
       1: ldc           #167                // String commands
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #169                // String strategy
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #34                 // class java/lang/Iterable
      16: astore_2
      17: new           #139                // class com/adventofcode/Position
      20: dup
      21: iconst_0
      22: iconst_0
      23: iconst_0
      24: invokespecial #172                // Method com/adventofcode/Position."<init>":(III)V
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_3
      32: astore        5
      34: aload_2
      35: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      40: astore        6
      42: aload         6
      44: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      49: ifeq          166
      52: aload         6
      54: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: astore        7
      61: aload         5
      63: aload         7
      65: checkcast     #174                // class kotlin/Pair
      68: astore        8
      70: astore        9
      72: iconst_0
      73: istore        10
      75: aload         8
      77: invokevirtual #177                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      80: checkcast     #80                 // class com/adventofcode/Command
      83: astore        11
      85: aload         8
      87: invokevirtual #180                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      90: checkcast     #182                // class java/lang/Number
      93: invokevirtual #185                // Method java/lang/Number.intValue:()I
      96: istore        12
      98: aload_1
      99: getstatic     #188                // Field com/adventofcode/Day02Kt$WhenMappings.$EnumSwitchMapping$1:[I
     102: swap
     103: invokevirtual #191                // Method com/adventofcode/Strategy.ordinal:()I
     106: iaload
     107: tableswitch   { // 1 to 2
                     1: 128
                     2: 140
               default: 152
          }
     128: aload         9
     130: aload         11
     132: iload         12
     134: invokestatic  #193                // Method diveBadly:(Lcom/adventofcode/Position;Lcom/adventofcode/Command;I)Lcom/adventofcode/Position;
     137: goto          160
     140: aload         9
     142: aload         11
     144: iload         12
     146: invokestatic  #195                // Method diveCorrectly:(Lcom/adventofcode/Position;Lcom/adventofcode/Command;I)Lcom/adventofcode/Position;
     149: goto          160
     152: new           #151                // class kotlin/NoWhenBranchMatchedException
     155: dup
     156: invokespecial #154                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     159: athrow
     160: nop
     161: astore        5
     163: goto          42
     166: aload         5
     168: astore_3
     169: iconst_0
     170: istore        4
     172: aload_3
     173: invokevirtual #142                // Method com/adventofcode/Position.getX:()I
     176: aload_3
     177: invokevirtual #149                // Method com/adventofcode/Position.getY:()I
     180: imul
     181: nop
     182: ireturn

  public static final void day02(java.lang.String, java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #210                // String args
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokestatic  #213                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      16: checkcast     #64                 // class java/lang/String
      19: getstatic     #219                // Field java/util/Locale.ROOT:Ljava/util/Locale;
      22: invokevirtual #223                // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;
      25: dup
      26: ldc           #225                // String toLowerCase(...)
      28: invokestatic  #228                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      31: astore_2
      32: aload_2
      33: ldc           #230                // String p1
      35: invokestatic  #234                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      38: ifeq          62
      41: aload_0
      42: invokestatic  #236                // Method commands:(Ljava/lang/String;)Ljava/util/List;
      45: getstatic     #239                // Field com/adventofcode/Strategy.BADLY:Lcom/adventofcode/Strategy;
      48: invokestatic  #241                // Method dive:(Ljava/util/List;Lcom/adventofcode/Strategy;)I
      51: istore_3
      52: getstatic     #247                // Field java/lang/System.out:Ljava/io/PrintStream;
      55: iload_3
      56: invokevirtual #252                // Method java/io/PrintStream.println:(I)V
      59: goto          89
      62: aload_2
      63: ldc           #254                // String p2
      65: invokestatic  #234                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      68: ifeq          89
      71: aload_0
      72: invokestatic  #236                // Method commands:(Ljava/lang/String;)Ljava/util/List;
      75: getstatic     #257                // Field com/adventofcode/Strategy.CORRECTLY:Lcom/adventofcode/Strategy;
      78: invokestatic  #241                // Method dive:(Ljava/util/List;Lcom/adventofcode/Strategy;)I
      81: istore_3
      82: getstatic     #247                // Field java/lang/System.out:Ljava/io/PrintStream;
      85: iload_3
      86: invokevirtual #252                // Method java/io/PrintStream.println:(I)V
      89: return

  public static void day02$default(java.lang.String, java.util.List, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          12
       6: ldc           #230                // String p1
       8: invokestatic  #263                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      11: astore_1
      12: aload_0
      13: aload_1
      14: invokestatic  #265                // Method day02:(Ljava/lang/String;Ljava/util/List;)V
      17: return
}

Compiled from "Day02.kt"
public final class com.adventofcode.Day02Kt$WhenMappings {
  public static final int[] $EnumSwitchMapping$0;

  public static final int[] $EnumSwitchMapping$1;

  static {};
    Code:
       0: invokestatic  #14                 // Method com/adventofcode/Command.values:()[Lcom/adventofcode/Command;
       3: arraylength
       4: newarray       int
       6: astore_0
       7: nop
       8: aload_0
       9: getstatic     #18                 // Field com/adventofcode/Command.FORWARD:Lcom/adventofcode/Command;
      12: invokevirtual #22                 // Method com/adventofcode/Command.ordinal:()I
      15: iconst_1
      16: iastore
      17: goto          21
      20: astore_1
      21: nop
      22: aload_0
      23: getstatic     #25                 // Field com/adventofcode/Command.UP:Lcom/adventofcode/Command;
      26: invokevirtual #22                 // Method com/adventofcode/Command.ordinal:()I
      29: iconst_2
      30: iastore
      31: goto          35
      34: astore_1
      35: nop
      36: aload_0
      37: getstatic     #28                 // Field com/adventofcode/Command.DOWN:Lcom/adventofcode/Command;
      40: invokevirtual #22                 // Method com/adventofcode/Command.ordinal:()I
      43: iconst_3
      44: iastore
      45: goto          49
      48: astore_1
      49: aload_0
      50: putstatic     #32                 // Field $EnumSwitchMapping$0:[I
      53: invokestatic  #37                 // Method com/adventofcode/Strategy.values:()[Lcom/adventofcode/Strategy;
      56: arraylength
      57: newarray       int
      59: astore_0
      60: nop
      61: aload_0
      62: getstatic     #41                 // Field com/adventofcode/Strategy.BADLY:Lcom/adventofcode/Strategy;
      65: invokevirtual #42                 // Method com/adventofcode/Strategy.ordinal:()I
      68: iconst_1
      69: iastore
      70: goto          74
      73: astore_1
      74: nop
      75: aload_0
      76: getstatic     #45                 // Field com/adventofcode/Strategy.CORRECTLY:Lcom/adventofcode/Strategy;
      79: invokevirtual #42                 // Method com/adventofcode/Strategy.ordinal:()I
      82: iconst_2
      83: iastore
      84: goto          88
      87: astore_1
      88: aload_0
      89: putstatic     #48                 // Field $EnumSwitchMapping$1:[I
      92: return
    Exception table:
       from    to  target type
           7    17    20   Class java/lang/NoSuchFieldError
          21    31    34   Class java/lang/NoSuchFieldError
          35    45    48   Class java/lang/NoSuchFieldError
          60    70    73   Class java/lang/NoSuchFieldError
          74    84    87   Class java/lang/NoSuchFieldError
}


package com.adventofcode

/**
 * [https://adventofcode.com/2021/day/1]
 */
fun sonarSweep(readings: Sequence<Int>, window: Int = 1): Int = readings
  .windowed(window)
  .map { it.sum() }
  .fold(listOf<Pair<Int, DepthChange>>()) { acc, windowedSum ->
    acc + (acc.lastOrNull()?.let { windowedSum to DepthChange.of(it.first, windowedSum) }
      ?: (windowedSum to DepthChange.NONE))
  }
  .count { it.second == DepthChange.INCREASE }

enum class DepthChange {
  NONE, INCREASE, DECREASE;

  companion object {
    fun of(prev: Int, next: Int): DepthChange {
      val change = next - prev
      return when {
        change > 0 -> INCREASE
        change < 0 -> DECREASE
        else -> NONE
      }
    }
  }
}

fun day01(input: String, args: List<String> = listOf("1")) {
  val readings = input.lineSequence().map { it.toInt() }
  val window = args.first().toInt()
  println(sonarSweep(readings, window))
}

Compiled from "Day01.kt"
public final class com.adventofcode.Day01Kt {
  public static final int sonarSweep(kotlin.sequences.Sequence<java.lang.Integer>, int);
    Code:
       0: aload_0
       1: ldc           #10                 // String readings
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: iconst_0
       9: iconst_0
      10: bipush        6
      12: aconst_null
      13: invokestatic  #22                 // Method kotlin/sequences/SequencesKt.windowed$default:(Lkotlin/sequences/Sequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;
      16: invokedynamic #42,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      21: invokestatic  #46                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      24: astore_2
      25: invokestatic  #52                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      28: astore_3
      29: nop
      30: iconst_0
      31: istore        4
      33: aload_3
      34: astore        5
      36: aload_2
      37: invokeinterface #58,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          160
      54: aload         6
      56: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         5
      65: aload         7
      67: checkcast     #70                 // class java/lang/Number
      70: invokevirtual #74                 // Method java/lang/Number.intValue:()I
      73: istore        8
      75: astore        9
      77: iconst_0
      78: istore        10
      80: aload         9
      82: checkcast     #76                 // class java/util/Collection
      85: aload         9
      87: invokestatic  #80                 // Method kotlin/collections/CollectionsKt.lastOrNull:(Ljava/util/List;)Ljava/lang/Object;
      90: checkcast     #82                 // class kotlin/Pair
      93: dup
      94: ifnull        139
      97: astore        11
      99: astore        12
     101: iconst_0
     102: istore        13
     104: iload         8
     106: invokestatic  #88                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     109: getstatic     #94                 // Field com/adventofcode/DepthChange.Companion:Lcom/adventofcode/DepthChange$Companion;
     112: aload         11
     114: invokevirtual #97                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     117: checkcast     #70                 // class java/lang/Number
     120: invokevirtual #74                 // Method java/lang/Number.intValue:()I
     123: iload         8
     125: invokevirtual #103                // Method com/adventofcode/DepthChange$Companion.of:(II)Lcom/adventofcode/DepthChange;
     128: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     131: aload         12
     133: swap
     134: nop
     135: dup
     136: ifnonnull     151
     139: pop
     140: iload         8
     142: invokestatic  #88                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     145: getstatic     #113                // Field com/adventofcode/DepthChange.NONE:Lcom/adventofcode/DepthChange;
     148: invokestatic  #109                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     151: invokestatic  #117                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     154: nop
     155: astore        5
     157: goto          44
     160: aload         5
     162: checkcast     #119                // class java/lang/Iterable
     165: astore_2
     166: nop
     167: iconst_0
     168: istore_3
     169: aload_2
     170: instanceof    #76                 // class java/util/Collection
     173: ifeq          192
     176: aload_2
     177: checkcast     #76                 // class java/util/Collection
     180: invokeinterface #122,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     185: ifeq          192
     188: iconst_0
     189: goto          267
     192: iconst_0
     193: istore        4
     195: aload_2
     196: invokeinterface #123,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     201: astore        5
     203: aload         5
     205: invokeinterface #64,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     210: ifeq          265
     213: aload         5
     215: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     220: astore        6
     222: aload         6
     224: checkcast     #82                 // class kotlin/Pair
     227: astore        7
     229: iconst_0
     230: istore        8
     232: aload         7
     234: invokevirtual #126                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     237: getstatic     #129                // Field com/adventofcode/DepthChange.INCREASE:Lcom/adventofcode/DepthChange;
     240: if_acmpne     247
     243: iconst_1
     244: goto          248
     247: iconst_0
     248: ifeq          203
     251: iinc          4, 1
     254: iload         4
     256: ifge          203
     259: invokestatic  #133                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     262: goto          203
     265: iload         4
     267: ireturn

  public static int sonarSweep$default(kotlin.sequences.Sequence, int, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_1
       7: istore_1
       8: aload_0
       9: iload_1
      10: invokestatic  #160                // Method sonarSweep:(Lkotlin/sequences/Sequence;I)I
      13: ireturn

  public static final void day01(java.lang.String, java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #165                // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #167                // String args
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #169                // class java/lang/CharSequence
      16: invokestatic  #175                // Method kotlin/text/StringsKt.lineSequence:(Ljava/lang/CharSequence;)Lkotlin/sequences/Sequence;
      19: invokedynamic #183,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      24: invokestatic  #46                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      27: astore_2
      28: aload_1
      29: invokestatic  #186                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      32: checkcast     #188                // class java/lang/String
      35: invokestatic  #191                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      38: istore_3
      39: aload_2
      40: iload_3
      41: invokestatic  #160                // Method sonarSweep:(Lkotlin/sequences/Sequence;I)I
      44: istore        4
      46: getstatic     #197                // Field java/lang/System.out:Ljava/io/PrintStream;
      49: iload         4
      51: invokevirtual #203                // Method java/io/PrintStream.println:(I)V
      54: return

  public static void day01$default(java.lang.String, java.util.List, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          12
       6: ldc           #208                // String 1
       8: invokestatic  #212                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      11: astore_1
      12: aload_0
      13: aload_1
      14: invokestatic  #214                // Method day01:(Ljava/lang/String;Ljava/util/List;)V
      17: return

  private static final int sonarSweep$lambda$0(java.util.List);
    Code:
       0: aload_0
       1: ldc           #215                // String it
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #119                // class java/lang/Iterable
      10: invokestatic  #219                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
      13: ireturn

  private static final int day01$lambda$4(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #215                // String it
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #191                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      10: ireturn
}