package com.codelicia.advent2021

import kotlin.math.max
import kotlin.math.min

typealias Vent = Pair<Int, Int>
typealias VentLine = Pair<Vent, Vent>

class Day05(input: String) {

    private val vents: List<VentLine> = input.trimIndent()
        .lines()
        .map { x ->
            val xs = x.split(" -> ")

            Vent(xs[0]) to Vent(xs[1])
        }

    fun part1(): Int = overlaps { vent -> vent.isDiagonal() }

    fun part2(): Int = overlaps { false }

    private fun VentLine.diagonalRange(): List<Vent> =
        (if (first.second < second.second) horizontalRange().reversed() else horizontalRange())
            .zip(if (first.first < second.first) verticalRange().reversed() else verticalRange())

    private fun VentLine.horizontalRange(): IntRange =
        min(first.first, second.first)..max(first.first, second.first)

    private fun VentLine.verticalRange(): IntRange =
        min(first.second, second.second)..max(first.second, second.second)

    private fun VentLine.isDiagonal() =
        first.first != second.first && first.second != second.second

    private fun VentLine.isHorizontal() =
        first.first != second.first

    private fun VentLine.isVertical() =
        first.second != second.second

    private fun overlaps(predicate: (VentLine) -> Boolean): Int =
        vents.map { line ->
            return@map when {
                predicate(line) -> emptyList<String>()
                line.isDiagonal() -> line.diagonalRange().map { "${it.first},${it.second}" }
                line.isHorizontal() -> line.horizontalRange().map { "$it,${line.first.second}" }
                line.isVertical() -> line.verticalRange().map { "${line.first.first},$it" }
                else -> emptyList<String>()
            }
        }
            .flatten()
            .groupingBy { it }
            .eachCount()
            .count { it.value > 1 }

    companion object {
        private fun Vent(s: String): Vent =
            s.split(",").first().toInt() to s.split(",").last().toInt()
    }
}

Compiled from "Day05.kt"
public final class com.codelicia.advent2021.Day05Kt {
}

Compiled from "Day05.kt"
public final class com.codelicia.advent2021.Day05$Companion {
  private com.codelicia.advent2021.Day05$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final kotlin.Pair<java.lang.Integer, java.lang.Integer> Vent(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #15                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #17                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #19                 // String ,
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #25                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      26: checkcast     #17                 // class java/lang/String
      29: invokestatic  #37                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      32: invokestatic  #41                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aload_1
      36: checkcast     #15                 // class java/lang/CharSequence
      39: iconst_1
      40: anewarray     #17                 // class java/lang/String
      43: astore_2
      44: aload_2
      45: iconst_0
      46: ldc           #19                 // String ,
      48: aastore
      49: aload_2
      50: iconst_0
      51: iconst_0
      52: bipush        6
      54: aconst_null
      55: invokestatic  #25                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      58: invokestatic  #44                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
      61: checkcast     #17                 // class java/lang/String
      64: invokestatic  #37                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      67: invokestatic  #41                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      70: invokestatic  #50                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      73: areturn

  public static final kotlin.Pair access$Vent(com.codelicia.advent2021.Day05$Companion, java.lang.String);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #56                 // Method Vent:(Ljava/lang/String;)Lkotlin/Pair;
       5: areturn

  public com.codelicia.advent2021.Day05$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #59                 // Method "<init>":()V
       4: return
}

Compiled from "Day05.kt"
public final class com.codelicia.advent2021.Day05 {
  public static final com.codelicia.advent2021.Day05$Companion Companion;

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

  public com.codelicia.advent2021.Day05(java.lang.String);
    Code:
       0: aload_1
       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: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: invokestatic  #24                 // Method kotlin/text/StringsKt.trimIndent:(Ljava/lang/String;)Ljava/lang/String;
      15: checkcast     #26                 // class java/lang/CharSequence
      18: invokestatic  #30                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
      21: checkcast     #32                 // class java/lang/Iterable
      24: astore_2
      25: astore        13
      27: iconst_0
      28: istore_3
      29: aload_2
      30: astore        4
      32: new           #34                 // class java/util/ArrayList
      35: dup
      36: aload_2
      37: bipush        10
      39: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
      45: checkcast     #45                 // class java/util/Collection
      48: astore        5
      50: iconst_0
      51: istore        6
      53: aload         4
      55: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        7
      62: aload         7
      64: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          173
      72: aload         7
      74: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        8
      81: aload         5
      83: aload         8
      85: checkcast     #61                 // class java/lang/String
      88: astore        9
      90: astore        14
      92: iconst_0
      93: istore        10
      95: aload         9
      97: checkcast     #26                 // class java/lang/CharSequence
     100: iconst_1
     101: anewarray     #61                 // class java/lang/String
     104: astore        11
     106: aload         11
     108: iconst_0
     109: ldc           #63                 // String  ->
     111: aastore
     112: aload         11
     114: iconst_0
     115: iconst_0
     116: bipush        6
     118: aconst_null
     119: invokestatic  #67                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     122: astore        12
     124: getstatic     #71                 // Field Companion:Lcom/codelicia/advent2021/Day05$Companion;
     127: aload         12
     129: iconst_0
     130: invokeinterface #77,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     135: checkcast     #61                 // class java/lang/String
     138: invokestatic  #83                 // Method com/codelicia/advent2021/Day05$Companion.access$Vent:(Lcom/codelicia/advent2021/Day05$Companion;Ljava/lang/String;)Lkotlin/Pair;
     141: getstatic     #71                 // Field Companion:Lcom/codelicia/advent2021/Day05$Companion;
     144: aload         12
     146: iconst_1
     147: invokeinterface #77,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     152: checkcast     #61                 // class java/lang/String
     155: invokestatic  #83                 // Method com/codelicia/advent2021/Day05$Companion.access$Vent:(Lcom/codelicia/advent2021/Day05$Companion;Ljava/lang/String;)Lkotlin/Pair;
     158: invokestatic  #89                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     161: aload         14
     163: swap
     164: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     169: pop
     170: goto          62
     173: aload         5
     175: checkcast     #73                 // class java/util/List
     178: nop
     179: aload         13
     181: swap
     182: putfield      #97                 // Field vents:Ljava/util/List;
     185: return

