package advent.of.code.day11

const val id = 5535

val squareResults = mutableMapOf<Pair<Int, Int>, Pair<Int, Int>>()

fun powerLevel(x: Int, y: Int) = (((((x + 10) * y + id) * (x + 10)) / 100) % 10) - 5

fun part1(): String {
    val result = (1..298).map { x ->
        (1..298).map { y ->
            val power = (0..2).map { powerX ->
                (0..2).map { powerY ->
                    powerLevel(x + powerX, y + powerY)
                }.sum()
            }.sum()
            Triple(x, y, power)
        }.maxBy { it.third }
    }.maxBy { it?.third ?: 0 }
    return "${result?.first},${result?.second}"
}

fun part2(): String {
    var max = 0
    var maxRegion: Triple<Int, Int, Int>? = null
    for (size in (1..300)) {
        for (x in (1..(301 - size))) {
            for (y in (1..(301 - size))) {
                val power = if (size > 1) {
                    squareResults[Pair(x, y)]?.first!! +
                            (x..(x + size - 2)).map {
                                powerLevel(it, y + size - 1)
                            }.sum() +
                            (y..(y + size - 2)).map {
                                powerLevel(x + size - 1, it)
                            }.sum() +
                            powerLevel(x + size - 1, y + size - 1)
                } else {
                    (x..(x + size - 1)).map { innerX ->
                        (y..(y + size - 1)).map { innerY ->
                            powerLevel(innerX, innerY)
                        }.sum()
                    }.sum()
                }
                if (power > max) {
                    max = power
                    maxRegion = Triple(x, y, size)
                }
                squareResults[Pair(x, y)] = Pair(power, size)
            }
        }

    }
    return "${maxRegion?.first},${maxRegion?.second},${maxRegion?.third}"
}

Compiled from "Solution.kt"
public final class advent.of.code.day11.SolutionKt {
  public static final int id;

  private static final java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>> squareResults;

  public static final java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>> getSquareResults();
    Code:
       0: getstatic     #12                 // Field squareResults:Ljava/util/Map;
       3: areturn

  public static final int powerLevel(int, int);
    Code:
       0: iload_0
       1: bipush        10
       3: iadd
       4: iload_1
       5: imul
       6: sipush        5535
       9: iadd
      10: iload_0
      11: bipush        10
      13: iadd
      14: imul
      15: bipush        100
      17: idiv
      18: bipush        10
      20: irem
      21: iconst_5
      22: isub
      23: ireturn

