package day17

import java.io.File
import kotlin.math.absoluteValue
import kotlin.math.min
import kotlin.math.sqrt

fun parseInput(line: String): Pair<IntRange, IntRange> {
  val rawXRange = line.split("x=")[1].split(",")[0]
  val rawYRange = line.split("y=")[1]
  val (minX, maxX) = rawXRange.split("..").map(String::toInt)
  val (minY, maxY) = rawYRange.split("..").map(String::toInt)
  return minX..maxX to minY..maxY
}

private fun Double.hasDecimals(): Boolean = this % 1.0 != 0.0

/*
* Solving t^2 - (2*C + 1)*t + 2*Y = 0; where
*  - C is the vertical velocity
*  - Y is any of the valid positions in rangeY
*
* There's probably a better way, but I'm only OK-ish with Maths
*
* Returns a map time => all vertical velocities that will make it to the target area
*/
fun samplingInitialVy(rangeY: IntRange): Map<Int, List<Int>> {
  val minTheoreticalVelocityY = rangeY.minOf { it } // going straight from S0 to SX in one unit of time
  /*
   With the current formula, given an initial Vy, when time = 2*Vy + 1 the vertical space travelled is 0
     - If the target is below the Y axis then in the next 'moment' Vy(t) will be greater than the greatest distance
       from the Y axis which will cause the probe to miss the area
     - If the target is above the Y axis then we are in the same case but one step before reaching the 0 sum. The limit
       in that case will be the greatest distance to the Y axis as any greater speed will be short and then miss the target
   */
  val maxTheoreticalVelocity = rangeY.maxOf { it.absoluteValue } // the furthest distance from the Y axis
  var candidate = minTheoreticalVelocityY // starting with the min velocity possible
  val solutionsByTime = mutableListOf<Pair<Int, Int>>()
  do {
    val b = -((2 * candidate) + 1)
    val squaredB = 1.0 * b * b
    val solutions = mutableListOf<Int>()
    for (y in rangeY) {
      val ac4 = 4 * 2 * y
      if (ac4 > squaredB) continue
      val root = sqrt(squaredB - ac4)
      val localSolutions = listOf(
        (-b + root) / 2,
        (-b - root) / 2
      ).filterNot { it < 0 || it.hasDecimals() }.map { it.toInt() }
      // t can only be a positive integer because:
      //  [a] can't travel back in time
      //  [b] the granularity of the problem is in units of time
      solutions.addAll(localSolutions)
    }
    solutionsByTime.addAll(solutions.associateWith { candidate }.toList())
    candidate += 1;
  } while (candidate <= maxTheoreticalVelocity)
  return solutionsByTime.groupBy { it.first }.mapValues { (_, v) -> v.map { it.second } }
}

/*
* Values for initial horizontal velocity Vx, aka Vx(0), are determined by the elapsed time, given that:
*  - Vx(t) = min(0, Vx(t-1) - 1)
*  - After time t,
*       Sx(t) = Vx(0) * min(Vx(0), t) - [1, min(Vx(0), t)) # IMPORTANT, the range is end exclusive
*
* Sx(t) is the distance traveled at the given initial velocity during time t. For the velocity to be
*  considered valid, Sx(t) must belong to rangeX
*/
private fun samplingInitialVxForGivenTime(time: Int, rangeX: IntRange): List<Int> {
  val candidates = (rangeX.first / time)..rangeX.last
  return candidates.filter { vx ->
    val sx = vx * min(vx, time) - (1 until min(vx, time)).sum()
    sx in rangeX
  }
}

fun findAllPossibleSolutions(rangeX: IntRange, rangeY: IntRange): List<Pair<Int, Int>> =
  samplingInitialVy(rangeY).flatMap { (time, vys) ->
    val solutionSpaceForX = samplingInitialVxForGivenTime(time, rangeX)
    solutionSpaceForX.flatMap { vx -> vys.map { vy -> vx to vy } }
  }.distinct()

fun findMaxInitialVerticalVelocity(rangeY: IntRange) =
  samplingInitialVy(rangeY).mapValues { (_, vs) -> vs.maxOf { it } }.maxByOrNull { it.value }!!

fun computeMaxHeight(time: Int, initialVerticalVelocity: Int): Int = (initialVerticalVelocity downTo 0).take(time).sum()

fun main() {
  File("./input/day17.txt").useLines { lines ->
    val areaDefinition = lines.first()
    val (rangeX, rangeY) = parseInput(areaDefinition)
    val (time, maxInitialVerticalSpeed) = findMaxInitialVerticalVelocity(rangeY)
    println(computeMaxHeight(time, maxInitialVerticalSpeed))

    println(findAllPossibleSolutions(rangeX, rangeY).size)
  }
}