  public final int part1();
    Code:
       0: aload_0
       1: aload_0
       2: invokedynamic #135,  0            // InvokeDynamic #0:invoke:(Lcom/codelicia/advent2021/Day05;)Lkotlin/jvm/functions/Function1;
       7: invokespecial #139                // Method overlaps:(Lkotlin/jvm/functions/Function1;)I
      10: ireturn

  public final int part2();
    Code:
       0: aload_0
       1: invokedynamic #148,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
       6: invokespecial #139                // Method overlaps:(Lkotlin/jvm/functions/Function1;)I
       9: ireturn

  private final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> diagonalRange(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: aload_1
       1: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #153                // class kotlin/Pair
       7: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      10: checkcast     #161                // class java/lang/Number
      13: invokevirtual #164                // Method java/lang/Number.intValue:()I
      16: aload_1
      17: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      20: checkcast     #153                // class kotlin/Pair
      23: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      26: checkcast     #161                // class java/lang/Number
      29: invokevirtual #164                // Method java/lang/Number.intValue:()I
      32: if_icmpge     49
      35: aload_0
      36: aload_1
      37: invokespecial #168                // Method horizontalRange:(Lkotlin/Pair;)Lkotlin/ranges/IntRange;
      40: checkcast     #170                // class kotlin/ranges/IntProgression
      43: invokestatic  #176                // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;
      46: goto          57
      49: aload_0
      50: aload_1
      51: invokespecial #168                // Method horizontalRange:(Lkotlin/Pair;)Lkotlin/ranges/IntRange;
      54: checkcast     #170                // class kotlin/ranges/IntProgression
      57: checkcast     #32                 // class java/lang/Iterable
      60: aload_1
      61: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      64: checkcast     #153                // class kotlin/Pair
      67: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      70: checkcast     #161                // class java/lang/Number
      73: invokevirtual #164                // Method java/lang/Number.intValue:()I
      76: aload_1
      77: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      80: checkcast     #153                // class kotlin/Pair
      83: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      86: checkcast     #161                // class java/lang/Number
      89: invokevirtual #164                // Method java/lang/Number.intValue:()I
      92: if_icmpge     109
      95: aload_0
      96: aload_1
      97: invokespecial #179                // Method verticalRange:(Lkotlin/Pair;)Lkotlin/ranges/IntRange;
     100: checkcast     #170                // class kotlin/ranges/IntProgression
     103: invokestatic  #176                // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;
     106: goto          117
     109: aload_0
     110: aload_1
     111: invokespecial #179                // Method verticalRange:(Lkotlin/Pair;)Lkotlin/ranges/IntRange;
     114: checkcast     #170                // class kotlin/ranges/IntProgression
     117: checkcast     #32                 // class java/lang/Iterable
     120: invokestatic  #183                // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
     123: areturn

  private final kotlin.ranges.IntRange horizontalRange(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: new           #188                // class kotlin/ranges/IntRange
       3: dup
       4: aload_1
       5: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       8: checkcast     #153                // class kotlin/Pair
      11: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      14: checkcast     #161                // class java/lang/Number
      17: invokevirtual #164                // Method java/lang/Number.intValue:()I
      20: aload_1
      21: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      24: checkcast     #153                // class kotlin/Pair
      27: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      30: checkcast     #161                // class java/lang/Number
      33: invokevirtual #164                // Method java/lang/Number.intValue:()I
      36: invokestatic  #194                // Method java/lang/Math.min:(II)I
      39: aload_1
      40: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      43: checkcast     #153                // class kotlin/Pair
      46: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      49: checkcast     #161                // class java/lang/Number
      52: invokevirtual #164                // Method java/lang/Number.intValue:()I
      55: aload_1
      56: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      59: checkcast     #153                // class kotlin/Pair
      62: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      65: checkcast     #161                // class java/lang/Number
      68: invokevirtual #164                // Method java/lang/Number.intValue:()I
      71: invokestatic  #197                // Method java/lang/Math.max:(II)I
      74: invokespecial #200                // Method kotlin/ranges/IntRange."<init>":(II)V
      77: areturn

  private final kotlin.ranges.IntRange verticalRange(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: new           #188                // class kotlin/ranges/IntRange
       3: dup
       4: aload_1
       5: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       8: checkcast     #153                // class kotlin/Pair
      11: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      14: checkcast     #161                // class java/lang/Number
      17: invokevirtual #164                // Method java/lang/Number.intValue:()I
      20: aload_1
      21: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      24: checkcast     #153                // class kotlin/Pair
      27: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      30: checkcast     #161                // class java/lang/Number
      33: invokevirtual #164                // Method java/lang/Number.intValue:()I
      36: invokestatic  #194                // Method java/lang/Math.min:(II)I
      39: aload_1
      40: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      43: checkcast     #153                // class kotlin/Pair
      46: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      49: checkcast     #161                // class java/lang/Number
      52: invokevirtual #164                // Method java/lang/Number.intValue:()I
      55: aload_1
      56: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      59: checkcast     #153                // class kotlin/Pair
      62: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      65: checkcast     #161                // class java/lang/Number
      68: invokevirtual #164                // Method java/lang/Number.intValue:()I
      71: invokestatic  #197                // Method java/lang/Math.max:(II)I
      74: invokespecial #200                // Method kotlin/ranges/IntRange."<init>":(II)V
      77: areturn

  private final boolean isDiagonal(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: aload_1
       1: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #153                // class kotlin/Pair
       7: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      10: checkcast     #161                // class java/lang/Number
      13: invokevirtual #164                // Method java/lang/Number.intValue:()I
      16: aload_1
      17: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      20: checkcast     #153                // class kotlin/Pair
      23: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      26: checkcast     #161                // class java/lang/Number
      29: invokevirtual #164                // Method java/lang/Number.intValue:()I
      32: if_icmpeq     74
      35: aload_1
      36: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      39: checkcast     #153                // class kotlin/Pair
      42: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      45: checkcast     #161                // class java/lang/Number
      48: invokevirtual #164                // Method java/lang/Number.intValue:()I
      51: aload_1
      52: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      55: checkcast     #153                // class kotlin/Pair
      58: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      61: checkcast     #161                // class java/lang/Number
      64: invokevirtual #164                // Method java/lang/Number.intValue:()I
      67: if_icmpeq     74
      70: iconst_1
      71: goto          75
      74: iconst_0
      75: ireturn

  private final boolean isHorizontal(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: aload_1
       1: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #153                // class kotlin/Pair
       7: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      10: checkcast     #161                // class java/lang/Number
      13: invokevirtual #164                // Method java/lang/Number.intValue:()I
      16: aload_1
      17: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      20: checkcast     #153                // class kotlin/Pair
      23: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      26: checkcast     #161                // class java/lang/Number
      29: invokevirtual #164                // Method java/lang/Number.intValue:()I
      32: if_icmpeq     39
      35: iconst_1
      36: goto          40
      39: iconst_0
      40: ireturn

  private final boolean isVertical(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: aload_1
       1: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #153                // class kotlin/Pair
       7: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      10: checkcast     #161                // class java/lang/Number
      13: invokevirtual #164                // Method java/lang/Number.intValue:()I
      16: aload_1
      17: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      20: checkcast     #153                // class kotlin/Pair
      23: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      26: checkcast     #161                // class java/lang/Number
      29: invokevirtual #164                // Method java/lang/Number.intValue:()I
      32: if_icmpeq     39
      35: iconst_1
      36: goto          40
      39: iconst_0
      40: ireturn

  private final int overlaps(kotlin.jvm.functions.Function1<? super kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>, java.lang.Boolean>);
    Code:
       0: aload_0
       1: getfield      #97                 // Field vents:Ljava/util/List;
       4: checkcast     #32                 // class java/lang/Iterable
       7: astore_2
       8: iconst_0
       9: istore_3
      10: aload_2
      11: astore        4
      13: new           #34                 // class java/util/ArrayList
      16: dup
      17: aload_2
      18: bipush        10
      20: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      23: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
      26: checkcast     #45                 // class java/util/Collection
      29: astore        5
      31: iconst_0
      32: istore        6
      34: aload         4
      36: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          571
      53: aload         7
      55: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        8
      62: aload         5
      64: aload         8
      66: checkcast     #153                // class kotlin/Pair
      69: astore        9
      71: astore        21
      73: iconst_0
      74: istore        10
      76: nop
      77: aload_1
      78: aload         9
      80: invokeinterface #214,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      85: checkcast     #216                // class java/lang/Boolean
      88: invokevirtual #219                // Method java/lang/Boolean.booleanValue:()Z
      91: ifeq          100
      94: invokestatic  #223                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      97: goto          558
     100: aload_0
     101: aload         9
     103: invokespecial #225                // Method isDiagonal:(Lkotlin/Pair;)Z
     106: ifeq          255
     109: aload_0
     110: aload         9
     112: invokespecial #227                // Method diagonalRange:(Lkotlin/Pair;)Ljava/util/List;
     115: checkcast     #32                 // class java/lang/Iterable
     118: astore        11
     120: iconst_0
     121: istore        12
     123: aload         11
     125: astore        13
     127: new           #34                 // class java/util/ArrayList
     130: dup
     131: aload         11
     133: bipush        10
     135: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     138: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
     141: checkcast     #45                 // class java/util/Collection
     144: astore        14
     146: iconst_0
     147: istore        15
     149: aload         13
     151: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     156: astore        16
     158: aload         16
     160: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     165: ifeq          246
     168: aload         16
     170: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     175: astore        17
     177: aload         14
     179: aload         17
     181: checkcast     #153                // class kotlin/Pair
     184: astore        18
     186: astore        19
     188: iconst_0
     189: istore        20
     191: new           #229                // class java/lang/StringBuilder
     194: dup
     195: invokespecial #230                // Method java/lang/StringBuilder."<init>":()V
     198: aload         18
     200: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     203: checkcast     #161                // class java/lang/Number
     206: invokevirtual #164                // Method java/lang/Number.intValue:()I
     209: invokevirtual #234                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     212: bipush        44
     214: invokevirtual #237                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     217: aload         18
     219: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     222: checkcast     #161                // class java/lang/Number
     225: invokevirtual #164                // Method java/lang/Number.intValue:()I
     228: invokevirtual #234                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     231: invokevirtual #241                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     234: aload         19
     236: swap
     237: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     242: pop
     243: goto          158
     246: aload         14
     248: checkcast     #73                 // class java/util/List
     251: nop
     252: goto          558
     255: aload_0
     256: aload         9
     258: invokespecial #243                // Method isHorizontal:(Lkotlin/Pair;)Z
     261: ifeq          405
     264: aload_0
     265: aload         9
     267: invokespecial #168                // Method horizontalRange:(Lkotlin/Pair;)Lkotlin/ranges/IntRange;
     270: checkcast     #32                 // class java/lang/Iterable
     273: astore        11
     275: iconst_0
     276: istore        12
     278: aload         11
     280: astore        13
     282: new           #34                 // class java/util/ArrayList
     285: dup
     286: aload         11
     288: bipush        10
     290: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     293: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
     296: checkcast     #45                 // class java/util/Collection
     299: astore        14
     301: iconst_0
     302: istore        15
     304: aload         13
     306: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     311: astore        16
     313: aload         16
     315: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     320: ifeq          396
     323: aload         16
     325: checkcast     #245                // class kotlin/collections/IntIterator
     328: invokevirtual #248                // Method kotlin/collections/IntIterator.nextInt:()I
     331: istore        17
     333: aload         14
     335: iload         17
     337: istore        18
     339: astore        19
     341: iconst_0
     342: istore        20
     344: new           #229                // class java/lang/StringBuilder
     347: dup
     348: invokespecial #230                // Method java/lang/StringBuilder."<init>":()V
     351: iload         18
     353: invokevirtual #234                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     356: bipush        44
     358: invokevirtual #237                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     361: aload         9
     363: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     366: checkcast     #153                // class kotlin/Pair
     369: invokevirtual #159                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     372: checkcast     #161                // class java/lang/Number
     375: invokevirtual #164                // Method java/lang/Number.intValue:()I
     378: invokevirtual #234                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     381: invokevirtual #241                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     384: aload         19
     386: swap
     387: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     392: pop
     393: goto          313
     396: aload         14
     398: checkcast     #73                 // class java/util/List
     401: nop
     402: goto          558
     405: aload_0
     406: aload         9
     408: invokespecial #250                // Method isVertical:(Lkotlin/Pair;)Z
     411: ifeq          555
     414: aload_0
     415: aload         9
     417: invokespecial #179                // Method verticalRange:(Lkotlin/Pair;)Lkotlin/ranges/IntRange;
     420: checkcast     #32                 // class java/lang/Iterable
     423: astore        11
     425: iconst_0
     426: istore        12
     428: aload         11
     430: astore        13
     432: new           #34                 // class java/util/ArrayList
     435: dup
     436: aload         11
     438: bipush        10
     440: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     443: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
     446: checkcast     #45                 // class java/util/Collection
     449: astore        14
     451: iconst_0
     452: istore        15
     454: aload         13
     456: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     461: astore        16
     463: aload         16
     465: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     470: ifeq          546
     473: aload         16
     475: checkcast     #245                // class kotlin/collections/IntIterator
     478: invokevirtual #248                // Method kotlin/collections/IntIterator.nextInt:()I
     481: istore        17
     483: aload         14
     485: iload         17
     487: istore        18
     489: astore        19
     491: iconst_0
     492: istore        20
     494: new           #229                // class java/lang/StringBuilder
     497: dup
     498: invokespecial #230                // Method java/lang/StringBuilder."<init>":()V
     501: aload         9
     503: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     506: checkcast     #153                // class kotlin/Pair
     509: invokevirtual #156                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     512: checkcast     #161                // class java/lang/Number
     515: invokevirtual #164                // Method java/lang/Number.intValue:()I
     518: invokevirtual #234                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     521: bipush        44
     523: invokevirtual #237                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     526: iload         18
     528: invokevirtual #234                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     531: invokevirtual #241                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     534: aload         19
     536: swap
     537: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     542: pop
     543: goto          463
     546: aload         14
     548: checkcast     #73                 // class java/util/List
     551: nop
     552: goto          558
     555: invokestatic  #223                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     558: nop
     559: aload         21
     561: swap
     562: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     567: pop
     568: goto          43
     571: aload         5
     573: checkcast     #73                 // class java/util/List
     576: nop
     577: checkcast     #32                 // class java/lang/Iterable
     580: invokestatic  #254                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     583: checkcast     #32                 // class java/lang/Iterable
     586: astore_2
     587: nop
     588: iconst_0
     589: istore_3
     590: new           #256                // class com/codelicia/advent2021/Day05$overlaps$$inlined$groupingBy$1
     593: dup
     594: aload_2
     595: invokespecial #259                // Method com/codelicia/advent2021/Day05$overlaps$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
     598: checkcast     #261                // class kotlin/collections/Grouping
     601: invokestatic  #267                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
     604: astore_2
     605: nop
     606: iconst_0
     607: istore_3
     608: aload_2
     609: invokeinterface #272,  1          // InterfaceMethod java/util/Map.isEmpty:()Z
     614: ifeq          621
     617: iconst_0
     618: goto          699
     621: iconst_0
     622: istore        4
     624: aload_2
     625: invokeinterface #276,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     630: invokeinterface #279,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     635: astore        5
     637: aload         5
     639: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     644: ifeq          697
     647: aload         5
     649: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     654: checkcast     #281                // class java/util/Map$Entry
     657: astore        6
     659: aload         6
     661: astore        7
     663: iconst_0
     664: istore        8
     666: aload         7
     668: invokeinterface #284,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     673: checkcast     #161                // class java/lang/Number
     676: invokevirtual #164                // Method java/lang/Number.intValue:()I
     679: iconst_1
     680: if_icmple     687
     683: iconst_1
     684: goto          688
     687: iconst_0
     688: ifeq          637
     691: iinc          4, 1
     694: goto          637
     697: iload         4
     699: ireturn

  private static final boolean part1$lambda$1(com.codelicia.advent2021.Day05, kotlin.Pair);
    Code:
       0: aload_1
       1: ldc_w         #303                // String vent
       4: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: aload_1
       9: invokespecial #225                // Method isDiagonal:(Lkotlin/Pair;)Z
      12: ireturn

  private static final boolean part2$lambda$2(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc_w         #305                // String it
       4: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_0
       8: ireturn

  static {};
    Code:
       0: new           #79                 // class com/codelicia/advent2021/Day05$Companion
       3: dup
       4: aconst_null
       5: invokespecial #309                // Method com/codelicia/advent2021/Day05$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #71                 // Field Companion:Lcom/codelicia/advent2021/Day05$Companion;
      11: return
}

Compiled from "_Collections.kt"
public final class com.codelicia.advent2021.Day05$overlaps$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.String, java.lang.String> {
  final java.lang.Iterable $this_groupingBy;

  public com.codelicia.advent2021.Day05$overlaps$$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.String> 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.String keyOf(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #37                 // class java/lang/String
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: areturn
}


package com.codelicia.advent2021

class Day16(val input: String) {

    private fun hexToBinary(input: String): List<Char> =
        input.map { it.digitToInt(16).toString(2).padStart(4, '0') }.flatMap { it.toList() }

    private var transmission: Iterator<Char> = hexToBinary(input).iterator()

    fun Iterator<Char>.next(size: Int): String =
        (1..size).map { next() }.joinToString("")

    fun part1(): Long = getPacket(transmission).first

    fun part2(): Long = getPacket(transmission).second

    // Version -> Count
    private fun getPacket(transmission: Iterator<Char>): Pair<Long, Long> {
        val subPackets = mutableListOf<Long>()

        val version = transmission.next(3).toInt(2)
        val typeId = transmission.next(3).toInt(2)

        var versionSum = version.toLong()

        when (typeId) {
            4 -> {
                var keepCounting = true;
                var count = ""
                while (keepCounting) {
                    val lastBit = transmission.next(1)
                    if (lastBit == "0") keepCounting = false;

                    val rest = transmission.next(4)
                    count += rest
                }
                subPackets.add(count.toLong(2))
            }

            else -> {
                val type = transmission.next(1).toInt(2)
                when (type) {
                    0 -> { // 15
                        val subPacketsLength = transmission.next(15).toInt(2)

                        val subPacketBits = transmission.next(subPacketsLength).toCharArray()
                        val iterator = subPacketBits.iterator()

                        while (iterator.hasNext()) {
                            val p = getPacket(iterator)
                            versionSum += p.first
                            subPackets.add(p.second)
                        }
                        return versionSum to subPackets.operateBy(typeId)
                    }
                    1 -> { // 11
                        val subPacketsLength = transmission.next(11).toInt(2)

                        repeat (subPacketsLength) {
                            val p = getPacket(transmission)
                            versionSum += p.first
                            subPackets.add(p.second)
                        }
                        return versionSum to subPackets.operateBy(typeId)
                    }
                }
            }
        }

        return versionSum to subPackets.operateBy(typeId)
    }

    fun MutableList<Long>.operateBy(id: Int) =
        when (id) {
            0 -> sumOf { it }
            1 -> reduce { acc, cur -> acc * cur }
            2 -> minOf { it }
            3 -> maxOf { it }
            5 -> if (this[0] > this[1]) 1 else 0
            6 -> if (this[0] < this[1]) 1 else 0
            7 -> if (this[0] == this[1]) 1 else 0
            else -> first()
        }
}

Compiled from "Day16.kt"
public final class com.codelicia.advent2021.Day16 {
  private final java.lang.String input;

  private java.util.Iterator<java.lang.Character> transmission;

  public com.codelicia.advent2021.Day16(java.lang.String);
    Code:
       0: aload_1
       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: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #21                 // Field input:Ljava/lang/String;
      15: aload_0
      16: aload_0
      17: aload_0
      18: getfield      #21                 // Field input:Ljava/lang/String;
      21: invokespecial #25                 // Method hexToBinary:(Ljava/lang/String;)Ljava/util/List;
      24: invokeinterface #31,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      29: putfield      #35                 // Field transmission:Ljava/util/Iterator;
      32: return

  public final java.lang.String getInput();
    Code:
       0: aload_0
       1: getfield      #21                 // Field input:Ljava/lang/String;
       4: areturn

  private final java.util.List<java.lang.Character> hexToBinary(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #42                 // class java/lang/CharSequence
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #44                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: invokeinterface #48,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      20: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #53                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: iconst_0
      32: istore        7
      34: iload         7
      36: aload         4
      38: invokeinterface #48,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      43: if_icmpge     109
      46: aload         4
      48: iload         7
      50: invokeinterface #57,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      55: istore        8
      57: aload         5
      59: iload         8
      61: istore        9
      63: astore        11
      65: iconst_0
      66: istore        10
      68: iload         9
      70: bipush        16
      72: invokestatic  #63                 // Method kotlin/text/CharsKt.digitToInt:(CI)I
      75: iconst_2
      76: invokestatic  #67                 // Method kotlin/text/CharsKt.checkRadix:(I)I
      79: invokestatic  #73                 // Method java/lang/Integer.toString:(II)Ljava/lang/String;
      82: dup
      83: ldc           #75                 // String toString(...)
      85: invokestatic  #78                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      88: iconst_4
      89: bipush        48
      91: invokestatic  #84                 // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;
      94: aload         11
      96: swap
      97: invokeinterface #88,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     102: pop
     103: iinc          7, 1
     106: goto          34
     109: aload         5
     111: checkcast     #27                 // class java/util/List
     114: nop
     115: checkcast     #90                 // class java/lang/Iterable
     118: astore_2
     119: nop
     120: iconst_0
     121: istore_3
     122: aload_2
     123: astore        4
     125: new           #44                 // class java/util/ArrayList
     128: dup
     129: invokespecial #91                 // Method java/util/ArrayList."<init>":()V
     132: checkcast     #53                 // class java/util/Collection
     135: astore        5
     137: iconst_0
     138: istore        6
     140: aload         4
     142: invokeinterface #92,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     147: astore        7
     149: aload         7
     151: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     156: ifeq          202
     159: aload         7
     161: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     166: astore        8
     168: aload         8
     170: checkcast     #104                // class java/lang/String
     173: astore        9
     175: iconst_0
     176: istore        10
     178: aload         9
     180: checkcast     #42                 // class java/lang/CharSequence
     183: invokestatic  #108                // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;
     186: checkcast     #90                 // class java/lang/Iterable
     189: astore        9
     191: aload         5
     193: aload         9
     195: invokestatic  #114                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     198: pop
     199: goto          149
     202: aload         5
     204: checkcast     #27                 // class java/util/List
     207: nop
     208: areturn

  public final java.lang.String next(java.util.Iterator<java.lang.Character>, int);
    Code:
       0: aload_1
       1: ldc           #139                // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #141                // class kotlin/ranges/IntRange
       9: dup
      10: iconst_1
      11: iload_2
      12: invokespecial #144                // Method kotlin/ranges/IntRange."<init>":(II)V
      15: checkcast     #90                 // class java/lang/Iterable
      18: astore_3
      19: iconst_0
      20: istore        4
      22: aload_3
      23: astore        5
      25: new           #44                 // class java/util/ArrayList
      28: dup
      29: aload_3
      30: bipush        10
      32: invokestatic  #148                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      35: invokespecial #51                 // Method java/util/ArrayList."<init>":(I)V
      38: checkcast     #53                 // class java/util/Collection
      41: astore        6
      43: iconst_0
      44: istore        7
      46: aload         5
      48: invokeinterface #92,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      53: astore        8
      55: aload         8
      57: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      62: ifeq          113
      65: aload         8
      67: checkcast     #150                // class kotlin/collections/IntIterator
      70: invokevirtual #153                // Method kotlin/collections/IntIterator.nextInt:()I
      73: istore        9
      75: aload         6
      77: iload         9
      79: istore        10
      81: astore        12
      83: iconst_0
      84: istore        11
      86: aload_1
      87: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      92: checkcast     #155                // class java/lang/Character
      95: invokevirtual #159                // Method java/lang/Character.charValue:()C
      98: invokestatic  #163                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     101: aload         12
     103: swap
     104: invokeinterface #88,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     109: pop
     110: goto          55
     113: aload         6
     115: checkcast     #27                 // class java/util/List
     118: nop
     119: checkcast     #90                 // class java/lang/Iterable
     122: ldc           #165                // String
     124: checkcast     #42                 // class java/lang/CharSequence
     127: aconst_null
     128: aconst_null
     129: iconst_0
     130: aconst_null
     131: aconst_null
     132: bipush        62
     134: aconst_null
     135: invokestatic  #169                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     138: areturn

  public final long part1();
    Code:
       0: aload_0
       1: aload_0
       2: getfield      #35                 // Field transmission:Ljava/util/Iterator;
       5: invokespecial #178                // Method getPacket:(Ljava/util/Iterator;)Lkotlin/Pair;
       8: invokevirtual #183                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      11: checkcast     #185                // class java/lang/Number
      14: invokevirtual #188                // Method java/lang/Number.longValue:()J
      17: lreturn

  public final long part2();
    Code:
       0: aload_0
       1: aload_0
       2: getfield      #35                 // Field transmission:Ljava/util/Iterator;
       5: invokespecial #178                // Method getPacket:(Ljava/util/Iterator;)Lkotlin/Pair;
       8: invokevirtual #192                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      11: checkcast     #185                // class java/lang/Number
      14: invokevirtual #188                // Method java/lang/Number.longValue:()J
      17: lreturn

  private final kotlin.Pair<java.lang.Long, java.lang.Long> getPacket(java.util.Iterator<java.lang.Character>);
    Code:
       0: new           #44                 // class java/util/ArrayList
       3: dup
       4: invokespecial #91                 // Method java/util/ArrayList."<init>":()V
       7: checkcast     #27                 // class java/util/List
      10: astore_2
      11: aload_0
      12: aload_1
      13: iconst_3
      14: invokevirtual #195                // Method next:(Ljava/util/Iterator;I)Ljava/lang/String;
      17: iconst_2
      18: invokestatic  #67                 // Method kotlin/text/CharsKt.checkRadix:(I)I
      21: invokestatic  #199                // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I
      24: istore_3
      25: aload_0
      26: aload_1
      27: iconst_3
      28: invokevirtual #195                // Method next:(Ljava/util/Iterator;I)Ljava/lang/String;
      31: iconst_2
      32: invokestatic  #67                 // Method kotlin/text/CharsKt.checkRadix:(I)I
      35: invokestatic  #199                // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I
      38: istore        4
      40: lconst_0
      41: lstore        12
      43: iload_3
      44: i2l
      45: lstore        12
      47: iload         4
      49: iconst_4
      50: if_icmpne     141
      53: iconst_1
      54: istore        5
      56: ldc           #165                // String
      58: astore        6
      60: iload         5
      62: ifeq          119
      65: aload_0
      66: aload_1
      67: iconst_1
      68: invokevirtual #195                // Method next:(Ljava/util/Iterator;I)Ljava/lang/String;
      71: astore        7
      73: aload         7
      75: ldc           #201                // String 0
      77: invokestatic  #205                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      80: ifeq          86
      83: iconst_0
      84: istore        5
      86: aload_0
      87: aload_1
      88: iconst_4
      89: invokevirtual #195                // Method next:(Ljava/util/Iterator;I)Ljava/lang/String;
      92: astore        8
      94: new           #207                // class java/lang/StringBuilder
      97: dup
      98: invokespecial #208                // Method java/lang/StringBuilder."<init>":()V
     101: aload         6
     103: invokevirtual #212                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     106: aload         8
     108: invokevirtual #212                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     111: invokevirtual #214                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     114: astore        6
     116: goto          60
     119: aload_2
     120: aload         6
     122: iconst_2
     123: invokestatic  #67                 // Method kotlin/text/CharsKt.checkRadix:(I)I
     126: invokestatic  #220                // Method java/lang/Long.parseLong:(Ljava/lang/String;I)J
     129: invokestatic  #223                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     132: invokeinterface #224,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     137: pop
     138: goto          384
     141: aload_0
     142: aload_1
     143: iconst_1
     144: invokevirtual #195                // Method next:(Ljava/util/Iterator;I)Ljava/lang/String;
     147: iconst_2
     148: invokestatic  #67                 // Method kotlin/text/CharsKt.checkRadix:(I)I
     151: invokestatic  #199                // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I
     154: istore        5
     156: iload         5
     158: tableswitch   { // 0 to 1
                     0: 180
                     1: 290
               default: 384
          }
     180: aload_0
     181: aload_1
     182: bipush        15
     184: invokevirtual #195                // Method next:(Ljava/util/Iterator;I)Ljava/lang/String;
     187: iconst_2
     188: invokestatic  #67                 // Method kotlin/text/CharsKt.checkRadix:(I)I
     191: invokestatic  #199                // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I
     194: istore        7
     196: aload_0
     197: aload_1
     198: iload         7
     200: invokevirtual #195                // Method next:(Ljava/util/Iterator;I)Ljava/lang/String;
     203: invokevirtual #228                // Method java/lang/String.toCharArray:()[C
     206: dup
     207: ldc           #230                // String toCharArray(...)
     209: invokestatic  #78                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     212: astore        8
     214: aload         8
     216: invokestatic  #235                // Method kotlin/jvm/internal/ArrayIteratorsKt.iterator:([C)Lkotlin/collections/CharIterator;
     219: astore        9
     221: aload         9
     223: invokevirtual #238                // Method kotlin/collections/CharIterator.hasNext:()Z
     226: ifeq          271
     229: aload_0
     230: aload         9
     232: checkcast     #94                 // class java/util/Iterator
     235: invokespecial #178                // Method getPacket:(Ljava/util/Iterator;)Lkotlin/Pair;
     238: astore        10
     240: lload         12
     242: aload         10
     244: invokevirtual #183                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     247: checkcast     #185                // class java/lang/Number
     250: invokevirtual #188                // Method java/lang/Number.longValue:()J
     253: ladd
     254: lstore        12
     256: aload_2
     257: aload         10
     259: invokevirtual #192                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     262: invokeinterface #224,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     267: pop
     268: goto          221
     271: lload         12
     273: invokestatic  #223                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     276: aload_0
     277: aload_2
     278: iload         4
     280: invokevirtual #242                // Method operateBy:(Ljava/util/List;I)J
     283: invokestatic  #223                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     286: invokestatic  #248                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     289: areturn
     290: aload_0
     291: aload_1
     292: bipush        11
     294: invokevirtual #195                // Method next:(Ljava/util/Iterator;I)Ljava/lang/String;
     297: iconst_2
     298: invokestatic  #67                 // Method kotlin/text/CharsKt.checkRadix:(I)I
     301: invokestatic  #199                // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I
     304: istore        7
     306: iconst_0
     307: istore        8
     309: iload         8
     311: iload         7
     313: if_icmpge     365
     316: iload         8
     318: istore        9
     320: iconst_0
     321: istore        10
     323: aload_0
     324: aload_1
     325: invokespecial #178                // Method getPacket:(Ljava/util/Iterator;)Lkotlin/Pair;
     328: astore        11
     330: lload         12
     332: aload         11
     334: invokevirtual #183                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     337: checkcast     #185                // class java/lang/Number
     340: invokevirtual #188                // Method java/lang/Number.longValue:()J
     343: ladd
     344: lstore        12
     346: aload_2
     347: aload         11
     349: invokevirtual #192                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     352: invokeinterface #224,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     357: pop
     358: nop
     359: iinc          8, 1
     362: goto          309
     365: lload         12
     367: invokestatic  #223                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     370: aload_0
     371: aload_2
     372: iload         4
     374: invokevirtual #242                // Method operateBy:(Ljava/util/List;I)J
     377: invokestatic  #223                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     380: invokestatic  #248                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     383: areturn
     384: lload         12
     386: invokestatic  #223                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     389: aload_0
     390: aload_2
     391: iload         4
     393: invokevirtual #242                // Method operateBy:(Ljava/util/List;I)J
     396: invokestatic  #223                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     399: invokestatic  #248                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     402: areturn

  public final long operateBy(java.util.List<java.lang.Long>, int);
    Code:
       0: aload_1
       1: ldc           #139                // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_2
       7: tableswitch   { // 0 to 7
                     0: 52
                     1: 123
                     2: 231
                     3: 334
                     4: 551
                     5: 437
                     6: 475
                     7: 513
               default: 551
          }
      52: aload_1
      53: checkcast     #90                 // class java/lang/Iterable
      56: astore_3
      57: lconst_0
      58: lstore        4
      60: aload_3
      61: invokeinterface #92,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      66: astore        6
      68: aload         6
      70: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      75: ifeq          118
      78: aload         6
      80: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      85: astore        7
      87: lload         4
      89: aload         7
      91: checkcast     #185                // class java/lang/Number
      94: invokevirtual #188                // Method java/lang/Number.longValue:()J
      97: lstore        8
      99: lstore        15
     101: iconst_0
     102: istore        11
     104: lload         8
     106: lstore        17
     108: lload         15
     110: lload         17
     112: ladd
     113: lstore        4
     115: goto          68
     118: lload         4
     120: goto          561
     123: aload_1
     124: checkcast     #90                 // class java/lang/Iterable
     127: astore_3
     128: iconst_0
     129: istore        4
     131: aload_3
     132: invokeinterface #92,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     137: astore        5
     139: aload         5
     141: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     146: ifne          160
     149: new           #271                // class java/lang/UnsupportedOperationException
     152: dup
     153: ldc_w         #273                // String Empty collection can\'t be reduced.
     156: invokespecial #275                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     159: athrow
     160: aload         5
     162: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     167: astore        6
     169: aload         5
     171: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     176: ifeq          220
     179: aload         6
     181: aload         5
     183: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: checkcast     #185                // class java/lang/Number
     191: invokevirtual #188                // Method java/lang/Number.longValue:()J
     194: lstore        7
     196: checkcast     #185                // class java/lang/Number
     199: invokevirtual #188                // Method java/lang/Number.longValue:()J
     202: lstore        10
     204: iconst_0
     205: istore        12
     207: lload         10
     209: lload         7
     211: lmul
     212: invokestatic  #223                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     215: astore        6
     217: goto          169
     220: aload         6
     222: checkcast     #185                // class java/lang/Number
     225: invokevirtual #188                // Method java/lang/Number.longValue:()J
     228: goto          561
     231: aload_1
     232: checkcast     #90                 // class java/lang/Iterable
     235: invokeinterface #92,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     240: astore        4
     242: aload         4
     244: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     249: ifne          260
     252: new           #277                // class java/util/NoSuchElementException
     255: dup
     256: invokespecial #278                // Method java/util/NoSuchElementException."<init>":()V
     259: athrow
     260: aload         4
     262: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     267: checkcast     #185                // class java/lang/Number
     270: invokevirtual #188                // Method java/lang/Number.longValue:()J
     273: lstore        5
     275: iconst_0
     276: istore        7
     278: lload         5
     280: lstore        8
     282: aload         4
     284: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     289: ifeq          329
     292: aload         4
     294: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     299: checkcast     #185                // class java/lang/Number
     302: invokevirtual #188                // Method java/lang/Number.longValue:()J
     305: lstore        10
     307: iconst_0
     308: istore        12
     310: lload         10
     312: lstore        13
     314: lload         8
     316: lload         13
     318: lcmp
     319: ifle          282
     322: lload         13
     324: lstore        8
     326: goto          282
     329: lload         8
     331: goto          561
     334: aload_1
     335: checkcast     #90                 // class java/lang/Iterable
     338: invokeinterface #92,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     343: astore        4
     345: aload         4
     347: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     352: ifne          363
     355: new           #277                // class java/util/NoSuchElementException
     358: dup
     359: invokespecial #278                // Method java/util/NoSuchElementException."<init>":()V
     362: athrow
     363: aload         4
     365: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     370: checkcast     #185                // class java/lang/Number
     373: invokevirtual #188                // Method java/lang/Number.longValue:()J
     376: lstore        5
     378: iconst_0
     379: istore        7
     381: lload         5
     383: lstore        8
     385: aload         4
     387: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     392: ifeq          432
     395: aload         4
     397: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     402: checkcast     #185                // class java/lang/Number
     405: invokevirtual #188                // Method java/lang/Number.longValue:()J
     408: lstore        10
     410: iconst_0
     411: istore        12
     413: lload         10
     415: lstore        13
     417: lload         8
     419: lload         13
     421: lcmp
     422: ifge          385
     425: lload         13
     427: lstore        8
     429: goto          385
     432: lload         8
     434: goto          561
     437: aload_1
     438: iconst_0
     439: invokeinterface #282,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     444: checkcast     #185                // class java/lang/Number
     447: invokevirtual #188                // Method java/lang/Number.longValue:()J
     450: aload_1
     451: iconst_1
     452: invokeinterface #282,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     457: checkcast     #185                // class java/lang/Number
     460: invokevirtual #188                // Method java/lang/Number.longValue:()J
     463: lcmp
     464: ifle          471
     467: lconst_1
     468: goto          561
     471: lconst_0
     472: goto          561
     475: aload_1
     476: iconst_0
     477: invokeinterface #282,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     482: checkcast     #185                // class java/lang/Number
     485: invokevirtual #188                // Method java/lang/Number.longValue:()J
     488: aload_1
     489: iconst_1
     490: invokeinterface #282,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     495: checkcast     #185                // class java/lang/Number
     498: invokevirtual #188                // Method java/lang/Number.longValue:()J
     501: lcmp
     502: ifge          509
     505: lconst_1
     506: goto          561
     509: lconst_0
     510: goto          561
     513: aload_1
     514: iconst_0
     515: invokeinterface #282,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     520: checkcast     #185                // class java/lang/Number
     523: invokevirtual #188                // Method java/lang/Number.longValue:()J
     526: aload_1
     527: iconst_1
     528: invokeinterface #282,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     533: checkcast     #185                // class java/lang/Number
     536: invokevirtual #188                // Method java/lang/Number.longValue:()J
     539: lcmp
     540: ifne          547
     543: lconst_1
     544: goto          561
     547: lconst_0
     548: goto          561
     551: aload_1
     552: invokestatic  #286                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     555: checkcast     #185                // class java/lang/Number
     558: invokevirtual #188                // Method java/lang/Number.longValue:()J
     561: lreturn
}