  public static final java.lang.String part1();
    Code:
       0: new           #21                 // class kotlin/ranges/IntRange
       3: dup
       4: iconst_1
       5: sipush        298
       8: invokespecial #25                 // Method kotlin/ranges/IntRange."<init>":(II)V
      11: checkcast     #27                 // class java/lang/Iterable
      14: astore_1
      15: iconst_0
      16: istore_2
      17: aload_1
      18: astore_3
      19: new           #29                 // class java/util/ArrayList
      22: dup
      23: aload_1
      24: bipush        10
      26: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      29: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
      32: checkcast     #40                 // class java/util/Collection
      35: astore        4
      37: iconst_0
      38: istore        5
      40: aload_3
      41: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      46: astore        6
      48: aload         6
      50: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      55: ifeq          597
      58: aload         6
      60: checkcast     #52                 // class kotlin/collections/IntIterator
      63: invokevirtual #56                 // Method kotlin/collections/IntIterator.nextInt:()I
      66: istore        7
      68: aload         4
      70: iload         7
      72: istore        8
      74: astore        41
      76: iconst_0
      77: istore        9
      79: new           #21                 // class kotlin/ranges/IntRange
      82: dup
      83: iconst_1
      84: sipush        298
      87: invokespecial #25                 // Method kotlin/ranges/IntRange."<init>":(II)V
      90: checkcast     #27                 // class java/lang/Iterable
      93: astore        10
      95: iconst_0
      96: istore        11
      98: aload         10
     100: astore        12
     102: new           #29                 // class java/util/ArrayList
     105: dup
     106: aload         10
     108: bipush        10
     110: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     113: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
     116: checkcast     #40                 // class java/util/Collection
     119: astore        13
     121: iconst_0
     122: istore        14
     124: aload         12
     126: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     131: astore        15
     133: aload         15
     135: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     140: ifeq          433
     143: aload         15
     145: checkcast     #52                 // class kotlin/collections/IntIterator
     148: invokevirtual #56                 // Method kotlin/collections/IntIterator.nextInt:()I
     151: istore        16
     153: aload         13
     155: iload         16
     157: istore        17
     159: astore        18
     161: iconst_0
     162: istore        19
     164: new           #21                 // class kotlin/ranges/IntRange
     167: dup
     168: iconst_0
     169: iconst_2
     170: invokespecial #25                 // Method kotlin/ranges/IntRange."<init>":(II)V
     173: checkcast     #27                 // class java/lang/Iterable
     176: astore        20
     178: iconst_0
     179: istore        21
     181: aload         20
     183: astore        22
     185: new           #29                 // class java/util/ArrayList
     188: dup
     189: aload         20
     191: bipush        10
     193: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     196: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
     199: checkcast     #40                 // class java/util/Collection
     202: astore        23
     204: iconst_0
     205: istore        24
     207: aload         22
     209: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     214: astore        25
     216: aload         25
     218: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     223: ifeq          385
     226: aload         25
     228: checkcast     #52                 // class kotlin/collections/IntIterator
     231: invokevirtual #56                 // Method kotlin/collections/IntIterator.nextInt:()I
     234: istore        26
     236: aload         23
     238: iload         26
     240: istore        27
     242: astore        28
     244: iconst_0
     245: istore        29
     247: new           #21                 // class kotlin/ranges/IntRange
     250: dup
     251: iconst_0
     252: iconst_2
     253: invokespecial #25                 // Method kotlin/ranges/IntRange."<init>":(II)V
     256: checkcast     #27                 // class java/lang/Iterable
     259: astore        30
     261: iconst_0
     262: istore        31
     264: aload         30
     266: astore        32
     268: new           #29                 // class java/util/ArrayList
     271: dup
     272: aload         30
     274: bipush        10
     276: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     279: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
     282: checkcast     #40                 // class java/util/Collection
     285: astore        33
     287: iconst_0
     288: istore        34
     290: aload         32
     292: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     297: astore        35
     299: aload         35
     301: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     306: ifeq          358
     309: aload         35
     311: checkcast     #52                 // class kotlin/collections/IntIterator
     314: invokevirtual #56                 // Method kotlin/collections/IntIterator.nextInt:()I
     317: istore        36
     319: aload         33
     321: iload         36
     323: istore        37
     325: astore        38
     327: iconst_0
     328: istore        39
     330: iload         8
     332: iload         27
     334: iadd
     335: iload         17
     337: iload         37
     339: iadd
     340: invokestatic  #58                 // Method powerLevel:(II)I
     343: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     346: aload         38
     348: swap
     349: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     354: pop
     355: goto          299
     358: aload         33
     360: checkcast     #70                 // class java/util/List
     363: nop
     364: checkcast     #27                 // class java/lang/Iterable
     367: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     370: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     373: aload         28
     375: swap
     376: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     381: pop
     382: goto          216
     385: aload         23
     387: checkcast     #70                 // class java/util/List
     390: nop
     391: checkcast     #27                 // class java/lang/Iterable
     394: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     397: istore        40
     399: new           #76                 // class kotlin/Triple
     402: dup
     403: iload         8
     405: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     408: iload         17
     410: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     413: iload         40
     415: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     418: invokespecial #79                 // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     421: aload         18
     423: swap
     424: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     429: pop
     430: goto          133
     433: aload         13
     435: checkcast     #70                 // class java/util/List
     438: nop
     439: checkcast     #27                 // class java/lang/Iterable
     442: astore        10
     444: nop
     445: iconst_0
     446: istore        11
     448: aload         10
     450: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     455: astore        12
     457: aload         12
     459: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     464: ifne          475
     467: new           #81                 // class java/util/NoSuchElementException
     470: dup
     471: invokespecial #84                 // Method java/util/NoSuchElementException."<init>":()V
     474: athrow
     475: aload         12
     477: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     482: astore        13
     484: aload         12
     486: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     491: ifne          499
     494: aload         13
     496: goto          581
     499: aload         13
     501: checkcast     #76                 // class kotlin/Triple
     504: astore        14
     506: iconst_0
     507: istore        15
     509: aload         14
     511: invokevirtual #91                 // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     514: checkcast     #93                 // class java/lang/Number
     517: invokevirtual #96                 // Method java/lang/Number.intValue:()I
     520: istore        14
     522: aload         12
     524: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     529: astore        15
     531: aload         15
     533: checkcast     #76                 // class kotlin/Triple
     536: astore        16
     538: iconst_0
     539: istore        17
     541: aload         16
     543: invokevirtual #91                 // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     546: checkcast     #93                 // class java/lang/Number
     549: invokevirtual #96                 // Method java/lang/Number.intValue:()I
     552: istore        16
     554: iload         14
     556: iload         16
     558: if_icmpge     569
     561: aload         15
     563: astore        13
     565: iload         16
     567: istore        14
     569: aload         12
     571: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     576: ifne          522
     579: aload         13
     581: checkcast     #76                 // class kotlin/Triple
     584: nop
     585: aload         41
     587: swap
     588: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     593: pop
     594: goto          48
     597: aload         4
     599: checkcast     #70                 // class java/util/List
     602: nop
     603: checkcast     #27                 // class java/lang/Iterable
     606: astore_1
     607: nop
     608: iconst_0
     609: istore_2
     610: aload_1
     611: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     616: astore_3
     617: aload_3
     618: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     623: ifne          634
     626: new           #81                 // class java/util/NoSuchElementException
     629: dup
     630: invokespecial #84                 // Method java/util/NoSuchElementException."<init>":()V
     633: athrow
     634: aload_3
     635: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     640: astore        4
     642: aload_3
     643: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     648: ifne          656
     651: aload         4
     653: goto          754
     656: aload         4
     658: checkcast     #76                 // class kotlin/Triple
     661: astore        5
     663: iconst_0
     664: istore        6
     666: aload         5
     668: dup
     669: ifnull        684
     672: invokevirtual #91                 // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     675: checkcast     #93                 // class java/lang/Number
     678: invokevirtual #96                 // Method java/lang/Number.intValue:()I
     681: goto          686
     684: pop
     685: iconst_0
     686: istore        5
     688: aload_3
     689: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     694: astore        6
     696: aload         6
     698: checkcast     #76                 // class kotlin/Triple
     701: astore        7
     703: iconst_0
     704: istore        8
     706: aload         7
     708: dup
     709: ifnull        724
     712: invokevirtual #91                 // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     715: checkcast     #93                 // class java/lang/Number
     718: invokevirtual #96                 // Method java/lang/Number.intValue:()I
     721: goto          726
     724: pop
     725: iconst_0
     726: istore        7
     728: iload         5
     730: iload         7
     732: if_icmpge     743
     735: aload         6
     737: astore        4
     739: iload         7
     741: istore        5
     743: aload_3
     744: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     749: ifne          688
     752: aload         4
     754: checkcast     #76                 // class kotlin/Triple
     757: astore_0
     758: new           #98                 // class java/lang/StringBuilder
     761: dup
     762: invokespecial #99                 // Method java/lang/StringBuilder."<init>":()V
     765: aload_0
     766: dup
     767: ifnull        779
     770: invokevirtual #102                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     773: checkcast     #60                 // class java/lang/Integer
     776: goto          781
     779: pop
     780: aconst_null
     781: invokevirtual #106                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     784: bipush        44
     786: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     789: aload_0
     790: dup
     791: ifnull        803
     794: invokevirtual #112                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     797: checkcast     #60                 // class java/lang/Integer
     800: goto          805
     803: pop
     804: aconst_null
     805: invokevirtual #106                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     808: invokevirtual #115                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     811: areturn