Compiled from "Day17.kt"
public final class day17.Day17Kt {
  public static final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> parseInput(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String line
       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: iconst_1
      11: anewarray     #20                 // class java/lang/String
      14: astore_2
      15: aload_2
      16: iconst_0
      17: ldc           #22                 // String x=
      19: aastore
      20: aload_2
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: iconst_1
      30: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      35: checkcast     #18                 // class java/lang/CharSequence
      38: iconst_1
      39: anewarray     #20                 // class java/lang/String
      42: astore_2
      43: aload_2
      44: iconst_0
      45: ldc           #36                 // String ,
      47: aastore
      48: aload_2
      49: iconst_0
      50: iconst_0
      51: bipush        6
      53: aconst_null
      54: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      57: iconst_0
      58: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      63: checkcast     #20                 // class java/lang/String
      66: astore_1
      67: aload_0
      68: checkcast     #18                 // class java/lang/CharSequence
      71: iconst_1
      72: anewarray     #20                 // class java/lang/String
      75: astore_3
      76: aload_3
      77: iconst_0
      78: ldc           #38                 // String y=
      80: aastore
      81: aload_3
      82: iconst_0
      83: iconst_0
      84: bipush        6
      86: aconst_null
      87: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      90: iconst_1
      91: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      96: checkcast     #20                 // class java/lang/String
      99: astore_2
     100: aload_1
     101: checkcast     #18                 // class java/lang/CharSequence
     104: iconst_1
     105: anewarray     #20                 // class java/lang/String
     108: astore        4
     110: aload         4
     112: iconst_0
     113: ldc           #40                 // String ..
     115: aastore
     116: aload         4
     118: iconst_0
     119: iconst_0
     120: bipush        6
     122: aconst_null
     123: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     126: checkcast     #42                 // class java/lang/Iterable
     129: astore        4
     131: iconst_0
     132: istore        5
     134: aload         4
     136: astore        6
     138: new           #44                 // class java/util/ArrayList
     141: dup
     142: aload         4
     144: bipush        10
     146: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     149: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
     152: checkcast     #56                 // class java/util/Collection
     155: astore        7
     157: iconst_0
     158: istore        8
     160: aload         6
     162: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     167: astore        9
     169: aload         9
     171: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     176: ifeq          223
     179: aload         9
     181: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     186: astore        10
     188: aload         7
     190: aload         10
     192: checkcast     #20                 // class java/lang/String
     195: astore        11
     197: astore        16
     199: iconst_0
     200: istore        12
     202: aload         11
     204: invokestatic  #76                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     207: nop
     208: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     211: aload         16
     213: swap
     214: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     219: pop
     220: goto          169
     223: aload         7
     225: checkcast     #30                 // class java/util/List
     228: nop
     229: astore_3
     230: aload_3
     231: iconst_0
     232: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     237: checkcast     #86                 // class java/lang/Number
     240: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     243: istore        4
     245: aload_3
     246: iconst_1
     247: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     252: checkcast     #86                 // class java/lang/Number
     255: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     258: istore        5
     260: aload_2
     261: checkcast     #18                 // class java/lang/CharSequence
     264: iconst_1
     265: anewarray     #20                 // class java/lang/String
     268: astore        7
     270: aload         7
     272: iconst_0
     273: ldc           #40                 // String ..
     275: aastore
     276: aload         7
     278: iconst_0
     279: iconst_0
     280: bipush        6
     282: aconst_null
     283: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     286: checkcast     #42                 // class java/lang/Iterable
     289: astore        7
     291: iconst_0
     292: istore        8
     294: aload         7
     296: astore        9
     298: new           #44                 // class java/util/ArrayList
     301: dup
     302: aload         7
     304: bipush        10
     306: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     309: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
     312: checkcast     #56                 // class java/util/Collection
     315: astore        10
     317: iconst_0
     318: istore        11
     320: aload         9
     322: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     327: astore        12
     329: aload         12
     331: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     336: ifeq          383
     339: aload         12
     341: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     346: astore        13
     348: aload         10
     350: aload         13
     352: checkcast     #20                 // class java/lang/String
     355: astore        14
     357: astore        16
     359: iconst_0
     360: istore        15
     362: aload         14
     364: invokestatic  #76                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     367: nop
     368: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     371: aload         16
     373: swap
     374: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     379: pop
     380: goto          329
     383: aload         10
     385: checkcast     #30                 // class java/util/List
     388: nop
     389: astore        6
     391: aload         6
     393: iconst_0
     394: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     399: checkcast     #86                 // class java/lang/Number
     402: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     405: istore        7
     407: aload         6
     409: iconst_1
     410: invokeinterface #34,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     415: checkcast     #86                 // class java/lang/Number
     418: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     421: istore        8
     423: new           #92                 // class kotlin/ranges/IntRange
     426: dup
     427: iload         4
     429: iload         5
     431: invokespecial #95                 // Method kotlin/ranges/IntRange."<init>":(II)V
     434: new           #92                 // class kotlin/ranges/IntRange
     437: dup
     438: iload         7
     440: iload         8
     442: invokespecial #95                 // Method kotlin/ranges/IntRange."<init>":(II)V
     445: invokestatic  #101                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     448: areturn

  private static final boolean hasDecimals(double);
    Code:
       0: dload_0
       1: dconst_1
       2: drem
       3: dconst_0
       4: dcmpg
       5: ifne          12
       8: iconst_1
       9: goto          13
      12: iconst_0
      13: ifne          20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ireturn

  public static final java.util.Map<java.lang.Integer, java.util.List<java.lang.Integer>> samplingInitialVy(kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: ldc           #132                // String rangeY
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #42                 // class java/lang/Iterable
      10: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      15: astore_3
      16: aload_3
      17: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      22: ifne          33
      25: new           #134                // class java/util/NoSuchElementException
      28: dup
      29: invokespecial #137                // Method java/util/NoSuchElementException."<init>":()V
      32: athrow
      33: aload_3
      34: checkcast     #139                // class kotlin/collections/IntIterator
      37: invokevirtual #142                // Method kotlin/collections/IntIterator.nextInt:()I
      40: istore        4
      42: iconst_0
      43: istore        5
      45: iload         4
      47: istore        4
      49: aload_3
      50: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      55: ifeq          88
      58: aload_3
      59: checkcast     #139                // class kotlin/collections/IntIterator
      62: invokevirtual #142                // Method kotlin/collections/IntIterator.nextInt:()I
      65: istore        5
      67: iconst_0
      68: istore        6
      70: iload         5
      72: istore        5
      74: iload         4
      76: iload         5
      78: if_icmple     49
      81: iload         5
      83: istore        4
      85: goto          49
      88: iload         4
      90: istore_1
      91: aload_0
      92: checkcast     #42                 // class java/lang/Iterable
      95: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     100: astore        4
     102: aload         4
     104: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     109: ifne          120
     112: new           #134                // class java/util/NoSuchElementException
     115: dup
     116: invokespecial #137                // Method java/util/NoSuchElementException."<init>":()V
     119: athrow
     120: aload         4
     122: checkcast     #139                // class kotlin/collections/IntIterator
     125: invokevirtual #142                // Method kotlin/collections/IntIterator.nextInt:()I
     128: istore        5
     130: iconst_0
     131: istore        6
     133: iload         5
     135: invokestatic  #148                // Method java/lang/Math.abs:(I)I
     138: nop
     139: istore        5
     141: aload         4
     143: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     148: ifeq          186
     151: aload         4
     153: checkcast     #139                // class kotlin/collections/IntIterator
     156: invokevirtual #142                // Method kotlin/collections/IntIterator.nextInt:()I
     159: istore        6
     161: iconst_0
     162: istore        7
     164: iload         6
     166: invokestatic  #148                // Method java/lang/Math.abs:(I)I
     169: nop
     170: istore        6
     172: iload         5
     174: iload         6
     176: if_icmpge     141
     179: iload         6
     181: istore        5
     183: goto          141
     186: iload         5
     188: istore_2
     189: iconst_0
     190: istore_3
     191: iload_1
     192: istore_3
     193: new           #44                 // class java/util/ArrayList
     196: dup
     197: invokespecial #149                // Method java/util/ArrayList."<init>":()V
     200: checkcast     #30                 // class java/util/List
     203: astore        4
     205: iconst_2
     206: iload_3
     207: imul
     208: iconst_1
     209: iadd
     210: ineg
     211: istore        5
     213: dconst_1
     214: iload         5
     216: i2d
     217: dmul
     218: iload         5
     220: i2d
     221: dmul
     222: dstore        6
     224: new           #44                 // class java/util/ArrayList
     227: dup
     228: invokespecial #149                // Method java/util/ArrayList."<init>":()V
     231: checkcast     #30                 // class java/util/List
     234: astore        8
     236: aload_0
     237: invokevirtual #152                // Method kotlin/ranges/IntRange.getFirst:()I
     240: istore        9
     242: aload_0
     243: invokevirtual #155                // Method kotlin/ranges/IntRange.getLast:()I
     246: istore        10
     248: iload         9
     250: iload         10
     252: if_icmpgt     570
     255: bipush        8
     257: iload         9
     259: imul
     260: istore        11
     262: iload         11
     264: i2d
     265: dload         6
     267: dcmpl
     268: ifgt          557
     271: dload         6
     273: iload         11
     275: i2d
     276: dsub
     277: invokestatic  #159                // Method java/lang/Math.sqrt:(D)D
     280: dstore        12
     282: iconst_2
     283: anewarray     #161                // class java/lang/Double
     286: astore        15
     288: aload         15
     290: iconst_0
     291: iload         5
     293: ineg
     294: i2d
     295: dload         12
     297: dadd
     298: iconst_2
     299: i2d
     300: ddiv
     301: invokestatic  #164                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     304: aastore
     305: aload         15
     307: iconst_1
     308: iload         5
     310: ineg
     311: i2d
     312: dload         12
     314: dsub
     315: iconst_2
     316: i2d
     317: ddiv
     318: invokestatic  #164                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     321: aastore
     322: aload         15
     324: invokestatic  #168                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     327: checkcast     #42                 // class java/lang/Iterable
     330: astore        15
     332: nop
     333: iconst_0
     334: istore        16
     336: aload         15
     338: astore        17
     340: new           #44                 // class java/util/ArrayList
     343: dup
     344: invokespecial #149                // Method java/util/ArrayList."<init>":()V
     347: checkcast     #56                 // class java/util/Collection
     350: astore        18
     352: iconst_0
     353: istore        19
     355: aload         17
     357: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     362: astore        20
     364: aload         20
     366: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     371: ifeq          432
     374: aload         20
     376: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     381: astore        21
     383: aload         21
     385: checkcast     #86                 // class java/lang/Number
     388: invokevirtual #172                // Method java/lang/Number.doubleValue:()D
     391: dstore        22
     393: iconst_0
     394: istore        24
     396: dload         22
     398: dconst_0
     399: dcmpg
     400: iflt          411
     403: dload         22
     405: invokestatic  #174                // Method hasDecimals:(D)Z
     408: ifeq          415
     411: iconst_1
     412: goto          416
     415: iconst_0
     416: ifne          364
     419: aload         18
     421: aload         21
     423: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     428: pop
     429: goto          364
     432: aload         18
     434: checkcast     #30                 // class java/util/List
     437: nop
     438: checkcast     #42                 // class java/lang/Iterable
     441: astore        15
     443: nop
     444: iconst_0
     445: istore        16
     447: aload         15
     449: astore        17
     451: new           #44                 // class java/util/ArrayList
     454: dup
     455: aload         15
     457: bipush        10
     459: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     462: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
     465: checkcast     #56                 // class java/util/Collection
     468: astore        18
     470: iconst_0
     471: istore        19
     473: aload         17
     475: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     480: astore        20
     482: aload         20
     484: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     489: ifeq          536
     492: aload         20
     494: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     499: astore        21
     501: aload         18
     503: aload         21
     505: checkcast     #86                 // class java/lang/Number
     508: invokevirtual #172                // Method java/lang/Number.doubleValue:()D
     511: dstore        22
     513: astore        30
     515: iconst_0
     516: istore        24
     518: dload         22
     520: d2i
     521: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     524: aload         30
     526: swap
     527: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     532: pop
     533: goto          482
     536: aload         18
     538: checkcast     #30                 // class java/util/List
     541: nop
     542: astore        14
     544: aload         8
     546: aload         14
     548: checkcast     #56                 // class java/util/Collection
     551: invokeinterface #178,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     556: pop
     557: iload         9
     559: iload         10
     561: if_icmpeq     570
     564: iinc          9, 1
     567: goto          255
     570: aload         4
     572: aload         8
     574: checkcast     #42                 // class java/lang/Iterable
     577: astore        9
     579: astore        30
     581: iconst_0
     582: istore        10
     584: new           #180                // class java/util/LinkedHashMap
     587: dup
     588: aload         9
     590: bipush        10
     592: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     595: invokestatic  #185                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     598: bipush        16
     600: invokestatic  #191                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     603: invokespecial #192                // Method java/util/LinkedHashMap."<init>":(I)V
     606: astore        11
     608: aload         9
     610: astore        12
     612: iconst_0
     613: istore        13
     615: aload         12
     617: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     622: astore        14
     624: aload         14
     626: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     631: ifeq          688
     634: aload         14
     636: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     641: astore        15
     643: aload         11
     645: checkcast     #194                // class java/util/Map
     648: aload         15
     650: aload         15
     652: checkcast     #86                 // class java/lang/Number
     655: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     658: istore        16
     660: astore        32
     662: astore        31
     664: iconst_0
     665: istore        17
     667: iload_3
     668: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     671: astore        33
     673: aload         31
     675: aload         32
     677: aload         33
     679: invokeinterface #198,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     684: pop
     685: goto          624
     688: aload         11
     690: checkcast     #194                // class java/util/Map
     693: nop
     694: aload         30
     696: swap
     697: invokestatic  #202                // Method kotlin/collections/MapsKt.toList:(Ljava/util/Map;)Ljava/util/List;
     700: checkcast     #56                 // class java/util/Collection
     703: invokeinterface #178,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     708: pop
     709: iload_3
     710: iconst_1
     711: iadd
     712: istore_3
     713: iload_3
     714: iload_2
     715: if_icmple     205
     718: aload         4
     720: checkcast     #42                 // class java/lang/Iterable
     723: astore        5
     725: iconst_0
     726: istore        6
     728: aload         5
     730: astore        7
     732: new           #180                // class java/util/LinkedHashMap
     735: dup
     736: invokespecial #203                // Method java/util/LinkedHashMap."<init>":()V
     739: checkcast     #194                // class java/util/Map
     742: astore        8
     744: iconst_0
     745: istore        9
     747: aload         7
     749: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     754: astore        10
     756: aload         10
     758: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     763: ifeq          877
     766: aload         10
     768: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     773: astore        11
     775: aload         11
     777: checkcast     #205                // class kotlin/Pair
     780: astore        12
     782: iconst_0
     783: istore        13
     785: aload         12
     787: invokevirtual #207                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     790: checkcast     #86                 // class java/lang/Number
     793: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     796: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     799: astore        14
     801: aload         8
     803: astore        15
     805: iconst_0
     806: istore        16
     808: aload         15
     810: aload         14
     812: invokeinterface #210,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     817: astore        17
     819: aload         17
     821: ifnonnull     856
     824: iconst_0
     825: istore        18
     827: new           #44                 // class java/util/ArrayList
     830: dup
     831: invokespecial #149                // Method java/util/ArrayList."<init>":()V
     834: checkcast     #30                 // class java/util/List
     837: astore        18
     839: aload         15
     841: aload         14
     843: aload         18
     845: invokeinterface #198,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     850: pop
     851: aload         18
     853: goto          858
     856: aload         17
     858: nop
     859: checkcast     #30                 // class java/util/List
     862: astore        12
     864: aload         12
     866: aload         11
     868: invokeinterface #211,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     873: pop
     874: goto          756
     877: aload         8
     879: nop
     880: astore        5
     882: nop
     883: iconst_0
     884: istore        6
     886: aload         5
     888: astore        7
     890: new           #180                // class java/util/LinkedHashMap
     893: dup
     894: aload         5
     896: invokeinterface #214,  1          // InterfaceMethod java/util/Map.size:()I
     901: invokestatic  #185                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     904: invokespecial #192                // Method java/util/LinkedHashMap."<init>":(I)V
     907: checkcast     #194                // class java/util/Map
     910: astore        8
     912: iconst_0
     913: istore        9
     915: aload         7
     917: invokeinterface #218,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     922: checkcast     #42                 // class java/lang/Iterable
     925: astore        10
     927: iconst_0
     928: istore        11
     930: aload         10
     932: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     937: astore        12
     939: aload         12
     941: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     946: ifeq          1136
     949: aload         12
     951: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     956: astore        13
     958: aload         8
     960: aload         13
     962: checkcast     #220                // class java/util/Map$Entry
     965: astore        14
     967: astore        15
     969: iconst_0
     970: istore        16
     972: aload         14
     974: invokeinterface #223,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     979: aload         15
     981: swap
     982: aload         13
     984: checkcast     #220                // class java/util/Map$Entry
     987: astore        17
     989: astore        31
     991: astore        30
     993: iconst_0
     994: istore        18
     996: aload         17
     998: invokeinterface #226,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
    1003: checkcast     #30                 // class java/util/List
    1006: astore        19
    1008: aload         19
    1010: checkcast     #42                 // class java/lang/Iterable
    1013: astore        20
    1015: iconst_0
    1016: istore        21
    1018: aload         20
    1020: astore        22
    1022: new           #44                 // class java/util/ArrayList
    1025: dup
    1026: aload         20
    1028: bipush        10
    1030: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
    1033: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
    1036: checkcast     #56                 // class java/util/Collection
    1039: astore        23
    1041: iconst_0
    1042: istore        24
    1044: aload         22
    1046: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1051: astore        25
    1053: aload         25
    1055: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1060: ifeq          1112
    1063: aload         25
    1065: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1070: astore        26
    1072: aload         23
    1074: aload         26
    1076: checkcast     #205                // class kotlin/Pair
    1079: astore        27
    1081: astore        28
    1083: iconst_0
    1084: istore        29
    1086: aload         27
    1088: invokevirtual #229                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1091: checkcast     #86                 // class java/lang/Number
    1094: invokevirtual #90                 // Method java/lang/Number.intValue:()I
    1097: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1100: aload         28
    1102: swap
    1103: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1108: pop
    1109: goto          1053
    1112: aload         23
    1114: checkcast     #30                 // class java/util/List
    1117: nop
    1118: nop
    1119: astore        32
    1121: aload         30
    1123: aload         31
    1125: aload         32
    1127: invokeinterface #198,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    1132: pop
    1133: goto          939
    1136: aload         8
    1138: nop
    1139: nop
    1140: areturn

  private static final java.util.List<java.lang.Integer> samplingInitialVxForGivenTime(int, kotlin.ranges.IntRange);
    Code:
       0: new           #92                 // class kotlin/ranges/IntRange
       3: dup
       4: aload_1
       5: invokevirtual #152                // Method kotlin/ranges/IntRange.getFirst:()I
       8: iload_0
       9: idiv
      10: aload_1
      11: invokevirtual #155                // Method kotlin/ranges/IntRange.getLast:()I
      14: invokespecial #95                 // Method kotlin/ranges/IntRange."<init>":(II)V
      17: astore_2
      18: aload_2
      19: checkcast     #42                 // class java/lang/Iterable
      22: astore_3
      23: iconst_0
      24: istore        4
      26: aload_3
      27: astore        5
      29: new           #44                 // class java/util/ArrayList
      32: dup
      33: invokespecial #149                // Method java/util/ArrayList."<init>":()V
      36: checkcast     #56                 // class java/util/Collection
      39: astore        6
      41: iconst_0
      42: istore        7
      44: aload         5
      46: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      51: astore        8
      53: aload         8
      55: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          160
      63: aload         8
      65: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: astore        9
      72: aload         9
      74: checkcast     #86                 // class java/lang/Number
      77: invokevirtual #90                 // Method java/lang/Number.intValue:()I
      80: istore        10
      82: iconst_0
      83: istore        11
      85: iload         10
      87: iload         10
      89: iload_0
      90: invokestatic  #292                // Method java/lang/Math.min:(II)I
      93: imul
      94: iconst_1
      95: iload         10
      97: iload_0
      98: invokestatic  #292                // Method java/lang/Math.min:(II)I
     101: invokestatic  #296                // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     104: checkcast     #42                 // class java/lang/Iterable
     107: invokestatic  #300                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     110: isub
     111: istore        12
     113: aload_1
     114: invokevirtual #152                // Method kotlin/ranges/IntRange.getFirst:()I
     117: istore        13
     119: iload         12
     121: aload_1
     122: invokevirtual #155                // Method kotlin/ranges/IntRange.getLast:()I
     125: if_icmpgt     143
     128: iload         13
     130: iload         12
     132: if_icmpgt     139
     135: iconst_1
     136: goto          144
     139: iconst_0
     140: goto          144
     143: iconst_0
     144: ifeq          53
     147: aload         6
     149: aload         9
     151: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     156: pop
     157: goto          53
     160: aload         6
     162: checkcast     #30                 // class java/util/List
     165: nop
     166: areturn

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findAllPossibleSolutions(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: ldc_w         #314                // String rangeX
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: ldc           #132                // String rangeY
      10: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      13: aload_1
      14: invokestatic  #316                // Method samplingInitialVy:(Lkotlin/ranges/IntRange;)Ljava/util/Map;
      17: astore_2
      18: iconst_0
      19: istore_3
      20: aload_2
      21: astore        4
      23: new           #44                 // class java/util/ArrayList
      26: dup
      27: invokespecial #149                // Method java/util/ArrayList."<init>":()V
      30: checkcast     #56                 // class java/util/Collection
      33: astore        5
      35: iconst_0
      36: istore        6
      38: aload         4
      40: invokeinterface #218,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      45: invokeinterface #319,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      50: astore        7
      52: aload         7
      54: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          338
      62: aload         7
      64: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: checkcast     #220                // class java/util/Map$Entry
      72: astore        8
      74: aload         8
      76: astore        9
      78: iconst_0
      79: istore        10
      81: aload         9
      83: invokeinterface #223,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      88: checkcast     #86                 // class java/lang/Number
      91: invokevirtual #90                 // Method java/lang/Number.intValue:()I
      94: istore        11
      96: aload         9
      98: invokeinterface #226,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     103: checkcast     #30                 // class java/util/List
     106: astore        12
     108: iload         11
     110: aload_0
     111: invokestatic  #321                // Method samplingInitialVxForGivenTime:(ILkotlin/ranges/IntRange;)Ljava/util/List;
     114: astore        13
     116: aload         13
     118: checkcast     #42                 // class java/lang/Iterable
     121: astore        14
     123: iconst_0
     124: istore        15
     126: aload         14
     128: astore        16
     130: new           #44                 // class java/util/ArrayList
     133: dup
     134: invokespecial #149                // Method java/util/ArrayList."<init>":()V
     137: checkcast     #56                 // class java/util/Collection
     140: astore        17
     142: iconst_0
     143: istore        18
     145: aload         16
     147: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     152: astore        19
     154: aload         19
     156: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     161: ifeq          315
     164: aload         19
     166: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     171: astore        20
     173: aload         20
     175: checkcast     #86                 // class java/lang/Number
     178: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     181: istore        21
     183: iconst_0
     184: istore        22
     186: aload         12
     188: checkcast     #42                 // class java/lang/Iterable
     191: astore        23
     193: iconst_0
     194: istore        24
     196: aload         23
     198: astore        25
     200: new           #44                 // class java/util/ArrayList
     203: dup
     204: aload         23
     206: bipush        10
     208: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     211: invokespecial #54                 // Method java/util/ArrayList."<init>":(I)V
     214: checkcast     #56                 // class java/util/Collection
     217: astore        26
     219: iconst_0
     220: istore        27
     222: aload         25
     224: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     229: astore        28
     231: aload         28
     233: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     238: ifeq          292
     241: aload         28
     243: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     248: astore        29
     250: aload         26
     252: aload         29
     254: checkcast     #86                 // class java/lang/Number
     257: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     260: istore        30
     262: astore        31
     264: iconst_0
     265: istore        32
     267: iload         21
     269: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     272: iload         30
     274: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     277: invokestatic  #101                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     280: aload         31
     282: swap
     283: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     288: pop
     289: goto          231
     292: aload         26
     294: checkcast     #30                 // class java/util/List
     297: nop
     298: checkcast     #42                 // class java/lang/Iterable
     301: nop
     302: astore        21
     304: aload         17
     306: aload         21
     308: invokestatic  #324                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     311: pop
     312: goto          154
     315: aload         17
     317: checkcast     #30                 // class java/util/List
     320: nop
     321: checkcast     #42                 // class java/lang/Iterable
     324: nop
     325: astore        9
     327: aload         5
     329: aload         9
     331: invokestatic  #324                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     334: pop
     335: goto          52
     338: aload         5
     340: checkcast     #30                 // class java/util/List
     343: nop
     344: checkcast     #42                 // class java/lang/Iterable
     347: invokestatic  #328                // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;
     350: areturn

  public static final java.util.Map$Entry<java.lang.Integer, java.lang.Integer> findMaxInitialVerticalVelocity(kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: ldc           #132                // String rangeY
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #316                // Method samplingInitialVy:(Lkotlin/ranges/IntRange;)Ljava/util/Map;
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #180                // class java/util/LinkedHashMap
      18: dup
      19: aload_1
      20: invokeinterface #214,  1          // InterfaceMethod java/util/Map.size:()I
      25: invokestatic  #185                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
      28: invokespecial #192                // Method java/util/LinkedHashMap."<init>":(I)V
      31: checkcast     #194                // class java/util/Map
      34: astore        4
      36: iconst_0
      37: istore        5
      39: aload_3
      40: invokeinterface #218,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      45: checkcast     #42                 // class java/lang/Iterable
      48: astore        6
      50: iconst_0
      51: istore        7
      53: aload         6
      55: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        8
      62: aload         8
      64: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          252
      72: aload         8
      74: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        9
      81: aload         4
      83: aload         9
      85: checkcast     #220                // class java/util/Map$Entry
      88: astore        10
      90: astore        11
      92: iconst_0
      93: istore        12
      95: aload         10
      97: invokeinterface #223,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     102: aload         11
     104: swap
     105: aload         9
     107: checkcast     #220                // class java/util/Map$Entry
     110: astore        13
     112: astore        21
     114: astore        20
     116: iconst_0
     117: istore        14
     119: aload         13
     121: invokeinterface #226,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     126: checkcast     #30                 // class java/util/List
     129: astore        15
     131: aload         15
     133: checkcast     #42                 // class java/lang/Iterable
     136: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     141: astore        16
     143: aload         16
     145: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     150: ifne          161
     153: new           #134                // class java/util/NoSuchElementException
     156: dup
     157: invokespecial #137                // Method java/util/NoSuchElementException."<init>":()V
     160: athrow
     161: aload         16
     163: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     168: checkcast     #86                 // class java/lang/Number
     171: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     174: istore        17
     176: iconst_0
     177: istore        18
     179: iload         17
     181: istore        17
     183: aload         16
     185: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     190: ifeq          229
     193: aload         16
     195: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     200: checkcast     #86                 // class java/lang/Number
     203: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     206: istore        18
     208: iconst_0
     209: istore        19
     211: iload         18
     213: istore        18
     215: iload         17
     217: iload         18
     219: if_icmpge     183
     222: iload         18
     224: istore        17
     226: goto          183
     229: iload         17
     231: nop
     232: invokestatic  #80                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     235: astore        22
     237: aload         20
     239: aload         21
     241: aload         22
     243: invokeinterface #198,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     248: pop
     249: goto          62
     252: aload         4
     254: nop
     255: nop
     256: invokeinterface #218,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     261: checkcast     #42                 // class java/lang/Iterable
     264: astore_2
     265: aload_2
     266: invokeinterface #60,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     271: astore_3
     272: aload_3
     273: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifne          285
     281: aconst_null
     282: goto          391
     285: aload_3
     286: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     291: astore        4
     293: aload_3
     294: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     299: ifne          307
     302: aload         4
     304: goto          391
     307: aload         4
     309: checkcast     #220                // class java/util/Map$Entry
     312: astore        5
     314: iconst_0
     315: istore        6
     317: aload         5
     319: invokeinterface #226,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     324: checkcast     #86                 // class java/lang/Number
     327: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     330: istore        5
     332: aload_3
     333: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     338: astore        6
     340: aload         6
     342: checkcast     #220                // class java/util/Map$Entry
     345: astore        7
     347: iconst_0
     348: istore        8
     350: aload         7
     352: invokeinterface #226,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     357: checkcast     #86                 // class java/lang/Number
     360: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     363: istore        7
     365: iload         5
     367: iload         7
     369: if_icmpge     380
     372: aload         6
     374: astore        4
     376: iload         7
     378: istore        5
     380: aload_3
     381: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     386: ifne          332
     389: aload         4
     391: checkcast     #220                // class java/util/Map$Entry
     394: dup
     395: invokestatic  #345                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     398: areturn

  public static final int computeMaxHeight(int, int);
    Code:
       0: iload_1
       1: iconst_0
       2: invokestatic  #354                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
       5: checkcast     #42                 // class java/lang/Iterable
       8: iload_0
       9: invokestatic  #358                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
      12: checkcast     #42                 // class java/lang/Iterable
      15: invokestatic  #300                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
      18: ireturn

  public static final void main();
    Code:
       0: new           #364                // class java/io/File
       3: dup
       4: ldc_w         #366                // String ./input/day17.txt
       7: invokespecial #369                // Method java/io/File."<init>":(Ljava/lang/String;)V
      10: astore_0
      11: getstatic     #375                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      14: astore_1
      15: iconst_0
      16: istore_2
      17: aload_0
      18: astore_3
      19: sipush        8192
      22: istore        4
      24: aload_3
      25: astore        5
      27: new           #377                // class java/io/InputStreamReader
      30: dup
      31: new           #379                // class java/io/FileInputStream
      34: dup
      35: aload         5
      37: invokespecial #382                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      40: checkcast     #384                // class java/io/InputStream
      43: aload_1
      44: invokespecial #387                // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      47: checkcast     #389                // class java/io/Reader
      50: astore        5
      52: aload         5
      54: instanceof    #391                // class java/io/BufferedReader
      57: ifeq          68
      60: aload         5
      62: checkcast     #391                // class java/io/BufferedReader
      65: goto          79
      68: new           #391                // class java/io/BufferedReader
      71: dup
      72: aload         5
      74: iload         4
      76: invokespecial #394                // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      79: checkcast     #396                // class java/io/Closeable
      82: astore_3
      83: aconst_null
      84: astore        4
      86: nop
      87: aload_3
      88: checkcast     #391                // class java/io/BufferedReader
      91: astore        5
      93: iconst_0
      94: istore        6
      96: aload         5
      98: invokestatic  #402                // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     101: astore        7
     103: iconst_0
     104: istore        8
     106: aload         7
     108: invokestatic  #408                // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
     111: checkcast     #20                 // class java/lang/String
     114: astore        9
     116: aload         9
     118: invokestatic  #410                // Method parseInput:(Ljava/lang/String;)Lkotlin/Pair;
     121: astore        10
     123: aload         10
     125: invokevirtual #413                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     128: checkcast     #92                 // class kotlin/ranges/IntRange
     131: astore        11
     133: aload         10
     135: invokevirtual #416                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     138: checkcast     #92                 // class kotlin/ranges/IntRange
     141: astore        12
     143: aload         12
     145: invokestatic  #418                // Method findMaxInitialVerticalVelocity:(Lkotlin/ranges/IntRange;)Ljava/util/Map$Entry;
     148: astore        13
     150: aload         13
     152: invokeinterface #223,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     157: checkcast     #86                 // class java/lang/Number
     160: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     163: istore        14
     165: aload         13
     167: invokeinterface #226,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     172: checkcast     #86                 // class java/lang/Number
     175: invokevirtual #90                 // Method java/lang/Number.intValue:()I
     178: istore        15
     180: iload         14
     182: iload         15
     184: invokestatic  #420                // Method computeMaxHeight:(II)I
     187: istore        16
     189: getstatic     #426                // Field java/lang/System.out:Ljava/io/PrintStream;
     192: iload         16
     194: invokevirtual #431                // Method java/io/PrintStream.println:(I)V
     197: aload         11
     199: aload         12
     201: invokestatic  #433                // Method findAllPossibleSolutions:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Ljava/util/List;
     204: invokeinterface #434,  1          // InterfaceMethod java/util/List.size:()I
     209: istore        16
     211: getstatic     #426                // Field java/lang/System.out:Ljava/io/PrintStream;
     214: iload         16
     216: invokevirtual #431                // Method java/io/PrintStream.println:(I)V
     219: nop
     220: getstatic     #440                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     223: astore        5
     225: aload_3
     226: aload         4
     228: invokestatic  #446                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     231: goto          254
     234: astore        6
     236: aload         6
     238: astore        4
     240: aload         6
     242: athrow
     243: astore        6
     245: aload_3
     246: aload         4
     248: invokestatic  #446                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     251: aload         6
     253: athrow
     254: nop
     255: return
    Exception table:
       from    to  target type
          86   225   234   Class java/lang/Throwable
          86   225   243   any
         234   243   243   any
         243   245   243   any

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


package day21

// Syntax sugar
private fun <N> Pair<N, N>.swap() = second to first
private fun Pair<Long, Long>.max() = if (first > second) first else second
private fun Pair<Long, Long>.addFirst(number: Long) = (first + number) to (second)
private fun Pair<Long, Long>.timesEach(number: Long) = (first * number) to (second * number)
private operator fun Pair<Long, Long>.plus(other: Pair<Long, Long>) = (first + other.first) to (second + other.second)

data class GameState(val position: Int, val score: Int = 0)

class GameRules(private val minScoreToWin: Int) {
  fun move(gameState: GameState, increment: Int): GameState {
    val newPosition = ((gameState.position - 1 + increment) % 10) + 1
    return GameState(newPosition, gameState.score + newPosition)
  }

  fun hasWon(gameState: GameState): Boolean = gameState.score >= minScoreToWin
}

fun playDeterministicGame(initialPositionPlayer1: Int, initialPositionPlayer2: Int): Int {
  tailrec fun play(
    currentPlayer: GameState,
    otherPlayer: GameState,
    diceSeq: Sequence<Int>,
    diceRolledCount: Int,
    gameRules: GameRules
  ): Int {
    val p = gameRules.move(currentPlayer, diceSeq.take(3).sum())
    return if (gameRules.hasWon(p)) otherPlayer.score * (diceRolledCount + 3)
    else play(otherPlayer, p, diceSeq.drop(3), diceRolledCount + 3, gameRules)
  }

  val deterministicDice = sequence { while (true) yieldAll(1..100) }
  return play(GameState(initialPositionPlayer1), GameState(initialPositionPlayer2), deterministicDice, 0, GameRules(1_000))
}

fun countUniversesInWhichPlayerWins(initialPositionPlayer1: Int, initialPositionPlayer2: Int): Pair<Long, Long> {
  /*
  * Three dice with values 1, 2 and 3 generate the following 'universes'
  *  - 1x sum = 3; 1x[1, 1, 1]
  *  - 3x sum = 4; 3x[1, 1, 2]
  *  - 6x sum = 5; 3x[1, 1, 3] + 3x[1, 2, 2]
  *  - 7x sum = 6; 6x[1, 2, 3] + 1x[2, 2, 2]
  *  - 6x sum = 7; 3x[2, 2, 3] + 3x[1, 3 ,3]
  *  - 3x sum = 8; 3x[2, 3, 3]
  *  - 1x sum = 9; 1x[3, 3, 3]
  */
  fun incMultiplier(increment: Int): Long = when (increment) {
    3, 9 -> 1
    4, 8 -> 3
    5, 7 -> 6
    6 -> 7
    else -> 0
  }

  fun play(currentPlayer: GameState, otherPlayer: GameState, gameRules: GameRules): Pair<Long, Long> {
    var victoryCounter = 0L to 0L
    for (increment in 3..9) {
      val p = gameRules.move(currentPlayer, increment)
      if (gameRules.hasWon(p)) {
        victoryCounter = victoryCounter.addFirst(incMultiplier(increment))
      } else {
        victoryCounter += play(otherPlayer, p, gameRules).swap().timesEach(incMultiplier(increment))
      }
    }
    return victoryCounter
  }
  return play(GameState(initialPositionPlayer1), GameState(initialPositionPlayer2), GameRules(21))
}

fun main() {
  // I'm not parsing such a small input :)
  // Starting point for player 1 is 2
  // Starting point for player 2 is 5
  println("Part one: ${playDeterministicGame(2, 5)}")
  println("Part two: ${countUniversesInWhichPlayerWins(2, 5).max()}")
}

Compiled from "Day21.kt"
public final class day21.Day21Kt {
  private static final <N> kotlin.Pair<N, N> swap(kotlin.Pair<? extends N, ? extends N>);
    Code:
       0: aload_0
       1: invokevirtual #13                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
       4: aload_0
       5: invokevirtual #16                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       8: invokestatic  #22                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      11: areturn

  private static final long max(kotlin.Pair<java.lang.Long, java.lang.Long>);
    Code:
       0: aload_0
       1: invokevirtual #16                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #29                 // class java/lang/Number
       7: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      10: aload_0
      11: invokevirtual #13                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      14: checkcast     #29                 // class java/lang/Number
      17: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      20: lcmp
      21: ifle          37
      24: aload_0
      25: invokevirtual #16                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      28: checkcast     #29                 // class java/lang/Number
      31: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      34: goto          47
      37: aload_0
      38: invokevirtual #13                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      41: checkcast     #29                 // class java/lang/Number
      44: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      47: lreturn

  private static final kotlin.Pair<java.lang.Long, java.lang.Long> addFirst(kotlin.Pair<java.lang.Long, java.lang.Long>, long);
    Code:
       0: aload_0
       1: invokevirtual #16                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #29                 // class java/lang/Number
       7: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      10: lload_1
      11: ladd
      12: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      15: aload_0
      16: invokevirtual #13                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      19: invokestatic  #22                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      22: areturn

  private static final kotlin.Pair<java.lang.Long, java.lang.Long> timesEach(kotlin.Pair<java.lang.Long, java.lang.Long>, long);
    Code:
       0: aload_0
       1: invokevirtual #16                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
       4: checkcast     #29                 // class java/lang/Number
       7: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      10: lload_1
      11: lmul
      12: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      15: aload_0
      16: invokevirtual #13                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      19: checkcast     #29                 // class java/lang/Number
      22: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      25: lload_1
      26: lmul
      27: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      30: invokestatic  #22                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      33: areturn

  private static final kotlin.Pair<java.lang.Long, java.lang.Long> plus(kotlin.Pair<java.lang.Long, java.lang.Long>, kotlin.Pair<java.lang.Long, java.lang.Long>);
    Code:
       0: aload_0
       1: ldc           #53                 // String <this>
       3: invokestatic  #59                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #16                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      10: checkcast     #29                 // class java/lang/Number
      13: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      16: aload_1
      17: invokevirtual #16                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      20: checkcast     #29                 // class java/lang/Number
      23: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      26: ladd
      27: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      30: aload_0
      31: invokevirtual #13                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      34: checkcast     #29                 // class java/lang/Number
      37: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      40: aload_1
      41: invokevirtual #13                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      44: checkcast     #29                 // class java/lang/Number
      47: invokevirtual #33                 // Method java/lang/Number.longValue:()J
      50: ladd
      51: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      54: invokestatic  #22                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      57: areturn

  public static final int playDeterministicGame(int, int);
    Code:
       0: new           #65                 // class day21/Day21Kt$playDeterministicGame$deterministicDice$1
       3: dup
       4: aconst_null
       5: invokespecial #69                 // Method day21/Day21Kt$playDeterministicGame$deterministicDice$1."<init>":(Lkotlin/coroutines/Continuation;)V
       8: checkcast     #71                 // class kotlin/jvm/functions/Function2
      11: invokestatic  #77                 // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      14: astore_2
      15: new           #79                 // class day21/GameState
      18: dup
      19: iload_0
      20: iconst_0
      21: iconst_2
      22: aconst_null
      23: invokespecial #82                 // Method day21/GameState."<init>":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V
      26: new           #79                 // class day21/GameState
      29: dup
      30: iload_1
      31: iconst_0
      32: iconst_2
      33: aconst_null
      34: invokespecial #82                 // Method day21/GameState."<init>":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V
      37: aload_2
      38: iconst_0
      39: new           #84                 // class day21/GameRules
      42: dup
      43: sipush        1000
      46: invokespecial #87                 // Method day21/GameRules."<init>":(I)V
      49: invokestatic  #91                 // Method playDeterministicGame$play:(Lday21/GameState;Lday21/GameState;Lkotlin/sequences/Sequence;ILday21/GameRules;)I
      52: ireturn

  public static final kotlin.Pair<java.lang.Long, java.lang.Long> countUniversesInWhichPlayerWins(int, int);
    Code:
       0: new           #79                 // class day21/GameState
       3: dup
       4: iload_0
       5: iconst_0
       6: iconst_2
       7: aconst_null
       8: invokespecial #82                 // Method day21/GameState."<init>":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V
      11: new           #79                 // class day21/GameState
      14: dup
      15: iload_1
      16: iconst_0
      17: iconst_2
      18: aconst_null
      19: invokespecial #82                 // Method day21/GameState."<init>":(IIILkotlin/jvm/internal/DefaultConstructorMarker;)V
      22: new           #84                 // class day21/GameRules
      25: dup
      26: bipush        21
      28: invokespecial #87                 // Method day21/GameRules."<init>":(I)V
      31: invokestatic  #104                // Method countUniversesInWhichPlayerWins$play$0:(Lday21/GameState;Lday21/GameState;Lday21/GameRules;)Lkotlin/Pair;
      34: areturn

  public static final void main();
    Code:
       0: new           #108                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #112                // String Part one:
       9: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: iconst_2
      13: iconst_5
      14: invokestatic  #118                // Method playDeterministicGame:(II)I
      17: invokevirtual #121                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      20: invokevirtual #125                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      23: getstatic     #131                // Field java/lang/System.out:Ljava/io/PrintStream;
      26: swap
      27: invokevirtual #137                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      30: new           #108                // class java/lang/StringBuilder
      33: dup
      34: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
      37: ldc           #139                // String Part two:
      39: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      42: iconst_2
      43: iconst_5
      44: invokestatic  #141                // Method countUniversesInWhichPlayerWins:(II)Lkotlin/Pair;
      47: invokestatic  #143                // Method max:(Lkotlin/Pair;)J
      50: invokevirtual #146                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      53: invokevirtual #125                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      56: getstatic     #131                // Field java/lang/System.out:Ljava/io/PrintStream;
      59: swap
      60: invokevirtual #137                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      63: return

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

  private static final int playDeterministicGame$play(day21.GameState, day21.GameState, kotlin.sequences.Sequence<java.lang.Integer>, int, day21.GameRules);
    Code:
       0: aload         4
       2: aload_0
       3: aload_2
       4: iconst_3
       5: invokestatic  #156                // Method kotlin/sequences/SequencesKt.take:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
       8: invokestatic  #160                // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I
      11: invokevirtual #164                // Method day21/GameRules.move:(Lday21/GameState;I)Lday21/GameState;
      14: astore        5
      16: aload         4
      18: aload         5
      20: invokevirtual #168                // Method day21/GameRules.hasWon:(Lday21/GameState;)Z
      23: ifeq          37
      26: aload_1
      27: invokevirtual #172                // Method day21/GameState.getScore:()I
      30: iload_3
      31: iconst_3
      32: iadd
      33: imul
      34: goto          75
      37: aload_1
      38: astore        6
      40: aload_2
      41: iconst_3
      42: invokestatic  #175                // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
      45: astore        7
      47: iload_3
      48: iconst_3
      49: iadd
      50: istore        8
      52: aload         4
      54: astore        9
      56: aload         6
      58: astore_0
      59: aload         5
      61: astore_1
      62: aload         7
      64: astore_2
      65: iload         8
      67: istore_3
      68: aload         9
      70: astore        4
      72: goto          0
      75: ireturn

  private static final long countUniversesInWhichPlayerWins$incMultiplier(int);
    Code:
       0: iload_0
       1: tableswitch   { // 3 to 9
                     3: 44
                     4: 48
                     5: 54
                     6: 60
                     7: 54
                     8: 48
                     9: 44
               default: 66
          }
      44: lconst_1
      45: goto          67
      48: ldc2_w        #186                // long 3l
      51: goto          67
      54: ldc2_w        #188                // long 6l
      57: goto          67
      60: ldc2_w        #190                // long 7l
      63: goto          67
      66: lconst_0
      67: lreturn

  private static final kotlin.Pair<java.lang.Long, java.lang.Long> countUniversesInWhichPlayerWins$play$0(day21.GameState, day21.GameState, day21.GameRules);
    Code:
       0: lconst_0
       1: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       4: lconst_0
       5: invokestatic  #43                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       8: invokestatic  #22                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      11: astore_3
      12: iconst_3
      13: istore        4
      15: iload         4
      17: bipush        10
      19: if_icmpge     82
      22: aload_2
      23: aload_0
      24: iload         4
      26: invokevirtual #164                // Method day21/GameRules.move:(Lday21/GameState;I)Lday21/GameState;
      29: astore        5
      31: aload_2
      32: aload         5
      34: invokevirtual #168                // Method day21/GameRules.hasWon:(Lday21/GameState;)Z
      37: ifeq          53
      40: aload_3
      41: iload         4
      43: invokestatic  #195                // Method countUniversesInWhichPlayerWins$incMultiplier:(I)J
      46: invokestatic  #197                // Method addFirst:(Lkotlin/Pair;J)Lkotlin/Pair;
      49: astore_3
      50: goto          76
      53: aload_3
      54: aload_1
      55: aload         5
      57: aload_2
      58: invokestatic  #104                // Method countUniversesInWhichPlayerWins$play$0:(Lday21/GameState;Lday21/GameState;Lday21/GameRules;)Lkotlin/Pair;
      61: invokestatic  #199                // Method swap:(Lkotlin/Pair;)Lkotlin/Pair;
      64: iload         4
      66: invokestatic  #195                // Method countUniversesInWhichPlayerWins$incMultiplier:(I)J
      69: invokestatic  #201                // Method timesEach:(Lkotlin/Pair;J)Lkotlin/Pair;
      72: invokestatic  #203                // Method plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;
      75: astore_3
      76: iinc          4, 1
      79: goto          15
      82: aload_3
      83: areturn
}

Compiled from "Day21.kt"
final class day21.Day21Kt$playDeterministicGame$deterministicDice$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.lang.Integer>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
  int label;

  private java.lang.Object L$0;

  day21.Day21Kt$playDeterministicGame$deterministicDice$1(kotlin.coroutines.Continuation<? super day21.Day21Kt$playDeterministicGame$deterministicDice$1>);
    Code:
       0: aload_0
       1: iconst_2
       2: aload_1
       3: invokespecial #13                 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda."<init>":(ILkotlin/coroutines/Continuation;)V
       6: return

  public final java.lang.Object invokeSuspend(java.lang.Object);
    Code:
       0: invokestatic  #39                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
       3: astore_3
       4: aload_0
       5: getfield      #43                 // Field label:I
       8: tableswitch   { // 0 to 1
                     0: 32
                     1: 82
               default: 99
          }
      32: aload_1
      33: invokestatic  #49                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
      36: aload_0
      37: getfield      #52                 // Field L$0:Ljava/lang/Object;
      40: checkcast     #54                 // class kotlin/sequences/SequenceScope
      43: astore_2
      44: aload_2
      45: new           #56                 // class kotlin/ranges/IntRange
      48: dup
      49: iconst_1
      50: bipush        100
      52: invokespecial #59                 // Method kotlin/ranges/IntRange."<init>":(II)V
      55: checkcast     #61                 // class java/lang/Iterable
      58: aload_0
      59: checkcast     #63                 // class kotlin/coroutines/Continuation
      62: aload_0
      63: aload_2
      64: putfield      #52                 // Field L$0:Ljava/lang/Object;
      67: aload_0
      68: iconst_1
      69: putfield      #43                 // Field label:I
      72: invokevirtual #67                 // Method kotlin/sequences/SequenceScope.yieldAll:(Ljava/lang/Iterable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      75: dup
      76: aload_3
      77: if_acmpne     95
      80: aload_3
      81: areturn
      82: aload_0
      83: getfield      #52                 // Field L$0:Ljava/lang/Object;
      86: checkcast     #54                 // class kotlin/sequences/SequenceScope
      89: astore_2
      90: aload_1
      91: invokestatic  #49                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
      94: aload_1
      95: pop
      96: goto          44
      99: new           #69                 // class java/lang/IllegalStateException
     102: dup
     103: ldc           #71                 // String call to \'resume\' before \'invoke\' with coroutine
     105: invokespecial #74                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     108: athrow

  public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);
    Code:
       0: new           #2                  // class day21/Day21Kt$playDeterministicGame$deterministicDice$1
       3: dup
       4: aload_2
       5: invokespecial #83                 // Method "<init>":(Lkotlin/coroutines/Continuation;)V
       8: astore_3
       9: aload_3
      10: aload_1
      11: putfield      #52                 // Field L$0:Ljava/lang/Object;
      14: aload_3
      15: checkcast     #63                 // class kotlin/coroutines/Continuation
      18: areturn

  public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.lang.Integer>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokevirtual #89                 // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
       6: checkcast     #2                  // class day21/Day21Kt$playDeterministicGame$deterministicDice$1
       9: getstatic     #95                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      12: invokevirtual #97                 // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;
      15: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #54                 // class kotlin/sequences/SequenceScope
       5: aload_2
       6: checkcast     #63                 // class kotlin/coroutines/Continuation
       9: invokevirtual #102                // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      12: areturn
}