  public static final java.lang.String part2();
    Code:
       0: iconst_0
       1: istore_0
       2: aconst_null
       3: astore_1
       4: iconst_1
       5: istore_2
       6: iload_2
       7: sipush        301
      10: if_icmpge     727
      13: iconst_1
      14: istore_3
      15: sipush        301
      18: iload_2
      19: isub
      20: istore        4
      22: iload_3
      23: iload         4
      25: if_icmpgt     721
      28: iconst_1
      29: istore        5
      31: sipush        301
      34: iload_2
      35: isub
      36: istore        6
      38: iload         5
      40: iload         6
      42: if_icmpgt     709
      45: iload_2
      46: iconst_1
      47: if_icmple     386
      50: getstatic     #12                 // Field squareResults:Ljava/util/Map;
      53: new           #147                // class kotlin/Pair
      56: dup
      57: iload_3
      58: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      61: iload         5
      63: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      66: invokespecial #150                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      69: invokeinterface #156,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      74: checkcast     #147                // class kotlin/Pair
      77: dup
      78: ifnull        90
      81: invokevirtual #157                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      84: checkcast     #60                 // class java/lang/Integer
      87: goto          92
      90: pop
      91: aconst_null
      92: dup
      93: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      96: invokevirtual #164                // Method java/lang/Integer.intValue:()I
      99: new           #21                 // class kotlin/ranges/IntRange
     102: dup
     103: iload_3
     104: iload_3
     105: iload_2
     106: iadd
     107: iconst_2
     108: isub
     109: invokespecial #25                 // Method kotlin/ranges/IntRange."<init>":(II)V
     112: checkcast     #27                 // class java/lang/Iterable
     115: astore        8
     117: istore        27
     119: iconst_0
     120: istore        9
     122: aload         8
     124: astore        10
     126: new           #29                 // class java/util/ArrayList
     129: dup
     130: aload         8
     132: bipush        10
     134: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     137: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
     140: checkcast     #40                 // class java/util/Collection
     143: astore        11
     145: iconst_0
     146: istore        12
     148: aload         10
     150: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     155: astore        13
     157: aload         13
     159: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     164: ifeq          214
     167: aload         13
     169: checkcast     #52                 // class kotlin/collections/IntIterator
     172: invokevirtual #56                 // Method kotlin/collections/IntIterator.nextInt:()I
     175: istore        14
     177: aload         11
     179: iload         14
     181: istore        15
     183: astore        28
     185: iconst_0
     186: istore        16
     188: iload         15
     190: iload         5
     192: iload_2
     193: iadd
     194: iconst_1
     195: isub
     196: invokestatic  #58                 // Method powerLevel:(II)I
     199: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     202: aload         28
     204: swap
     205: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     210: pop
     211: goto          157
     214: aload         11
     216: checkcast     #70                 // class java/util/List
     219: nop
     220: astore        28
     222: iload         27
     224: aload         28
     226: checkcast     #27                 // class java/lang/Iterable
     229: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     232: iadd
     233: new           #21                 // class kotlin/ranges/IntRange
     236: dup
     237: iload         5
     239: iload         5
     241: iload_2
     242: iadd
     243: iconst_2
     244: isub
     245: invokespecial #25                 // Method kotlin/ranges/IntRange."<init>":(II)V
     248: checkcast     #27                 // class java/lang/Iterable
     251: astore        8
     253: istore        27
     255: iconst_0
     256: istore        9
     258: aload         8
     260: astore        10
     262: new           #29                 // class java/util/ArrayList
     265: dup
     266: aload         8
     268: bipush        10
     270: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     273: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
     276: checkcast     #40                 // class java/util/Collection
     279: astore        11
     281: iconst_0
     282: istore        12
     284: aload         10
     286: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     291: astore        13
     293: aload         13
     295: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     300: ifeq          349
     303: aload         13
     305: checkcast     #52                 // class kotlin/collections/IntIterator
     308: invokevirtual #56                 // Method kotlin/collections/IntIterator.nextInt:()I
     311: istore        14
     313: aload         11
     315: iload         14
     317: istore        15
     319: astore        28
     321: iconst_0
     322: istore        16
     324: iload_3
     325: iload_2
     326: iadd
     327: iconst_1
     328: isub
     329: iload         15
     331: invokestatic  #58                 // Method powerLevel:(II)I
     334: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     337: aload         28
     339: swap
     340: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     345: pop
     346: goto          293
     349: aload         11
     351: checkcast     #70                 // class java/util/List
     354: nop
     355: astore        28
     357: iload         27
     359: aload         28
     361: checkcast     #27                 // class java/lang/Iterable
     364: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     367: iadd
     368: iload_3
     369: iload_2
     370: iadd
     371: iconst_1
     372: isub
     373: iload         5
     375: iload_2
     376: iadd
     377: iconst_1
     378: isub
     379: invokestatic  #58                 // Method powerLevel:(II)I
     382: iadd
     383: goto          623
     386: new           #21                 // class kotlin/ranges/IntRange
     389: dup
     390: iload_3
     391: iload_3
     392: iload_2
     393: iadd
     394: iconst_1
     395: isub
     396: invokespecial #25                 // Method kotlin/ranges/IntRange."<init>":(II)V
     399: checkcast     #27                 // class java/lang/Iterable
     402: astore        8
     404: iconst_0
     405: istore        9
     407: aload         8
     409: astore        10
     411: new           #29                 // class java/util/ArrayList
     414: dup
     415: aload         8
     417: bipush        10
     419: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     422: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
     425: checkcast     #40                 // class java/util/Collection
     428: astore        11
     430: iconst_0
     431: istore        12
     433: aload         10
     435: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     440: astore        13
     442: aload         13
     444: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     449: ifeq          611
     452: aload         13
     454: checkcast     #52                 // class kotlin/collections/IntIterator
     457: invokevirtual #56                 // Method kotlin/collections/IntIterator.nextInt:()I
     460: istore        14
     462: aload         11
     464: iload         14
     466: istore        15
     468: astore        27
     470: iconst_0
     471: istore        16
     473: new           #21                 // class kotlin/ranges/IntRange
     476: dup
     477: iload         5
     479: iload         5
     481: iload_2
     482: iadd
     483: iconst_1
     484: isub
     485: invokespecial #25                 // Method kotlin/ranges/IntRange."<init>":(II)V
     488: checkcast     #27                 // class java/lang/Iterable
     491: astore        17
     493: iconst_0
     494: istore        18
     496: aload         17
     498: astore        19
     500: new           #29                 // class java/util/ArrayList
     503: dup
     504: aload         17
     506: bipush        10
     508: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     511: invokespecial #38                 // Method java/util/ArrayList."<init>":(I)V
     514: checkcast     #40                 // class java/util/Collection
     517: astore        20
     519: iconst_0
     520: istore        21
     522: aload         19
     524: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     529: astore        22
     531: aload         22
     533: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     538: ifeq          584
     541: aload         22
     543: checkcast     #52                 // class kotlin/collections/IntIterator
     546: invokevirtual #56                 // Method kotlin/collections/IntIterator.nextInt:()I
     549: istore        23
     551: aload         20
     553: iload         23
     555: istore        24
     557: astore        25
     559: iconst_0
     560: istore        26
     562: iload         15
     564: iload         24
     566: invokestatic  #58                 // Method powerLevel:(II)I
     569: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     572: aload         25
     574: swap
     575: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     580: pop
     581: goto          531
     584: aload         20
     586: checkcast     #70                 // class java/util/List
     589: nop
     590: checkcast     #27                 // class java/lang/Iterable
     593: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     596: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     599: aload         27
     601: swap
     602: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     607: pop
     608: goto          442
     611: aload         11
     613: checkcast     #70                 // class java/util/List
     616: nop
     617: checkcast     #27                 // class java/lang/Iterable
     620: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     623: istore        7
     625: iload         7
     627: iload_0
     628: if_icmple     655
     631: iload         7
     633: istore_0
     634: new           #76                 // class kotlin/Triple
     637: dup
     638: iload_3
     639: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     642: iload         5
     644: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     647: iload_2
     648: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     651: invokespecial #79                 // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     654: astore_1
     655: getstatic     #12                 // Field squareResults:Ljava/util/Map;
     658: new           #147                // class kotlin/Pair
     661: dup
     662: iload_3
     663: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     666: iload         5
     668: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     671: invokespecial #150                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     674: new           #147                // class kotlin/Pair
     677: dup
     678: iload         7
     680: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     683: iload_2
     684: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     687: invokespecial #150                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     690: invokeinterface #168,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     695: pop
     696: iload         5
     698: iload         6
     700: if_icmpeq     709
     703: iinc          5, 1
     706: goto          45
     709: iload_3
     710: iload         4
     712: if_icmpeq     721
     715: iinc          3, 1
     718: goto          28
     721: iinc          2, 1
     724: goto          6
     727: new           #98                 // class java/lang/StringBuilder
     730: dup
     731: invokespecial #99                 // Method java/lang/StringBuilder."<init>":()V
     734: aload_1
     735: dup
     736: ifnull        748
     739: invokevirtual #102                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     742: checkcast     #60                 // class java/lang/Integer
     745: goto          750
     748: pop
     749: aconst_null
     750: invokevirtual #106                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     753: bipush        44
     755: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     758: aload_1
     759: dup
     760: ifnull        772
     763: invokevirtual #112                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     766: checkcast     #60                 // class java/lang/Integer
     769: goto          774
     772: pop
     773: aconst_null
     774: invokevirtual #106                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     777: bipush        44
     779: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     782: aload_1
     783: dup
     784: ifnull        796
     787: invokevirtual #91                 // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     790: checkcast     #60                 // class java/lang/Integer
     793: goto          798
     796: pop
     797: aconst_null
     798: invokevirtual #106                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     801: invokevirtual #115                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     804: areturn

  static {};
    Code:
       0: new           #180                // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #181                // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #152                // class java/util/Map
      10: putstatic     #12                 // Field squareResults:Ljava/util/Map;
      13: return
}


package advent.of.code.day10

import java.io.File

private val lineRegex = Regex("position=<([- ]?[0-9]+), ([- ]?[0-9]+)> velocity=<([- ]?[0-9]+), ([- ]?[0-9]+)>")

private var input = File("day10.txt").readLines().map {
    val res = lineRegex.find(it.trim())
    listOf(
        res?.groupValues?.get(1)?.trim()?.toInt() ?: 0,
        res?.groupValues?.get(2)?.trim()?.toInt() ?: 0,
        res?.groupValues?.get(3)?.trim()?.toInt() ?: 0,
        res?.groupValues?.get(4)?.trim()?.toInt() ?: 0
    )
}.toList()

fun List<List<Int>>.move() = map { listOf(it[0] + it[2], it[1] + it[3], it[2], it[3]) }.toList()

fun List<List<Int>>.height() = map { it[1] }.max()!! - map { it[1] }.min()!!

fun part1() {
    var result = input.toList()
    var before = input.toList()
    var min = Int.MAX_VALUE
    for (s in (0..10000000)) {
        val current = result.height()
        if (current > min) {
            var msg = "\n"
            val minX = before.map { it[0] }.min()!!
            val maxX = before.map { it[0] }.max()!!
            val minY = before.map { it[1] }.min()!!
            val maxY = before.map { it[1] }.max()!!
            for (y in (minY..maxY)) {
                for (x in (minX..maxX))
                    msg += if (before.any { it[0] == x && it[1] == y }) '#' else ' '
                msg += '\n'
            }
            println(s - 1)
            println(msg)
            break
        }
        min = current
        before = result
        result = result.move()
    }
}

Compiled from "Solution.kt"
public final class advent.of.code.day10.SolutionKt {
  private static final kotlin.text.Regex lineRegex;

  private static java.util.List<? extends java.util.List<java.lang.Integer>> input;

  public static final java.util.List<java.util.List<java.lang.Integer>> move(java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       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/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #20                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #32                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          196
      54: aload         6
      56: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #48                 // class java/util/List
      70: astore        8
      72: astore        11
      74: iconst_0
      75: istore        9
      77: iconst_4
      78: anewarray     #50                 // class java/lang/Integer
      81: astore        10
      83: aload         10
      85: iconst_0
      86: aload         8
      88: iconst_0
      89: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      94: checkcast     #56                 // class java/lang/Number
      97: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     100: aload         8
     102: iconst_2
     103: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     108: checkcast     #56                 // class java/lang/Number
     111: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     114: iadd
     115: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     118: aastore
     119: aload         10
     121: iconst_1
     122: aload         8
     124: iconst_1
     125: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     130: checkcast     #56                 // class java/lang/Number
     133: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     136: aload         8
     138: iconst_3
     139: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     144: checkcast     #56                 // class java/lang/Number
     147: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     150: iadd
     151: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     154: aastore
     155: aload         10
     157: iconst_2
     158: aload         8
     160: iconst_2
     161: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     166: aastore
     167: aload         10
     169: iconst_3
     170: aload         8
     172: iconst_3
     173: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     178: aastore
     179: aload         10
     181: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     184: aload         11
     186: swap
     187: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     192: pop
     193: goto          44
     196: aload         4
     198: checkcast     #48                 // class java/util/List
     201: nop
     202: checkcast     #18                 // class java/lang/Iterable
     205: invokestatic  #76                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     208: areturn

  public static final int height(java.util.List<? extends java.util.List<java.lang.Integer>>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       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/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #20                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #32                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          106
      54: aload         6
      56: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #48                 // class java/util/List
      70: astore        8
      72: astore        10
      74: iconst_0
      75: istore        9
      77: aload         8
      79: iconst_1
      80: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      85: checkcast     #56                 // class java/lang/Number
      88: invokevirtual #60                 // Method java/lang/Number.intValue:()I
      91: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      94: aload         10
      96: swap
      97: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     102: pop
     103: goto          44
     106: aload         4
     108: checkcast     #48                 // class java/util/List
     111: nop
     112: checkcast     #18                 // class java/lang/Iterable
     115: invokestatic  #97                 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     118: dup
     119: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     122: checkcast     #56                 // class java/lang/Number
     125: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     128: aload_0
     129: checkcast     #18                 // class java/lang/Iterable
     132: astore_1
     133: istore        10
     135: iconst_0
     136: istore_2
     137: aload_1
     138: astore_3
     139: new           #20                 // class java/util/ArrayList
     142: dup
     143: aload_1
     144: bipush        10
     146: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     149: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
     152: checkcast     #32                 // class java/util/Collection
     155: astore        4
     157: iconst_0
     158: istore        5
     160: aload_3
     161: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     166: astore        6
     168: aload         6
     170: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     175: ifeq          230
     178: aload         6
     180: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     185: astore        7
     187: aload         4
     189: aload         7
     191: checkcast     #48                 // class java/util/List
     194: astore        8
     196: astore        11
     198: iconst_0
     199: istore        9
     201: aload         8
     203: iconst_1
     204: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     209: checkcast     #56                 // class java/lang/Number
     212: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     215: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     218: aload         11
     220: swap
     221: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     226: pop
     227: goto          168
     230: aload         4
     232: checkcast     #48                 // class java/util/List
     235: nop
     236: astore        11
     238: iload         10
     240: aload         11
     242: checkcast     #18                 // class java/lang/Iterable
     245: invokestatic  #104                // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     248: dup
     249: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     252: checkcast     #56                 // class java/lang/Number
     255: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     258: isub
     259: ireturn

  public static final void part1();
    Code:
       0: getstatic     #112                // Field input:Ljava/util/List;
       3: checkcast     #18                 // class java/lang/Iterable
       6: invokestatic  #76                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
       9: astore_0
      10: getstatic     #112                // Field input:Ljava/util/List;
      13: checkcast     #18                 // class java/lang/Iterable
      16: invokestatic  #76                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
      19: astore_1
      20: ldc           #113                // int 2147483647
      22: istore_2
      23: iconst_0
      24: istore_3
      25: iload_3
      26: ldc           #114                // int 10000001
      28: if_icmpge     838
      31: aload_0
      32: invokestatic  #116                // Method height:(Ljava/util/List;)I
      35: istore        4
      37: iload         4
      39: iload_2
      40: if_icmple     822
      43: ldc           #118                // String \n
      45: astore        5
      47: aload_1
      48: checkcast     #18                 // class java/lang/Iterable
      51: astore        7
      53: iconst_0
      54: istore        8
      56: aload         7
      58: astore        9
      60: new           #20                 // class java/util/ArrayList
      63: dup
      64: aload         7
      66: bipush        10
      68: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      71: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      74: checkcast     #32                 // class java/util/Collection
      77: astore        10
      79: iconst_0
      80: istore        11
      82: aload         9
      84: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      89: astore        12
      91: aload         12
      93: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      98: ifeq          153
     101: aload         12
     103: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     108: astore        13
     110: aload         10
     112: aload         13
     114: checkcast     #48                 // class java/util/List
     117: astore        14
     119: astore        19
     121: iconst_0
     122: istore        15
     124: aload         14
     126: iconst_0
     127: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     132: checkcast     #56                 // class java/lang/Number
     135: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     138: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     141: aload         19
     143: swap
     144: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     149: pop
     150: goto          91
     153: aload         10
     155: checkcast     #48                 // class java/util/List
     158: nop
     159: checkcast     #18                 // class java/lang/Iterable
     162: invokestatic  #104                // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     165: dup
     166: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     169: checkcast     #56                 // class java/lang/Number
     172: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     175: istore        6
     177: aload_1
     178: checkcast     #18                 // class java/lang/Iterable
     181: astore        8
     183: iconst_0
     184: istore        9
     186: aload         8
     188: astore        10
     190: new           #20                 // class java/util/ArrayList
     193: dup
     194: aload         8
     196: bipush        10
     198: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     201: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
     204: checkcast     #32                 // class java/util/Collection
     207: astore        11
     209: iconst_0
     210: istore        12
     212: aload         10
     214: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     219: astore        13
     221: aload         13
     223: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     228: ifeq          283
     231: aload         13
     233: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     238: astore        14
     240: aload         11
     242: aload         14
     244: checkcast     #48                 // class java/util/List
     247: astore        15
     249: astore        19
     251: iconst_0
     252: istore        16
     254: aload         15
     256: iconst_0
     257: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     262: checkcast     #56                 // class java/lang/Number
     265: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     268: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     271: aload         19
     273: swap
     274: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     279: pop
     280: goto          221
     283: aload         11
     285: checkcast     #48                 // class java/util/List
     288: nop
     289: checkcast     #18                 // class java/lang/Iterable
     292: invokestatic  #97                 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     295: dup
     296: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     299: checkcast     #56                 // class java/lang/Number
     302: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     305: istore        7
     307: aload_1
     308: checkcast     #18                 // class java/lang/Iterable
     311: astore        9
     313: iconst_0
     314: istore        10
     316: aload         9
     318: astore        11
     320: new           #20                 // class java/util/ArrayList
     323: dup
     324: aload         9
     326: bipush        10
     328: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     331: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
     334: checkcast     #32                 // class java/util/Collection
     337: astore        12
     339: iconst_0
     340: istore        13
     342: aload         11
     344: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     349: astore        14
     351: aload         14
     353: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     358: ifeq          413
     361: aload         14
     363: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     368: astore        15
     370: aload         12
     372: aload         15
     374: checkcast     #48                 // class java/util/List
     377: astore        16
     379: astore        19
     381: iconst_0
     382: istore        17
     384: aload         16
     386: iconst_1
     387: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     392: checkcast     #56                 // class java/lang/Number
     395: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     398: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     401: aload         19
     403: swap
     404: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     409: pop
     410: goto          351
     413: aload         12
     415: checkcast     #48                 // class java/util/List
     418: nop
     419: checkcast     #18                 // class java/lang/Iterable
     422: invokestatic  #104                // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     425: dup
     426: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     429: checkcast     #56                 // class java/lang/Number
     432: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     435: istore        8
     437: aload_1
     438: checkcast     #18                 // class java/lang/Iterable
     441: astore        10
     443: iconst_0
     444: istore        11
     446: aload         10
     448: astore        12
     450: new           #20                 // class java/util/ArrayList
     453: dup
     454: aload         10
     456: bipush        10
     458: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     461: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
     464: checkcast     #32                 // class java/util/Collection
     467: astore        13
     469: iconst_0
     470: istore        14
     472: aload         12
     474: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     479: astore        15
     481: aload         15
     483: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     488: ifeq          543
     491: aload         15
     493: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     498: astore        16
     500: aload         13
     502: aload         16
     504: checkcast     #48                 // class java/util/List
     507: astore        17
     509: astore        19
     511: iconst_0
     512: istore        18
     514: aload         17
     516: iconst_1
     517: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     522: checkcast     #56                 // class java/lang/Number
     525: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     528: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     531: aload         19
     533: swap
     534: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     539: pop
     540: goto          481
     543: aload         13
     545: checkcast     #48                 // class java/util/List
     548: nop
     549: checkcast     #18                 // class java/lang/Iterable
     552: invokestatic  #97                 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     555: dup
     556: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     559: checkcast     #56                 // class java/lang/Number
     562: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     565: istore        9
     567: iload         8
     569: istore        10
     571: iload         10
     573: iload         9
     575: if_icmpgt     798
     578: iload         6
     580: istore        11
     582: iload         11
     584: iload         7
     586: if_icmpgt     763
     589: new           #120                // class java/lang/StringBuilder
     592: dup
     593: invokespecial #122                // Method java/lang/StringBuilder."<init>":()V
     596: aload         5
     598: invokevirtual #126                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     601: aload_1
     602: checkcast     #18                 // class java/lang/Iterable
     605: astore        12
     607: astore        19
     609: iconst_0
     610: istore        13
     612: aload         12
     614: instanceof    #32                 // class java/util/Collection
     617: ifeq          637
     620: aload         12
     622: checkcast     #32                 // class java/util/Collection
     625: invokeinterface #129,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     630: ifeq          637
     633: iconst_0
     634: goto          726
     637: aload         12
     639: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     644: astore        14
     646: aload         14
     648: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     653: ifeq          725
     656: aload         14
     658: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     663: astore        15
     665: aload         15
     667: checkcast     #48                 // class java/util/List
     670: astore        16
     672: iconst_0
     673: istore        17
     675: aload         16
     677: iconst_0
     678: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     683: checkcast     #56                 // class java/lang/Number
     686: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     689: iload         11
     691: if_icmpne     717
     694: aload         16
     696: iconst_1
     697: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     702: checkcast     #56                 // class java/lang/Number
     705: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     708: iload         10
     710: if_icmpne     717
     713: iconst_1
     714: goto          718
     717: iconst_0
     718: ifeq          646
     721: iconst_1
     722: goto          726
     725: iconst_0
     726: istore        20
     728: aload         19
     730: iload         20
     732: ifeq          740
     735: bipush        35
     737: goto          742
     740: bipush        32
     742: invokevirtual #132                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     745: invokevirtual #136                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     748: astore        5
     750: iload         11
     752: iload         7
     754: if_icmpeq     763
     757: iinc          11, 1
     760: goto          589
     763: new           #120                // class java/lang/StringBuilder
     766: dup
     767: invokespecial #122                // Method java/lang/StringBuilder."<init>":()V
     770: aload         5
     772: invokevirtual #126                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     775: bipush        10
     777: invokevirtual #132                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     780: invokevirtual #136                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     783: astore        5
     785: iload         10
     787: iload         9
     789: if_icmpeq     798
     792: iinc          10, 1
     795: goto          578
     798: iload_3
     799: iconst_1
     800: isub
     801: istore        10
     803: getstatic     #142                // Field java/lang/System.out:Ljava/io/PrintStream;
     806: iload         10
     808: invokevirtual #147                // Method java/io/PrintStream.println:(I)V
     811: getstatic     #142                // Field java/lang/System.out:Ljava/io/PrintStream;
     814: aload         5
     816: invokevirtual #149                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     819: goto          838
     822: iload         4
     824: istore_2
     825: aload_0
     826: astore_1
     827: aload_0
     828: invokestatic  #151                // Method move:(Ljava/util/List;)Ljava/util/List;
     831: astore_0
     832: iinc          3, 1
     835: goto          25
     838: return

  static {};
    Code:
       0: new           #177                // class kotlin/text/Regex
       3: dup
       4: ldc           #179                // String position=<([- ]?[0-9]+), ([- ]?[0-9]+)> velocity=<([- ]?[0-9]+), ([- ]?[0-9]+)>
       6: invokespecial #182                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
       9: putstatic     #186                // Field lineRegex:Lkotlin/text/Regex;
      12: new           #188                // class java/io/File
      15: dup
      16: ldc           #190                // String day10.txt
      18: invokespecial #191                // Method java/io/File."<init>":(Ljava/lang/String;)V
      21: aconst_null
      22: iconst_1
      23: aconst_null
      24: invokestatic  #197                // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      27: checkcast     #18                 // class java/lang/Iterable
      30: astore_0
      31: iconst_0
      32: istore_1
      33: aload_0
      34: astore_2
      35: new           #20                 // class java/util/ArrayList
      38: dup
      39: aload_0
      40: bipush        10
      42: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      45: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      48: checkcast     #32                 // class java/util/Collection
      51: astore_3
      52: iconst_0
      53: istore        4
      55: aload_2
      56: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      61: astore        5
      63: aload         5
      65: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          368
      73: aload         5
      75: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      80: astore        6
      82: aload_3
      83: aload         6
      85: checkcast     #174                // class java/lang/String
      88: astore        7
      90: astore        11
      92: iconst_0
      93: istore        8
      95: getstatic     #186                // Field lineRegex:Lkotlin/text/Regex;
      98: aload         7
     100: checkcast     #199                // class java/lang/CharSequence
     103: invokestatic  #205                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     106: invokevirtual #206                // Method java/lang/Object.toString:()Ljava/lang/String;
     109: checkcast     #199                // class java/lang/CharSequence
     112: iconst_0
     113: iconst_2
     114: aconst_null
     115: invokestatic  #210                // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;
     118: astore        9
     120: iconst_4
     121: anewarray     #50                 // class java/lang/Integer
     124: astore        10
     126: aload         10
     128: iconst_0
     129: aload         9
     131: dup
     132: ifnull        176
     135: invokeinterface #216,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     140: dup
     141: ifnull        176
     144: iconst_1
     145: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     150: checkcast     #174                // class java/lang/String
     153: dup
     154: ifnull        176
     157: checkcast     #199                // class java/lang/CharSequence
     160: invokestatic  #205                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     163: invokevirtual #206                // Method java/lang/Object.toString:()Ljava/lang/String;
     166: dup
     167: ifnull        176
     170: invokestatic  #220                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     173: goto          178
     176: pop
     177: iconst_0
     178: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     181: aastore
     182: aload         10
     184: iconst_1
     185: aload         9
     187: dup
     188: ifnull        232
     191: invokeinterface #216,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     196: dup
     197: ifnull        232
     200: iconst_2
     201: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     206: checkcast     #174                // class java/lang/String
     209: dup
     210: ifnull        232
     213: checkcast     #199                // class java/lang/CharSequence
     216: invokestatic  #205                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     219: invokevirtual #206                // Method java/lang/Object.toString:()Ljava/lang/String;
     222: dup
     223: ifnull        232
     226: invokestatic  #220                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     229: goto          234
     232: pop
     233: iconst_0
     234: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     237: aastore
     238: aload         10
     240: iconst_2
     241: aload         9
     243: dup
     244: ifnull        288
     247: invokeinterface #216,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     252: dup
     253: ifnull        288
     256: iconst_3
     257: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     262: checkcast     #174                // class java/lang/String
     265: dup
     266: ifnull        288
     269: checkcast     #199                // class java/lang/CharSequence
     272: invokestatic  #205                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     275: invokevirtual #206                // Method java/lang/Object.toString:()Ljava/lang/String;
     278: dup
     279: ifnull        288
     282: invokestatic  #220                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     285: goto          290
     288: pop
     289: iconst_0
     290: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     293: aastore
     294: aload         10
     296: iconst_3
     297: aload         9
     299: dup
     300: ifnull        344
     303: invokeinterface #216,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     308: dup
     309: ifnull        344
     312: iconst_4
     313: invokeinterface #54,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     318: checkcast     #174                // class java/lang/String
     321: dup
     322: ifnull        344
     325: checkcast     #199                // class java/lang/CharSequence
     328: invokestatic  #205                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     331: invokevirtual #206                // Method java/lang/Object.toString:()Ljava/lang/String;
     334: dup
     335: ifnull        344
     338: invokestatic  #220                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     341: goto          346
     344: pop
     345: iconst_0
     346: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     349: aastore
     350: aload         10
     352: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     355: nop
     356: aload         11
     358: swap
     359: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     364: pop
     365: goto          63
     368: aload_3
     369: checkcast     #48                 // class java/util/List
     372: nop
     373: checkcast     #18                 // class java/lang/Iterable
     376: invokestatic  #76                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     379: putstatic     #112                // Field input:Ljava/util/List;
     382: return
}


package advent.of.code.day17

import java.io.File
import java.util.*

class Position(name1: String, val1: Int, val2: Int) : Comparable<Position> {
    val x: Int
    val y: Int

    init {
        if (name1 == "x") {
            x = val1
            y = val2
        } else {
            x = val2
            y = val1
        }
    }

    override fun compareTo(other: Position): Int {
        return compareBy<Position>({ it.y }, { it.x }).compare(this, other)
    }

    override fun toString(): String {
        return "(${x.toString().padStart(3, ' ')},${y.toString().padStart(3, ' ')})"
    }
}

val input = File("day17.txt")

val multipleCoord = Regex("(x|y)=([.0-9]+)\\.\\.([.0-9]+)")
val oneCoord = Regex("(x|y)=([.0-9]+)")

class Underground(input: File) {
    val clay: MutableSet<Position> = TreeSet()

    init {
        input.readLines().forEach { line ->
            val parts = line.split(",").map { it.trim() }
            var multiResult = multipleCoord.find(parts[0])
            if (multiResult != null) {
                val coordName1 = multiResult.groupValues[1]
                val startCoord1 = multiResult.groupValues[2].toInt()
                val endCoord1 = multiResult.groupValues[3].toInt()
                val oneResult = oneCoord.find(parts[1])
                val startCoord2 = oneResult!!.groupValues[2].toInt()
                for (c in (startCoord1..endCoord1))
                    clay.add(Position(coordName1, c, startCoord2))
            } else {
                val oneResult = oneCoord.find(parts[0])
                val coordName1 = oneResult!!.groupValues[1]
                val startCoord1 = oneResult.groupValues[2].toInt()
                multiResult = multipleCoord.find(parts[1])
                val startCoord2 = multiResult!!.groupValues[2].toInt()
                val endCoord2 = multiResult.groupValues[3].toInt()
                for (c in (startCoord2..endCoord2))
                    clay.add(Position(coordName1, startCoord1, c))
            }
        }
    }
}

fun part1(): Int {
    val underground = Underground(input)
    println(underground.clay)
    return 1
}

fun part2() = 2

Compiled from "Solution.kt"
public final class advent.of.code.day17.SolutionKt {
  private static final java.io.File input;

  private static final kotlin.text.Regex multipleCoord;

  private static final kotlin.text.Regex oneCoord;

  public static final java.io.File getInput();
    Code:
       0: getstatic     #11                 // Field input:Ljava/io/File;
       3: areturn

  public static final kotlin.text.Regex getMultipleCoord();
    Code:
       0: getstatic     #17                 // Field multipleCoord:Lkotlin/text/Regex;
       3: areturn

  public static final kotlin.text.Regex getOneCoord();
    Code:
       0: getstatic     #21                 // Field oneCoord:Lkotlin/text/Regex;
       3: areturn

  public static final int part1();
    Code:
       0: new           #25                 // class advent/of/code/day17/Underground
       3: dup
       4: getstatic     #11                 // Field input:Ljava/io/File;
       7: invokespecial #29                 // Method advent/of/code/day17/Underground."<init>":(Ljava/io/File;)V
      10: astore_0
      11: aload_0
      12: invokevirtual #33                 // Method advent/of/code/day17/Underground.getClay:()Ljava/util/Set;
      15: getstatic     #39                 // Field java/lang/System.out:Ljava/io/PrintStream;
      18: swap
      19: invokevirtual #45                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      22: iconst_1
      23: ireturn

  public static final int part2();
    Code:
       0: iconst_2
       1: ireturn

  static {};
    Code:
       0: new           #52                 // class java/io/File
       3: dup
       4: ldc           #54                 // String day17.txt
       6: invokespecial #57                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: putstatic     #11                 // Field input:Ljava/io/File;
      12: new           #59                 // class kotlin/text/Regex
      15: dup
      16: ldc           #61                 // String (x|y)=([.0-9]+)\\.\\.([.0-9]+)
      18: invokespecial #62                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      21: putstatic     #17                 // Field multipleCoord:Lkotlin/text/Regex;
      24: new           #59                 // class kotlin/text/Regex
      27: dup
      28: ldc           #64                 // String (x|y)=([.0-9]+)
      30: invokespecial #62                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      33: putstatic     #21                 // Field oneCoord:Lkotlin/text/Regex;
      36: return
}


package com.igorwojda.string.issubstring

//Kotlin Idiomatic Approach
private object Solution1 {
    private fun isSubstring(str: String, subStr: String): Boolean {
        return str.contains(subStr) && str.isNotEmpty() && subStr.isNotEmpty()
    }
}

// Time complexity: O(n+m)
// Space complexity: O(1)
//
// Optimal solution using double pointer.
private object Solution2 {
    private fun isSubstring(str: String, subStr: String): Boolean {
        if (str.isEmpty() || subStr.isEmpty()) return false
        if (str.length <= subStr.length) return false

        var pointer1 = 0
        var pointer2 = 0

        while (pointer1 <= str.lastIndex) {
            if (str[pointer1] == subStr[pointer2]) {
                pointer2++
            }

            if (pointer2 == subStr.length) {
                return true
            }

            pointer1++
        }

        return false
    }
}

// Time complexity: O(n+m)
// Space complexity: ??, but more than O(1)
// Number of iterations (n) is bounded by the length of the first string
// and String.drop requires copying the entire remaining string (on it's own it has O(m) complexity)
// First of 5 chars, needs 5 iterations at most and 15 character copied (5+4+3+2+1=15). Second is copied less often.
//
// Recursive solution
private object Solution3 {
    private fun isSubstring(str: String, subStr: String): Boolean {
        if (subStr.length > str.length) {
            return false
        }

        if (str.isEmpty() || subStr.isEmpty()) {
            return false
        }

        return if (str.first() == subStr.first()) {
            val localStr = str.drop(1)
            val localSubStr = subStr.drop(1)

            if (localStr.first() == localSubStr.first()) {
                true
            } else {
                isSubstring(localStr, localSubStr.drop(1))
            }
        } else {
            isSubstring(str.drop(1), subStr)
        }
    }
}

// Time complexity: O(n)
// Space complexity: O(1)
// This recursive solution is faster than solution with String.drop because it uses double pointer
//
// Recursive solution

private fun isSubstring(str: String, subStr: String): Boolean {
    if (str.isEmpty() || subStr.isEmpty()) {
        return false
    }

    fun helper(first: String, second: String, firstPointer1: Int = 0, secondPointer2: Int = 0): Boolean {
        if (firstPointer1 > first.lastIndex) {
            return false
        }

        return if (first[firstPointer1] == second[secondPointer2]) {
            val localPointer1 = firstPointer1 + 1
            val localPointer2 = secondPointer2 + 1

            if (localPointer1 > first.lastIndex || localPointer2 > second.lastIndex) {
                return true
            } else {
                helper(first, second, localPointer1, localPointer2)
            }
        } else {
            val p1 = firstPointer1 + 1

            if (p1 > first.lastIndex) {
                return false
            } else {
                helper(first, second, p1, secondPointer2)
            }
        }
    }

    return helper(str, subStr)
}

Compiled from "solution.kt"
public final class com.igorwojda.string.issubstring.SolutionKt {
  private static final boolean isSubstring(java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #8                  // class java/lang/CharSequence
       4: invokeinterface #12,  1           // InterfaceMethod java/lang/CharSequence.length:()I
       9: ifne          16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ifne          40
      20: aload_1
      21: checkcast     #8                  // class java/lang/CharSequence
      24: invokeinterface #12,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      29: ifne          36
      32: iconst_1
      33: goto          37
      36: iconst_0
      37: ifeq          42
      40: iconst_0
      41: ireturn
      42: aload_0
      43: aload_1
      44: iconst_0
      45: iconst_0
      46: bipush        12
      48: aconst_null
      49: invokestatic  #16                 // Method isSubstring$helper$default:(Ljava/lang/String;Ljava/lang/String;IIILjava/lang/Object;)Z
      52: ireturn

  private static final boolean isSubstring$helper(java.lang.String, java.lang.String, int, int);
    Code:
       0: iload_2
       1: aload_0
       2: checkcast     #8                  // class java/lang/CharSequence
       5: invokestatic  #27                 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
       8: if_icmple     13
      11: iconst_0
      12: ireturn
      13: aload_0
      14: iload_2
      15: invokevirtual #33                 // Method java/lang/String.charAt:(I)C
      18: aload_1
      19: iload_3
      20: invokevirtual #33                 // Method java/lang/String.charAt:(I)C
      23: if_icmpne     74
      26: iload_2
      27: iconst_1
      28: iadd
      29: istore        4
      31: iload_3
      32: iconst_1
      33: iadd
      34: istore        5
      36: iload         4
      38: aload_0
      39: checkcast     #8                  // class java/lang/CharSequence
      42: invokestatic  #27                 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      45: if_icmpgt     60
      48: iload         5
      50: aload_1
      51: checkcast     #8                  // class java/lang/CharSequence
      54: invokestatic  #27                 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      57: if_icmple     62
      60: iconst_1
      61: ireturn
      62: aload_0
      63: aload_1
      64: iload         4
      66: iload         5
      68: invokestatic  #35                 // Method isSubstring$helper:(Ljava/lang/String;Ljava/lang/String;II)Z
      71: goto          101
      74: iload_2
      75: iconst_1
      76: iadd
      77: istore        4
      79: iload         4
      81: aload_0
      82: checkcast     #8                  // class java/lang/CharSequence
      85: invokestatic  #27                 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      88: if_icmple     93
      91: iconst_0
      92: ireturn
      93: aload_0
      94: aload_1
      95: iload         4
      97: iload_3
      98: invokestatic  #35                 // Method isSubstring$helper:(Ljava/lang/String;Ljava/lang/String;II)Z
     101: ireturn

  static boolean isSubstring$helper$default(java.lang.String, java.lang.String, int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_4
       3: iand
       4: ifeq          9
       7: iconst_0
       8: istore_2
       9: iload         4
      11: bipush        8
      13: iand
      14: ifeq          19
      17: iconst_0
      18: istore_3
      19: aload_0
      20: aload_1
      21: iload_2
      22: iload_3
      23: invokestatic  #35                 // Method isSubstring$helper:(Ljava/lang/String;Ljava/lang/String;II)Z
      26: ireturn
}