object Puzzle17 {

    @JvmStatic
    fun main(args: Array<String>) {
        val input = Puzzle17::class.java.getResource("puzzle17.txt").readText()
        val calculatedActiveCountIn3D = calculateActiveCountIn3D(input)
        println(calculatedActiveCountIn3D)
        val calculatedActiveCountIn4D = calculateActiveCountIn4D(input)
        println(calculatedActiveCountIn4D)
    }

    fun calculateActiveCountIn3D(input: String): Int {
        var state = State3D(input)
        for (i in 1..6){
            state = state.getNextState()
        }
        return state.countActiveCells()
    }

    fun calculateActiveCountIn4D(input: String): Int {
        var state = State4D(input)
        for (i in 1..6){
            state = state.getNextState()
        }
        return state.countActiveCells()
    }

    class State3D{
        private val grid: List<List<CharArray>>

        constructor(input: String){
            val initialState = input.split("\n").map { line -> line.toCharArray() }
            grid = listOf(initialState)
        }

        constructor(grid: List<List<CharArray>>){
            this.grid = grid
        }

        private fun zDimension() = grid.size
        private fun yDimension() = grid.first().size
        private fun xDimension() = grid.first().first().size

        private fun getGridAt(z: Int, y: Int, x: Int): Char{
            return if (z in 0 until zDimension()
                && y in 0 until yDimension()
                && x in 0 until xDimension()){
                grid[z][y][x]
            }else '.'
        }

        fun getNextState(): State3D {
            val nextState = mutableListOf<List<CharArray>>()
            val nextXDimension = xDimension() + 2
            val nextYDimension = yDimension() + 2
            val nextZDimension = zDimension() + 2
            for (z in 0 until nextZDimension) {
                val rows = mutableListOf<CharArray>()
                for (y in 0 until nextYDimension) {
                    val row = CharArray(nextXDimension)
                    for (x in 0 until nextXDimension) {
                        val currentStateZ = z - 1
                        val currentStateY = y - 1
                        val currentStateX = x - 1
                        val activeNeighbourCount = activeNeighbourCount(currentStateZ, currentStateY, currentStateX)
                        row[x] =
                            if (getGridAt(currentStateZ, currentStateY, currentStateX) == '#') {
                                if (activeNeighbourCount == 2 || activeNeighbourCount == 3) '#'
                                else '.'
                            } else if (activeNeighbourCount == 3) '#'
                            else '.'
                    }
                    rows.add(row)
                }
                nextState.add(rows)
            }
            return State3D(nextState)
        }

        private fun activeNeighbourCount(z: Int, y: Int, x: Int): Int {
            var count = 0
            for (i in -1..1)
                for (j in -1..1)
                    for (k in -1..1){
                        if (
                            (i != 0 || j != 0 || k != 0)
                            && getGridAt(z+k, y+j, x+i) == '#'
                        ){
                            count++
                        }
                    }
            return count
        }

        fun countActiveCells(): Int {
            return grid.sumOf { z -> z.sumOf { y -> y.count { x -> x == '#' } }}
        }
    }

    class State4D{
        private val grid: List<List<List<CharArray>>>

        constructor(input: String){
            val initialState = input.split("\n").map { line -> line.toCharArray() }
            grid = listOf(listOf(initialState))
        }

        constructor(grid: List<List<List<CharArray>>>){
            this.grid = grid
        }

        private fun wDimension() = grid.size
        private fun zDimension() = grid.first().size
        private fun yDimension() = grid.first().first().size
        private fun xDimension() = grid.first().first().first().size

        private fun getGridAt(w: Int, z: Int, y: Int, x: Int): Char{
            return if ( w in 0 until wDimension()
                && z in 0 until zDimension()
                && y in 0 until yDimension()
                && x in 0 until xDimension()){
                grid[w][z][y][x]
            }else '.'
        }

        fun getNextState(): State4D {
            val nextState = mutableListOf<List<List<CharArray>>>()
            val nextXDimension = xDimension() + 2
            val nextYDimension = yDimension() + 2
            val nextZDimension = zDimension() + 2
            val nextWDimension = wDimension() + 2
            for (w in 0 until nextWDimension) {
                val layers = mutableListOf<List<CharArray>>()
                for (z in 0 until nextZDimension) {
                    val rows = mutableListOf<CharArray>()
                    for (y in 0 until nextYDimension) {
                        val row = CharArray(nextXDimension)
                        for (x in 0 until nextXDimension) {
                            val currentStateW = w - 1
                            val currentStateZ = z - 1
                            val currentStateY = y - 1
                            val currentStateX = x - 1
                            val activeNeighbourCount = activeNeighbourCount(currentStateW, currentStateZ, currentStateY, currentStateX)
                            row[x] =
                                if (getGridAt(currentStateW, currentStateZ, currentStateY, currentStateX) == '#') {
                                    if (activeNeighbourCount == 2 || activeNeighbourCount == 3) '#'
                                    else '.'
                                } else if (activeNeighbourCount == 3) '#'
                                else '.'
                        }
                        rows.add(row)
                    }
                    layers.add(rows)
                }
                nextState.add(layers)
            }
            return State4D(nextState)
        }

        private fun activeNeighbourCount(w: Int, z: Int, y: Int, x: Int): Int {
            var count = 0
            for (i in -1..1)
                for (j in -1..1)
                    for (k in -1..1)
                        for (l in -1..1){
                            if (
                                (i != 0 || j != 0 || k != 0 || l != 0)
                                && getGridAt(w+l,z+k, y+j, x+i) == '#'
                            ){
                                count++
                            }
                    }
            return count
        }

        fun countActiveCells(): Int {
            return grid.sumOf { w -> w.sumOf { z -> z.sumOf { y -> y.count { x -> x == '#' } }}}
        }
    }
}

Compiled from "Puzzle17.kt"
public final class Puzzle17$State3D {
  private final java.util.List<java.util.List<char[]>> grid;

  public Puzzle17$State3D(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_1
      11: checkcast     #20                 // class java/lang/CharSequence
      14: iconst_1
      15: anewarray     #22                 // class java/lang/String
      18: astore_3
      19: aload_3
      20: iconst_0
      21: ldc           #24                 // String \n
      23: aastore
      24: aload_3
      25: iconst_0
      26: iconst_0
      27: bipush        6
      29: aconst_null
      30: invokestatic  #30                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      33: checkcast     #32                 // class java/lang/Iterable
      36: astore_3
      37: iconst_0
      38: istore        4
      40: aload_3
      41: astore        5
      43: new           #34                 // class java/util/ArrayList
      46: dup
      47: aload_3
      48: bipush        10
      50: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      53: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
      56: checkcast     #45                 // class java/util/Collection
      59: astore        6
      61: iconst_0
      62: istore        7
      64: aload         5
      66: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        8
      73: aload         8
      75: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          130
      83: aload         8
      85: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: astore        9
      92: aload         6
      94: aload         9
      96: checkcast     #22                 // class java/lang/String
      99: astore        10
     101: astore        12
     103: iconst_0
     104: istore        11
     106: aload         10
     108: invokevirtual #63                 // Method java/lang/String.toCharArray:()[C
     111: dup
     112: ldc           #65                 // String toCharArray(...)
     114: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     117: nop
     118: aload         12
     120: swap
     121: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     126: pop
     127: goto          73
     130: aload         6
     132: checkcast     #74                 // class java/util/List
     135: nop
     136: astore_2
     137: aload_0
     138: aload_2
     139: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     142: putfield      #82                 // Field grid:Ljava/util/List;
     145: return

  public Puzzle17$State3D(java.util.List<? extends java.util.List<char[]>>);
    Code:
       0: aload_1
       1: ldc           #101                // String grid
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #82                 // Field grid:Ljava/util/List;
      15: return

  private final int zDimension();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: invokeinterface #106,  1          // InterfaceMethod java/util/List.size:()I
       9: ireturn

  private final int yDimension();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       7: checkcast     #74                 // class java/util/List
      10: invokeinterface #106,  1          // InterfaceMethod java/util/List.size:()I
      15: ireturn

  private final int xDimension();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       7: checkcast     #74                 // class java/util/List
      10: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      13: checkcast     #114                // class "[C"
      16: arraylength
      17: ireturn

  private final char getGridAt(int, int, int);
    Code:
       0: iconst_0
       1: iload_1
       2: if_icmpgt     21
       5: iload_1
       6: aload_0
       7: invokespecial #118                // Method zDimension:()I
      10: if_icmpge     17
      13: iconst_1
      14: goto          22
      17: iconst_0
      18: goto          22
      21: iconst_0
      22: ifeq          102
      25: iconst_0
      26: iload_2
      27: if_icmpgt     46
      30: iload_2
      31: aload_0
      32: invokespecial #120                // Method yDimension:()I
      35: if_icmpge     42
      38: iconst_1
      39: goto          47
      42: iconst_0
      43: goto          47
      46: iconst_0
      47: ifeq          102
      50: iconst_0
      51: iload_3
      52: if_icmpgt     71
      55: iload_3
      56: aload_0
      57: invokespecial #122                // Method xDimension:()I
      60: if_icmpge     67
      63: iconst_1
      64: goto          72
      67: iconst_0
      68: goto          72
      71: iconst_0
      72: ifeq          102
      75: aload_0
      76: getfield      #82                 // Field grid:Ljava/util/List;
      79: iload_1
      80: invokeinterface #126,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      85: checkcast     #74                 // class java/util/List
      88: iload_2
      89: invokeinterface #126,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      94: checkcast     #114                // class "[C"
      97: iload_3
      98: caload
      99: goto          104
     102: bipush        46
     104: ireturn

  public final Puzzle17$State3D getNextState();
    Code:
       0: new           #34                 // class java/util/ArrayList
       3: dup
       4: invokespecial #132                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #74                 // class java/util/List
      10: astore_1
      11: aload_0
      12: invokespecial #122                // Method xDimension:()I
      15: iconst_2
      16: iadd
      17: istore_2
      18: aload_0
      19: invokespecial #120                // Method yDimension:()I
      22: iconst_2
      23: iadd
      24: istore_3
      25: aload_0
      26: invokespecial #118                // Method zDimension:()I
      29: iconst_2
      30: iadd
      31: istore        4
      33: iconst_0
      34: istore        5
      36: iload         5
      38: iload         4
      40: if_icmpge     213
      43: new           #34                 // class java/util/ArrayList
      46: dup
      47: invokespecial #132                // Method java/util/ArrayList."<init>":()V
      50: checkcast     #74                 // class java/util/List
      53: astore        6
      55: iconst_0
      56: istore        7
      58: iload         7
      60: iload_3
      61: if_icmpge     198
      64: iload_2
      65: newarray       char
      67: astore        8
      69: iconst_0
      70: istore        9
      72: iload         9
      74: iload_2
      75: if_icmpge     182
      78: iload         5
      80: iconst_1
      81: isub
      82: istore        10
      84: iload         7
      86: iconst_1
      87: isub
      88: istore        11
      90: iload         9
      92: iconst_1
      93: isub
      94: istore        12
      96: aload_0
      97: iload         10
      99: iload         11
     101: iload         12
     103: invokespecial #136                // Method activeNeighbourCount:(III)I
     106: istore        13
     108: aload         8
     110: iload         9
     112: aload_0
     113: iload         10
     115: iload         11
     117: iload         12
     119: invokespecial #138                // Method getGridAt:(III)C
     122: bipush        35
     124: if_icmpne     162
     127: iload         13
     129: tableswitch   { // 2 to 3
                     2: 152
                     3: 152
               default: 157
          }
     152: bipush        35
     154: goto          175
     157: bipush        46
     159: goto          175
     162: iload         13
     164: iconst_3
     165: if_icmpne     173
     168: bipush        35
     170: goto          175
     173: bipush        46
     175: castore
     176: iinc          9, 1
     179: goto          72
     182: aload         6
     184: aload         8
     186: invokeinterface #139,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     191: pop
     192: iinc          7, 1
     195: goto          58
     198: aload_1
     199: aload         6
     201: invokeinterface #139,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     206: pop
     207: iinc          5, 1
     210: goto          36
     213: new           #2                  // class Puzzle17$State3D
     216: dup
     217: aload_1
     218: invokespecial #141                // Method "<init>":(Ljava/util/List;)V
     221: areturn

  private final int activeNeighbourCount(int, int, int);
    Code:
       0: iconst_0
       1: istore        4
       3: iconst_m1
       4: istore        5
       6: iload         5
       8: iconst_2
       9: if_icmpge     87
      12: iconst_m1
      13: istore        6
      15: iload         6
      17: iconst_2
      18: if_icmpge     81
      21: iconst_m1
      22: istore        7
      24: iload         7
      26: iconst_2
      27: if_icmpge     75
      30: iload         5
      32: ifne          45
      35: iload         6
      37: ifne          45
      40: iload         7
      42: ifeq          69
      45: aload_0
      46: iload_1
      47: iload         7
      49: iadd
      50: iload_2
      51: iload         6
      53: iadd
      54: iload_3
      55: iload         5
      57: iadd
      58: invokespecial #138                // Method getGridAt:(III)C
      61: bipush        35
      63: if_icmpne     69
      66: iinc          4, 1
      69: iinc          7, 1
      72: goto          24
      75: iinc          6, 1
      78: goto          15
      81: iinc          5, 1
      84: goto          6
      87: iload         4
      89: ireturn

  public final int countActiveCells();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: checkcast     #32                 // class java/lang/Iterable
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      16: astore_3
      17: aload_3
      18: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifeq          191
      26: aload_3
      27: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      32: astore        4
      34: iload_2
      35: aload         4
      37: checkcast     #74                 // class java/util/List
      40: astore        5
      42: istore        23
      44: iconst_0
      45: istore        6
      47: aload         5
      49: checkcast     #32                 // class java/lang/Iterable
      52: astore        7
      54: iconst_0
      55: istore        8
      57: aload         7
      59: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      64: astore        9
      66: aload         9
      68: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      73: ifeq          177
      76: aload         9
      78: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      83: astore        10
      85: iload         8
      87: aload         10
      89: checkcast     #114                // class "[C"
      92: astore        11
      94: istore        12
      96: iconst_0
      97: istore        13
      99: aload         11
     101: astore        14
     103: iconst_0
     104: istore        15
     106: iconst_0
     107: istore        16
     109: iconst_0
     110: istore        17
     112: aload         14
     114: arraylength
     115: istore        18
     117: iload         17
     119: iload         18
     121: if_icmpge     162
     124: aload         14
     126: iload         17
     128: caload
     129: istore        19
     131: iload         19
     133: istore        20
     135: iconst_0
     136: istore        21
     138: iload         20
     140: bipush        35
     142: if_icmpne     149
     145: iconst_1
     146: goto          150
     149: iconst_0
     150: ifeq          156
     153: iinc          16, 1
     156: iinc          17, 1
     159: goto          117
     162: iload         16
     164: nop
     165: istore        22
     167: iload         12
     169: iload         22
     171: iadd
     172: istore        8
     174: goto          66
     177: iload         8
     179: nop
     180: istore        24
     182: iload         23
     184: iload         24
     186: iadd
     187: istore_2
     188: goto          17
     191: iload_2
     192: ireturn
}

Compiled from "Puzzle17.kt"
public final class Puzzle17$State4D {
  private final java.util.List<java.util.List<java.util.List<char[]>>> grid;

  public Puzzle17$State4D(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_1
      11: checkcast     #20                 // class java/lang/CharSequence
      14: iconst_1
      15: anewarray     #22                 // class java/lang/String
      18: astore_3
      19: aload_3
      20: iconst_0
      21: ldc           #24                 // String \n
      23: aastore
      24: aload_3
      25: iconst_0
      26: iconst_0
      27: bipush        6
      29: aconst_null
      30: invokestatic  #30                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      33: checkcast     #32                 // class java/lang/Iterable
      36: astore_3
      37: iconst_0
      38: istore        4
      40: aload_3
      41: astore        5
      43: new           #34                 // class java/util/ArrayList
      46: dup
      47: aload_3
      48: bipush        10
      50: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      53: invokespecial #43                 // Method java/util/ArrayList."<init>":(I)V
      56: checkcast     #45                 // class java/util/Collection
      59: astore        6
      61: iconst_0
      62: istore        7
      64: aload         5
      66: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        8
      73: aload         8
      75: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          130
      83: aload         8
      85: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: astore        9
      92: aload         6
      94: aload         9
      96: checkcast     #22                 // class java/lang/String
      99: astore        10
     101: astore        12
     103: iconst_0
     104: istore        11
     106: aload         10
     108: invokevirtual #63                 // Method java/lang/String.toCharArray:()[C
     111: dup
     112: ldc           #65                 // String toCharArray(...)
     114: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     117: nop
     118: aload         12
     120: swap
     121: invokeinterface #72,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     126: pop
     127: goto          73
     130: aload         6
     132: checkcast     #74                 // class java/util/List
     135: nop
     136: astore_2
     137: aload_0
     138: aload_2
     139: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     142: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     145: putfield      #82                 // Field grid:Ljava/util/List;
     148: return

  public Puzzle17$State4D(java.util.List<? extends java.util.List<? extends java.util.List<char[]>>>);
    Code:
       0: aload_1
       1: ldc           #101                // String grid
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #82                 // Field grid:Ljava/util/List;
      15: return

  private final int wDimension();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: invokeinterface #106,  1          // InterfaceMethod java/util/List.size:()I
       9: ireturn

  private final int zDimension();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       7: checkcast     #74                 // class java/util/List
      10: invokeinterface #106,  1          // InterfaceMethod java/util/List.size:()I
      15: ireturn

  private final int yDimension();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       7: checkcast     #74                 // class java/util/List
      10: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      13: checkcast     #74                 // class java/util/List
      16: invokeinterface #106,  1          // InterfaceMethod java/util/List.size:()I
      21: ireturn

  private final int xDimension();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       7: checkcast     #74                 // class java/util/List
      10: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      13: checkcast     #74                 // class java/util/List
      16: invokestatic  #111                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      19: checkcast     #115                // class "[C"
      22: arraylength
      23: ireturn

  private final char getGridAt(int, int, int, int);
    Code:
       0: iconst_0
       1: iload_1
       2: if_icmpgt     21
       5: iload_1
       6: aload_0
       7: invokespecial #119                // Method wDimension:()I
      10: if_icmpge     17
      13: iconst_1
      14: goto          22
      17: iconst_0
      18: goto          22
      21: iconst_0
      22: ifeq          139
      25: iconst_0
      26: iload_2
      27: if_icmpgt     46
      30: iload_2
      31: aload_0
      32: invokespecial #121                // Method zDimension:()I
      35: if_icmpge     42
      38: iconst_1
      39: goto          47
      42: iconst_0
      43: goto          47
      46: iconst_0
      47: ifeq          139
      50: iconst_0
      51: iload_3
      52: if_icmpgt     71
      55: iload_3
      56: aload_0
      57: invokespecial #123                // Method yDimension:()I
      60: if_icmpge     67
      63: iconst_1
      64: goto          72
      67: iconst_0
      68: goto          72
      71: iconst_0
      72: ifeq          139
      75: iconst_0
      76: iload         4
      78: if_icmpgt     98
      81: iload         4
      83: aload_0
      84: invokespecial #125                // Method xDimension:()I
      87: if_icmpge     94
      90: iconst_1
      91: goto          99
      94: iconst_0
      95: goto          99
      98: iconst_0
      99: ifeq          139
     102: aload_0
     103: getfield      #82                 // Field grid:Ljava/util/List;
     106: iload_1
     107: invokeinterface #129,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     112: checkcast     #74                 // class java/util/List
     115: iload_2
     116: invokeinterface #129,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     121: checkcast     #74                 // class java/util/List
     124: iload_3
     125: invokeinterface #129,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     130: checkcast     #115                // class "[C"
     133: iload         4
     135: caload
     136: goto          141
     139: bipush        46
     141: ireturn

  public final Puzzle17$State4D getNextState();
    Code:
       0: new           #34                 // class java/util/ArrayList
       3: dup
       4: invokespecial #136                // Method java/util/ArrayList."<init>":()V
       7: checkcast     #74                 // class java/util/List
      10: astore_1
      11: aload_0
      12: invokespecial #125                // Method xDimension:()I
      15: iconst_2
      16: iadd
      17: istore_2
      18: aload_0
      19: invokespecial #123                // Method yDimension:()I
      22: iconst_2
      23: iadd
      24: istore_3
      25: aload_0
      26: invokespecial #121                // Method zDimension:()I
      29: iconst_2
      30: iadd
      31: istore        4
      33: aload_0
      34: invokespecial #119                // Method wDimension:()I
      37: iconst_2
      38: iadd
      39: istore        5
      41: iconst_0
      42: istore        6
      44: iload         6
      46: iload         5
      48: if_icmpge     269
      51: new           #34                 // class java/util/ArrayList
      54: dup
      55: invokespecial #136                // Method java/util/ArrayList."<init>":()V
      58: checkcast     #74                 // class java/util/List
      61: astore        7
      63: iconst_0
      64: istore        8
      66: iload         8
      68: iload         4
      70: if_icmpge     254
      73: new           #34                 // class java/util/ArrayList
      76: dup
      77: invokespecial #136                // Method java/util/ArrayList."<init>":()V
      80: checkcast     #74                 // class java/util/List
      83: astore        9
      85: iconst_0
      86: istore        10
      88: iload         10
      90: iload_3
      91: if_icmpge     238
      94: iload_2
      95: newarray       char
      97: astore        11
      99: iconst_0
     100: istore        12
     102: iload         12
     104: iload_2
     105: if_icmpge     222
     108: iload         6
     110: iconst_1
     111: isub
     112: istore        13
     114: iload         8
     116: iconst_1
     117: isub
     118: istore        14
     120: iload         10
     122: iconst_1
     123: isub
     124: istore        15
     126: iload         12
     128: iconst_1
     129: isub
     130: istore        16
     132: aload_0
     133: iload         13
     135: iload         14
     137: iload         15
     139: iload         16
     141: invokespecial #140                // Method activeNeighbourCount:(IIII)I
     144: istore        17
     146: aload         11
     148: iload         12
     150: aload_0
     151: iload         13
     153: iload         14
     155: iload         15
     157: iload         16
     159: invokespecial #142                // Method getGridAt:(IIII)C
     162: bipush        35
     164: if_icmpne     202
     167: iload         17
     169: tableswitch   { // 2 to 3
                     2: 192
                     3: 192
               default: 197
          }
     192: bipush        35
     194: goto          215
     197: bipush        46
     199: goto          215
     202: iload         17
     204: iconst_3
     205: if_icmpne     213
     208: bipush        35
     210: goto          215
     213: bipush        46
     215: castore
     216: iinc          12, 1
     219: goto          102
     222: aload         9
     224: aload         11
     226: invokeinterface #143,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     231: pop
     232: iinc          10, 1
     235: goto          88
     238: aload         7
     240: aload         9
     242: invokeinterface #143,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     247: pop
     248: iinc          8, 1
     251: goto          66
     254: aload_1
     255: aload         7
     257: invokeinterface #143,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     262: pop
     263: iinc          6, 1
     266: goto          44
     269: new           #2                  // class Puzzle17$State4D
     272: dup
     273: aload_1
     274: invokespecial #145                // Method "<init>":(Ljava/util/List;)V
     277: areturn

  private final int activeNeighbourCount(int, int, int, int);
    Code:
       0: iconst_0
       1: istore        5
       3: iconst_m1
       4: istore        6
       6: iload         6
       8: iconst_2
       9: if_icmpge     112
      12: iconst_m1
      13: istore        7
      15: iload         7
      17: iconst_2
      18: if_icmpge     106
      21: iconst_m1
      22: istore        8
      24: iload         8
      26: iconst_2
      27: if_icmpge     100
      30: iconst_m1
      31: istore        9
      33: iload         9
      35: iconst_2
      36: if_icmpge     94
      39: iload         6
      41: ifne          59
      44: iload         7
      46: ifne          59
      49: iload         8
      51: ifne          59
      54: iload         9
      56: ifeq          88
      59: aload_0
      60: iload_1
      61: iload         9
      63: iadd
      64: iload_2
      65: iload         8
      67: iadd
      68: iload_3
      69: iload         7
      71: iadd
      72: iload         4
      74: iload         6
      76: iadd
      77: invokespecial #142                // Method getGridAt:(IIII)C
      80: bipush        35
      82: if_icmpne     88
      85: iinc          5, 1
      88: iinc          9, 1
      91: goto          33
      94: iinc          8, 1
      97: goto          24
     100: iinc          7, 1
     103: goto          15
     106: iinc          6, 1
     109: goto          6
     112: iload         5
     114: ireturn

  public final int countActiveCells();
    Code:
       0: aload_0
       1: getfield      #82                 // Field grid:Ljava/util/List;
       4: checkcast     #32                 // class java/lang/Iterable
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      16: astore_3
      17: aload_3
      18: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifeq          258
      26: aload_3
      27: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      32: astore        4
      34: iload_2
      35: aload         4
      37: checkcast     #74                 // class java/util/List
      40: astore        5
      42: istore        31
      44: iconst_0
      45: istore        6
      47: aload         5
      49: checkcast     #32                 // class java/lang/Iterable
      52: astore        7
      54: iconst_0
      55: istore        8
      57: aload         7
      59: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      64: astore        9
      66: aload         9
      68: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      73: ifeq          244
      76: aload         9
      78: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      83: astore        10
      85: iload         8
      87: aload         10
      89: checkcast     #74                 // class java/util/List
      92: astore        11
      94: istore        12
      96: iconst_0
      97: istore        13
      99: aload         11
     101: checkcast     #32                 // class java/lang/Iterable
     104: astore        14
     106: iconst_0
     107: istore        15
     109: aload         14
     111: invokeinterface #49,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     116: astore        16
     118: aload         16
     120: invokeinterface #55,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     125: ifeq          229
     128: aload         16
     130: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     135: astore        17
     137: iload         15
     139: aload         17
     141: checkcast     #115                // class "[C"
     144: astore        18
     146: istore        19
     148: iconst_0
     149: istore        20
     151: aload         18
     153: astore        21
     155: iconst_0
     156: istore        22
     158: iconst_0
     159: istore        23
     161: iconst_0
     162: istore        24
     164: aload         21
     166: arraylength
     167: istore        25
     169: iload         24
     171: iload         25
     173: if_icmpge     214
     176: aload         21
     178: iload         24
     180: caload
     181: istore        26
     183: iload         26
     185: istore        27
     187: iconst_0
     188: istore        28
     190: iload         27
     192: bipush        35
     194: if_icmpne     201
     197: iconst_1
     198: goto          202
     201: iconst_0
     202: ifeq          208
     205: iinc          23, 1
     208: iinc          24, 1
     211: goto          169
     214: iload         23
     216: nop
     217: istore        29
     219: iload         19
     221: iload         29
     223: iadd
     224: istore        15
     226: goto          118
     229: iload         15
     231: nop
     232: istore        30
     234: iload         12
     236: iload         30
     238: iadd
     239: istore        8
     241: goto          66
     244: iload         8
     246: nop
     247: istore        32
     249: iload         31
     251: iload         32
     253: iadd
     254: istore_2
     255: goto          17
     258: iload_2
     259: ireturn
}

Compiled from "Puzzle17.kt"
public final class Puzzle17 {
  public static final Puzzle17 INSTANCE;

  private Puzzle17();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #16                 // String args
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #2                  // class Puzzle17
       8: ldc           #24                 // String puzzle17.txt
      10: invokevirtual #30                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      13: dup
      14: ldc           #32                 // String getResource(...)
      16: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      19: astore_2
      20: getstatic     #41                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      23: astore_3
      24: aload_2
      25: invokestatic  #47                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      28: astore        4
      30: new           #49                 // class java/lang/String
      33: dup
      34: aload         4
      36: aload_3
      37: invokespecial #52                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      40: astore_1
      41: getstatic     #55                 // Field INSTANCE:LPuzzle17;
      44: aload_1
      45: invokevirtual #59                 // Method calculateActiveCountIn3D:(Ljava/lang/String;)I
      48: istore_2
      49: getstatic     #65                 // Field java/lang/System.out:Ljava/io/PrintStream;
      52: iload_2
      53: invokevirtual #71                 // Method java/io/PrintStream.println:(I)V
      56: getstatic     #55                 // Field INSTANCE:LPuzzle17;
      59: aload_1
      60: invokevirtual #74                 // Method calculateActiveCountIn4D:(Ljava/lang/String;)I
      63: istore_3
      64: getstatic     #65                 // Field java/lang/System.out:Ljava/io/PrintStream;
      67: iload_3
      68: invokevirtual #71                 // Method java/io/PrintStream.println:(I)V
      71: return

  public final int calculateActiveCountIn3D(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #81                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #83                 // class Puzzle17$State3D
       9: dup
      10: aload_1
      11: invokespecial #86                 // Method Puzzle17$State3D."<init>":(Ljava/lang/String;)V
      14: astore_2
      15: iconst_1
      16: istore_3
      17: iload_3
      18: bipush        7
      20: if_icmpge     34
      23: aload_2
      24: invokevirtual #90                 // Method Puzzle17$State3D.getNextState:()LPuzzle17$State3D;
      27: astore_2
      28: iinc          3, 1
      31: goto          17
      34: aload_2
      35: invokevirtual #94                 // Method Puzzle17$State3D.countActiveCells:()I
      38: ireturn

  public final int calculateActiveCountIn4D(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #81                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #99                 // class Puzzle17$State4D
       9: dup
      10: aload_1
      11: invokespecial #100                // Method Puzzle17$State4D."<init>":(Ljava/lang/String;)V
      14: astore_2
      15: iconst_1
      16: istore_3
      17: iload_3
      18: bipush        7
      20: if_icmpge     34
      23: aload_2
      24: invokevirtual #103                // Method Puzzle17$State4D.getNextState:()LPuzzle17$State4D;
      27: astore_2
      28: iinc          3, 1
      31: goto          17
      34: aload_2
      35: invokevirtual #104                // Method Puzzle17$State4D.countActiveCells:()I
      38: ireturn

  static {};
    Code:
       0: new           #2                  // class Puzzle17
       3: dup
       4: invokespecial #107                // Method "<init>":()V
       7: putstatic     #55                 // Field INSTANCE:LPuzzle17;
      10: return
}


object Puzzle11 {

    @JvmStatic
    fun main(args: Array<String>) {
        val input = Puzzle11::class.java.getResource("puzzle11.txt").readText()
        val calculateOccupiedSeats =  calculateOccupiedSeats(input, Puzzle11::countImmediatelyAdjacentSeats, 4)
        println(calculateOccupiedSeats)
        val calculateOccupiedSeatsVisible =  calculateOccupiedSeats(input, Puzzle11::countVisibleAdjacentSeats, 5)
        println(calculateOccupiedSeatsVisible)

    }

    fun calculateOccupiedSeats(input: String,
                               counter: (i: Int, rows: Int, j: Int, cols: Int, input: List<CharArray>) -> Int,
                               minOccupiedToLeave: Int): Int {
        var arrayWithResult = Pair(inputToArrayLists(input), true)
        while (arrayWithResult.second){
            arrayWithResult = applyRules(arrayWithResult.first, counter, minOccupiedToLeave)
        }
        return arrayWithResult.first.sumOf { line -> line.count { it == '#' } }
    }

    private fun applyRules(
        input: List<CharArray>,
        counter: (i: Int, rows: Int, j: Int, cols: Int, input: List<CharArray>) -> Int,
        minOccupiedToLeave: Int
    ): Pair<List<CharArray>, Boolean> {
        val rows = input.size
        val cols = input.first().size
        val output = List(rows) {CharArray(cols)}
        var changed = false

        for (row in 0 until rows){
            for (col in 0 until cols){
                val countOccupied = counter(row, rows, col, cols, input)
                if (input[row][col] == 'L'){
                    if (countOccupied == 0){
                        output[row][col] = '#'
                        changed = true
                    }else{
                        output[row][col] = 'L'
                    }

                }else if (input[row][col] == '#'){
                    if (countOccupied >= minOccupiedToLeave){
                        output[row][col] = 'L'
                        changed = true
                    }else{
                        output[row][col] = '#'
                    }
                }else{
                    output[row][col] = '.'
                }
            }
        }

        return Pair(output, changed)
    }

    fun countImmediatelyAdjacentSeats(i: Int, rows: Int, j: Int, cols: Int, input: List<CharArray>): Int {
        var countOccupied = 0
        for (x in -1..1)
            for (y in -1..1) {
                if ( (x != 0 || y != 0)
                    && i + x >= 0 && i + x <= rows - 1
                    && j + y >= 0 && j + y <= cols - 1
                    && input[i + x][j + y] == '#'
                ) {
                    countOccupied++
                }
            }
        return countOccupied
    }

    fun countVisibleAdjacentSeats(row: Int, rows: Int, col: Int, cols: Int, input: List<CharArray>): Int {
        var countOccupied = 0

        for (dCol in -1..1) {
            var currentCol = col + dCol
            if (currentCol in 0 until cols) {
                for (dRow in -1..1) {
                    if (dCol != 0 || dRow != 0) {
                        var currentRow = row + dRow
                        currentCol = col + dCol
                        while (currentCol in 0 until cols && currentRow in 0 until rows && input[currentRow][currentCol] == '.') {
                            currentCol += dCol
                            currentRow += dRow
                        }
                        if (currentCol in 0 until cols && currentRow in 0 until rows && input[currentRow][currentCol] == '#') {
                            countOccupied++
                        }
                    }
                }
            }
        }

        return countOccupied
    }

    private fun inputToArrayLists(input: String): List<CharArray> {
        return input.split("\n").map { it.toCharArray() }
    }
}

Compiled from "Puzzle11.kt"
final class Puzzle11$main$calculateOccupiedSeats$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function5<java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.util.List<? extends char[]>, java.lang.Integer> {
  Puzzle11$main$calculateOccupiedSeats$1(java.lang.Object);
    Code:
       0: aload_0
       1: iconst_5
       2: aload_1
       3: ldc           #11                 // class Puzzle11
       5: ldc           #13                 // String countImmediatelyAdjacentSeats
       7: ldc           #15                 // String countImmediatelyAdjacentSeats(IIIILjava/util/List;)I
       9: iconst_0
      10: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      13: return

  public final java.lang.Integer invoke(int, int, int, int, java.util.List<char[]>);
    Code:
       0: aload         5
       2: ldc           #27                 // String p4
       4: invokestatic  #33                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: getfield      #35                 // Field receiver:Ljava/lang/Object;
      11: checkcast     #11                 // class Puzzle11
      14: iload_1
      15: iload_2
      16: iload_3
      17: iload         4
      19: aload         5
      21: invokevirtual #38                 // Method Puzzle11.countImmediatelyAdjacentSeats:(IIIILjava/util/List;)I
      24: invokestatic  #44                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      27: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #53                 // class java/lang/Number
       5: invokevirtual #57                 // Method java/lang/Number.intValue:()I
       8: aload_2
       9: checkcast     #53                 // class java/lang/Number
      12: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      15: aload_3
      16: checkcast     #53                 // class java/lang/Number
      19: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      22: aload         4
      24: checkcast     #53                 // class java/lang/Number
      27: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      30: aload         5
      32: checkcast     #59                 // class java/util/List
      35: invokevirtual #61                 // Method invoke:(IIIILjava/util/List;)Ljava/lang/Integer;
      38: areturn
}

Compiled from "Puzzle11.kt"
final class Puzzle11$main$calculateOccupiedSeatsVisible$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function5<java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.util.List<? extends char[]>, java.lang.Integer> {
  Puzzle11$main$calculateOccupiedSeatsVisible$1(java.lang.Object);
    Code:
       0: aload_0
       1: iconst_5
       2: aload_1
       3: ldc           #11                 // class Puzzle11
       5: ldc           #13                 // String countVisibleAdjacentSeats
       7: ldc           #15                 // String countVisibleAdjacentSeats(IIIILjava/util/List;)I
       9: iconst_0
      10: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      13: return

  public final java.lang.Integer invoke(int, int, int, int, java.util.List<char[]>);
    Code:
       0: aload         5
       2: ldc           #27                 // String p4
       4: invokestatic  #33                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: getfield      #35                 // Field receiver:Ljava/lang/Object;
      11: checkcast     #11                 // class Puzzle11
      14: iload_1
      15: iload_2
      16: iload_3
      17: iload         4
      19: aload         5
      21: invokevirtual #38                 // Method Puzzle11.countVisibleAdjacentSeats:(IIIILjava/util/List;)I
      24: invokestatic  #44                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      27: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #53                 // class java/lang/Number
       5: invokevirtual #57                 // Method java/lang/Number.intValue:()I
       8: aload_2
       9: checkcast     #53                 // class java/lang/Number
      12: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      15: aload_3
      16: checkcast     #53                 // class java/lang/Number
      19: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      22: aload         4
      24: checkcast     #53                 // class java/lang/Number
      27: invokevirtual #57                 // Method java/lang/Number.intValue:()I
      30: aload         5
      32: checkcast     #59                 // class java/util/List
      35: invokevirtual #61                 // Method invoke:(IIIILjava/util/List;)Ljava/lang/Integer;
      38: areturn
}

Compiled from "Puzzle11.kt"
public final class Puzzle11 {
  public static final Puzzle11 INSTANCE;

  private Puzzle11();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #16                 // String args
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #2                  // class Puzzle11
       8: ldc           #24                 // String puzzle11.txt
      10: invokevirtual #30                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      13: dup
      14: ldc           #32                 // String getResource(...)
      16: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      19: astore_2
      20: getstatic     #41                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      23: astore_3
      24: aload_2
      25: invokestatic  #47                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      28: astore        4
      30: new           #49                 // class java/lang/String
      33: dup
      34: aload         4
      36: aload_3
      37: invokespecial #52                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      40: astore_1
      41: getstatic     #55                 // Field INSTANCE:LPuzzle11;
      44: aload_1
      45: new           #57                 // class Puzzle11$main$calculateOccupiedSeats$1
      48: dup
      49: getstatic     #55                 // Field INSTANCE:LPuzzle11;
      52: invokespecial #60                 // Method Puzzle11$main$calculateOccupiedSeats$1."<init>":(Ljava/lang/Object;)V
      55: checkcast     #62                 // class kotlin/jvm/functions/Function5
      58: iconst_4
      59: invokevirtual #66                 // Method calculateOccupiedSeats:(Ljava/lang/String;Lkotlin/jvm/functions/Function5;I)I
      62: istore_2
      63: getstatic     #72                 // Field java/lang/System.out:Ljava/io/PrintStream;
      66: iload_2
      67: invokevirtual #78                 // Method java/io/PrintStream.println:(I)V
      70: getstatic     #55                 // Field INSTANCE:LPuzzle11;
      73: aload_1
      74: new           #80                 // class Puzzle11$main$calculateOccupiedSeatsVisible$1
      77: dup
      78: getstatic     #55                 // Field INSTANCE:LPuzzle11;
      81: invokespecial #81                 // Method Puzzle11$main$calculateOccupiedSeatsVisible$1."<init>":(Ljava/lang/Object;)V
      84: checkcast     #62                 // class kotlin/jvm/functions/Function5
      87: iconst_5
      88: invokevirtual #66                 // Method calculateOccupiedSeats:(Ljava/lang/String;Lkotlin/jvm/functions/Function5;I)I
      91: istore_3
      92: getstatic     #72                 // Field java/lang/System.out:Ljava/io/PrintStream;
      95: iload_3
      96: invokevirtual #78                 // Method java/io/PrintStream.println:(I)V
      99: return

  public final int calculateOccupiedSeats(java.lang.String, kotlin.jvm.functions.Function5<? super java.lang.Integer, ? super java.lang.Integer, ? super java.lang.Integer, ? super java.lang.Integer, ? super java.util.List<char[]>, java.lang.Integer>, int);
    Code:
       0: aload_1
       1: ldc           #88                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #90                 // String counter
       9: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #92                 // class kotlin/Pair
      15: dup
      16: aload_0
      17: aload_1
      18: invokespecial #96                 // Method inputToArrayLists:(Ljava/lang/String;)Ljava/util/List;
      21: iconst_1
      22: invokestatic  #102                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      25: invokespecial #105                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      28: astore        4
      30: aload         4
      32: invokevirtual #109                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      35: checkcast     #98                 // class java/lang/Boolean
      38: invokevirtual #113                // Method java/lang/Boolean.booleanValue:()Z
      41: ifeq          63
      44: aload_0
      45: aload         4
      47: invokevirtual #116                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      50: checkcast     #118                // class java/util/List
      53: aload_2
      54: iload_3
      55: invokespecial #122                // Method applyRules:(Ljava/util/List;Lkotlin/jvm/functions/Function5;I)Lkotlin/Pair;
      58: astore        4
      60: goto          30
      63: aload         4
      65: invokevirtual #116                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      68: checkcast     #124                // class java/lang/Iterable
      71: astore        5
      73: iconst_0
      74: istore        6
      76: aload         5
      78: invokeinterface #128,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      83: astore        7
      85: aload         7
      87: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      92: ifeq          196
      95: aload         7
      97: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     102: astore        8
     104: iload         6
     106: aload         8
     108: checkcast     #138                // class "[C"
     111: astore        9
     113: istore        19
     115: iconst_0
     116: istore        10
     118: aload         9
     120: astore        11
     122: iconst_0
     123: istore        12
     125: iconst_0
     126: istore        13
     128: iconst_0
     129: istore        14
     131: aload         11
     133: arraylength
     134: istore        15
     136: iload         14
     138: iload         15
     140: if_icmpge     181
     143: aload         11
     145: iload         14
     147: caload
     148: istore        16
     150: iload         16
     152: istore        17
     154: iconst_0
     155: istore        18
     157: iload         17
     159: bipush        35
     161: if_icmpne     168
     164: iconst_1
     165: goto          169
     168: iconst_0
     169: ifeq          175
     172: iinc          13, 1
     175: iinc          14, 1
     178: goto          136
     181: iload         13
     183: nop
     184: istore        20
     186: iload         19
     188: iload         20
     190: iadd
     191: istore        6
     193: goto          85
     196: iload         6
     198: ireturn

  private final kotlin.Pair<java.util.List<char[]>, java.lang.Boolean> applyRules(java.util.List<char[]>, kotlin.jvm.functions.Function5<? super java.lang.Integer, ? super java.lang.Integer, ? super java.lang.Integer, ? super java.lang.Integer, ? super java.util.List<char[]>, java.lang.Integer>, int);
    Code:
       0: aload_1
       1: invokeinterface #156,  1          // InterfaceMethod java/util/List.size:()I
       6: istore        4
       8: aload_1
       9: invokestatic  #162                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      12: checkcast     #138                // class "[C"
      15: arraylength
      16: istore        5
      18: new           #164                // class java/util/ArrayList
      21: dup
      22: iload         4
      24: invokespecial #166                // Method java/util/ArrayList."<init>":(I)V
      27: astore        7
      29: iconst_0
      30: istore        8
      32: iload         8
      34: iload         4
      36: if_icmpge     71
      39: iload         8
      41: istore        9
      43: aload         7
      45: iload         9
      47: istore        10
      49: astore        12
      51: iconst_0
      52: istore        11
      54: iload         5
      56: newarray       char
      58: aload         12
      60: swap
      61: invokevirtual #170                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      64: pop
      65: iinc          8, 1
      68: goto          32
      71: aload         7
      73: checkcast     #118                // class java/util/List
      76: astore        6
      78: iconst_0
      79: istore        7
      81: iconst_0
      82: istore        8
      84: iload         8
      86: iload         4
      88: if_icmpge     300
      91: iconst_0
      92: istore        9
      94: iload         9
      96: iload         5
      98: if_icmpge     294
     101: aload_2
     102: iload         8
     104: invokestatic  #175                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     107: iload         4
     109: invokestatic  #175                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     112: iload         9
     114: invokestatic  #175                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     117: iload         5
     119: invokestatic  #175                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     122: aload_1
     123: invokeinterface #179,  6          // InterfaceMethod kotlin/jvm/functions/Function5.invoke:(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     128: checkcast     #181                // class java/lang/Number
     131: invokevirtual #184                // Method java/lang/Number.intValue:()I
     134: istore        10
     136: aload_1
     137: iload         8
     139: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     144: checkcast     #138                // class "[C"
     147: iload         9
     149: caload
     150: bipush        76
     152: if_icmpne     203
     155: iload         10
     157: ifne          183
     160: aload         6
     162: iload         8
     164: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     169: checkcast     #138                // class "[C"
     172: iload         9
     174: bipush        35
     176: castore
     177: iconst_1
     178: istore        7
     180: goto          288
     183: aload         6
     185: iload         8
     187: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     192: checkcast     #138                // class "[C"
     195: iload         9
     197: bipush        76
     199: castore
     200: goto          288
     203: aload_1
     204: iload         8
     206: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     211: checkcast     #138                // class "[C"
     214: iload         9
     216: caload
     217: bipush        35
     219: if_icmpne     271
     222: iload         10
     224: iload_3
     225: if_icmplt     251
     228: aload         6
     230: iload         8
     232: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     237: checkcast     #138                // class "[C"
     240: iload         9
     242: bipush        76
     244: castore
     245: iconst_1
     246: istore        7
     248: goto          288
     251: aload         6
     253: iload         8
     255: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     260: checkcast     #138                // class "[C"
     263: iload         9
     265: bipush        35
     267: castore
     268: goto          288
     271: aload         6
     273: iload         8
     275: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     280: checkcast     #138                // class "[C"
     283: iload         9
     285: bipush        46
     287: castore
     288: iinc          9, 1
     291: goto          94
     294: iinc          8, 1
     297: goto          84
     300: new           #92                 // class kotlin/Pair
     303: dup
     304: aload         6
     306: iload         7
     308: invokestatic  #102                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     311: invokespecial #105                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     314: areturn

  public final int countImmediatelyAdjacentSeats(int, int, int, int, java.util.List<char[]>);
    Code:
       0: aload         5
       2: ldc           #88                 // String input
       4: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_0
       8: istore        6
      10: iconst_m1
      11: istore        7
      13: iload         7
      15: iconst_2
      16: if_icmpge     112
      19: iconst_m1
      20: istore        8
      22: iload         8
      24: iconst_2
      25: if_icmpge     106
      28: iload         7
      30: ifne          38
      33: iload         8
      35: ifeq          100
      38: iload_1
      39: iload         7
      41: iadd
      42: iflt          100
      45: iload_1
      46: iload         7
      48: iadd
      49: iload_2
      50: iconst_1
      51: isub
      52: if_icmpgt     100
      55: iload_3
      56: iload         8
      58: iadd
      59: iflt          100
      62: iload_3
      63: iload         8
      65: iadd
      66: iload         4
      68: iconst_1
      69: isub
      70: if_icmpgt     100
      73: aload         5
      75: iload_1
      76: iload         7
      78: iadd
      79: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      84: checkcast     #138                // class "[C"
      87: iload_3
      88: iload         8
      90: iadd
      91: caload
      92: bipush        35
      94: if_icmpne     100
      97: iinc          6, 1
     100: iinc          8, 1
     103: goto          22
     106: iinc          7, 1
     109: goto          13
     112: iload         6
     114: ireturn

  public final int countVisibleAdjacentSeats(int, int, int, int, java.util.List<char[]>);
    Code:
       0: aload         5
       2: ldc           #88                 // String input
       4: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: iconst_0
       8: istore        6
      10: iconst_m1
      11: istore        7
      13: iload         7
      15: iconst_2
      16: if_icmpge     251
      19: iload_3
      20: iload         7
      22: iadd
      23: istore        8
      25: iconst_0
      26: iload         8
      28: if_icmpgt     46
      31: iload         8
      33: iload         4
      35: if_icmpge     42
      38: iconst_1
      39: goto          47
      42: iconst_0
      43: goto          47
      46: iconst_0
      47: ifeq          245
      50: iconst_m1
      51: istore        9
      53: iload         9
      55: iconst_2
      56: if_icmpge     245
      59: iload         7
      61: ifne          69
      64: iload         9
      66: ifeq          239
      69: iload_1
      70: iload         9
      72: iadd
      73: istore        10
      75: iload_3
      76: iload         7
      78: iadd
      79: istore        8
      81: iconst_0
      82: iload         8
      84: if_icmpgt     102
      87: iload         8
      89: iload         4
      91: if_icmpge     98
      94: iconst_1
      95: goto          103
      98: iconst_0
      99: goto          103
     102: iconst_0
     103: ifeq          167
     106: iconst_0
     107: iload         10
     109: if_icmpgt     126
     112: iload         10
     114: iload_2
     115: if_icmpge     122
     118: iconst_1
     119: goto          127
     122: iconst_0
     123: goto          127
     126: iconst_0
     127: ifeq          167
     130: aload         5
     132: iload         10
     134: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     139: checkcast     #138                // class "[C"
     142: iload         8
     144: caload
     145: bipush        46
     147: if_icmpne     167
     150: iload         8
     152: iload         7
     154: iadd
     155: istore        8
     157: iload         10
     159: iload         9
     161: iadd
     162: istore        10
     164: goto          81
     167: iconst_0
     168: iload         8
     170: if_icmpgt     188
     173: iload         8
     175: iload         4
     177: if_icmpge     184
     180: iconst_1
     181: goto          189
     184: iconst_0
     185: goto          189
     188: iconst_0
     189: ifeq          239
     192: iconst_0
     193: iload         10
     195: if_icmpgt     212
     198: iload         10
     200: iload_2
     201: if_icmpge     208
     204: iconst_1
     205: goto          213
     208: iconst_0
     209: goto          213
     212: iconst_0
     213: ifeq          239
     216: aload         5
     218: iload         10
     220: invokeinterface #188,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     225: checkcast     #138                // class "[C"
     228: iload         8
     230: caload
     231: bipush        35
     233: if_icmpne     239
     236: iinc          6, 1
     239: iinc          9, 1
     242: goto          53
     245: iinc          7, 1
     248: goto          13
     251: iload         6
     253: ireturn

  private final java.util.List<char[]> inputToArrayLists(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #213                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #49                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #215                // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #221                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #124                // class java/lang/Iterable
      26: astore_2
      27: iconst_0
      28: istore_3
      29: aload_2
      30: astore        4
      32: new           #164                // class java/util/ArrayList
      35: dup
      36: aload_2
      37: bipush        10
      39: invokestatic  #225                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokespecial #166                // Method java/util/ArrayList."<init>":(I)V
      45: checkcast     #227                // class java/util/Collection
      48: astore        5
      50: iconst_0
      51: istore        6
      53: aload         4
      55: invokeinterface #128,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        7
      62: aload         7
      64: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          119
      72: aload         7
      74: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        8
      81: aload         5
      83: aload         8
      85: checkcast     #49                 // class java/lang/String
      88: astore        9
      90: astore        11
      92: iconst_0
      93: istore        10
      95: aload         9
      97: invokevirtual #231                // Method java/lang/String.toCharArray:()[C
     100: dup
     101: ldc           #233                // String toCharArray(...)
     103: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     106: nop
     107: aload         11
     109: swap
     110: invokeinterface #234,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     115: pop
     116: goto          62
     119: aload         5
     121: checkcast     #118                // class java/util/List
     124: nop
     125: areturn

  static {};
    Code:
       0: new           #2                  // class Puzzle11
       3: dup
       4: invokespecial #246                // Method "<init>":()V
       7: putstatic     #55                 // Field INSTANCE:LPuzzle11;
      10: return
}


import java.math.BigInteger

object Puzzle10 {

    @JvmStatic
    fun main(args: Array<String>) {
        val input = Puzzle10::class.java.getResource("puzzle10.txt").readText()
        val count1and3diffInInput =  count1and3diffInInput(input)
        println(count1and3diffInInput.first * count1and3diffInInput.second)
        val countAvailableConfigurations = countAvailableConfigurations(input)
        println(countAvailableConfigurations)
    }

    fun count1and3diffInInput(input: String): Pair<Int, Int> {
        val orderedNumbers = inputToSortedList(input)
        var diff1 = 0
        var diff3 = 0
        for ( i in 1 until orderedNumbers.count()){
            val diff = orderedNumbers[i] - orderedNumbers[i-1]
            if (diff == 1) diff1 ++
            if (diff == 3) diff3 ++
        }
        return Pair(diff1, diff3)
    }

    private fun inputToSortedList(input: String): List<Int> {
        val numbers = input.split("\n").map(String::toInt)
        val numbersWithStartAndEnd = numbers + 0 + (numbers.maxOrNull()!! + 3)
        return numbersWithStartAndEnd.sorted()
    }

    fun countAvailableConfigurations(input: String): BigInteger {
        val orderedNumbers = inputToSortedList(input)
        val parentsMap = HashMap<Int, MutableList<Int>>()
        for ( i in orderedNumbers) {
            for (j in 1..3) {
                val parent = i - j
                if (orderedNumbers.contains(parent)) {
                    if (!parentsMap.containsKey(i)) {
                        parentsMap[i] = ArrayList()
                    }
                    parentsMap[i]!!.add(parent)
                }
            }
        }

        val parentCount = HashMap<Int, BigInteger>()

        for (num in orderedNumbers){
            val parents = parentsMap[num]
            if (parents == null){
                parentCount[num] = BigInteger.ONE
            }else{
                parentCount[num] = parents.map{ parentCount[it]!!}.sumOf { it }
            }
        }

        val maxValue = orderedNumbers.maxOrNull()!!
        return parentCount[maxValue]!!
    }
}

Compiled from "Puzzle10.kt"
public final class Puzzle10 {
  public static final Puzzle10 INSTANCE;

  private Puzzle10();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #16                 // String args
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #2                  // class Puzzle10
       8: ldc           #24                 // String puzzle10.txt
      10: invokevirtual #30                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      13: dup
      14: ldc           #32                 // String getResource(...)
      16: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      19: astore_2
      20: getstatic     #41                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      23: astore_3
      24: aload_2
      25: invokestatic  #47                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      28: astore        4
      30: new           #49                 // class java/lang/String
      33: dup
      34: aload         4
      36: aload_3
      37: invokespecial #52                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      40: astore_1
      41: getstatic     #55                 // Field INSTANCE:LPuzzle10;
      44: aload_1
      45: invokevirtual #59                 // Method count1and3diffInInput:(Ljava/lang/String;)Lkotlin/Pair;
      48: astore_2
      49: aload_2
      50: invokevirtual #65                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      53: checkcast     #67                 // class java/lang/Number
      56: invokevirtual #71                 // Method java/lang/Number.intValue:()I
      59: aload_2
      60: invokevirtual #74                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      63: checkcast     #67                 // class java/lang/Number
      66: invokevirtual #71                 // Method java/lang/Number.intValue:()I
      69: imul
      70: istore_3
      71: getstatic     #80                 // Field java/lang/System.out:Ljava/io/PrintStream;
      74: iload_3
      75: invokevirtual #86                 // Method java/io/PrintStream.println:(I)V
      78: getstatic     #55                 // Field INSTANCE:LPuzzle10;
      81: aload_1
      82: invokevirtual #90                 // Method countAvailableConfigurations:(Ljava/lang/String;)Ljava/math/BigInteger;
      85: astore_3
      86: getstatic     #80                 // Field java/lang/System.out:Ljava/io/PrintStream;
      89: aload_3
      90: invokevirtual #93                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      93: return

  public final kotlin.Pair<java.lang.Integer, java.lang.Integer> count1and3diffInInput(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #100                // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #104                // Method inputToSortedList:(Ljava/lang/String;)Ljava/util/List;
      11: astore_2
      12: iconst_0
      13: istore_3
      14: iconst_0
      15: istore        4
      17: iconst_1
      18: istore        5
      20: aload_2
      21: checkcast     #106                // class java/util/Collection
      24: invokeinterface #109,  1          // InterfaceMethod java/util/Collection.size:()I
      29: istore        6
      31: iload         5
      33: iload         6
      35: if_icmpge     95
      38: aload_2
      39: iload         5
      41: invokeinterface #115,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      46: checkcast     #67                 // class java/lang/Number
      49: invokevirtual #71                 // Method java/lang/Number.intValue:()I
      52: aload_2
      53: iload         5
      55: iconst_1
      56: isub
      57: invokeinterface #115,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      62: checkcast     #67                 // class java/lang/Number
      65: invokevirtual #71                 // Method java/lang/Number.intValue:()I
      68: isub
      69: istore        7
      71: iload         7
      73: iconst_1
      74: if_icmpne     80
      77: iinc          3, 1
      80: iload         7
      82: iconst_3
      83: if_icmpne     89
      86: iinc          4, 1
      89: iinc          5, 1
      92: goto          31
      95: new           #61                 // class kotlin/Pair
      98: dup
      99: iload_3
     100: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: iload         4
     105: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     108: invokespecial #124                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     111: areturn

  private final java.util.List<java.lang.Integer> inputToSortedList(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #134                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #49                 // class java/lang/String
       8: astore_3
       9: aload_3
      10: iconst_0
      11: ldc           #136                // String \n
      13: aastore
      14: aload_3
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #142                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #144                // class java/lang/Iterable
      26: astore_3
      27: iconst_0
      28: istore        4
      30: aload_3
      31: astore        5
      33: new           #146                // class java/util/ArrayList
      36: dup
      37: aload_3
      38: bipush        10
      40: invokestatic  #152                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      43: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
      46: checkcast     #106                // class java/util/Collection
      49: astore        6
      51: iconst_0
      52: istore        7
      54: aload         5
      56: invokeinterface #158,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      61: astore        8
      63: aload         8
      65: invokeinterface #164,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          117
      73: aload         8
      75: invokeinterface #167,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      80: astore        9
      82: aload         6
      84: aload         9
      86: checkcast     #49                 // class java/lang/String
      89: astore        10
      91: astore        12
      93: iconst_0
      94: istore        11
      96: aload         10
      98: invokestatic  #171                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     101: nop
     102: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     105: aload         12
     107: swap
     108: invokeinterface #175,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     113: pop
     114: goto          63
     117: aload         6
     119: checkcast     #111                // class java/util/List
     122: nop
     123: astore_2
     124: aload_2
     125: checkcast     #106                // class java/util/Collection
     128: iconst_0
     129: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     132: invokestatic  #179                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     135: checkcast     #106                // class java/util/Collection
     138: aload_2
     139: checkcast     #144                // class java/lang/Iterable
     142: invokestatic  #183                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     145: dup
     146: invokestatic  #186                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     149: checkcast     #67                 // class java/lang/Number
     152: invokevirtual #71                 // Method java/lang/Number.intValue:()I
     155: iconst_3
     156: iadd
     157: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     160: invokestatic  #179                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     163: astore_3
     164: aload_3
     165: checkcast     #144                // class java/lang/Iterable
     168: invokestatic  #190                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     171: areturn

  public final java.math.BigInteger countAvailableConfigurations(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #100                // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #104                // Method inputToSortedList:(Ljava/lang/String;)Ljava/util/List;
      11: astore_2
      12: new           #205                // class java/util/HashMap
      15: dup
      16: invokespecial #206                // Method java/util/HashMap."<init>":()V
      19: astore_3
      20: aload_2
      21: invokeinterface #207,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      26: astore        4
      28: aload         4
      30: invokeinterface #164,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      35: ifeq          154
      38: aload         4
      40: invokeinterface #167,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      45: checkcast     #67                 // class java/lang/Number
      48: invokevirtual #71                 // Method java/lang/Number.intValue:()I
      51: istore        5
      53: iconst_1
      54: istore        6
      56: iload         6
      58: iconst_4
      59: if_icmpge     28
      62: iload         5
      64: iload         6
      66: isub
      67: istore        7
      69: aload_2
      70: iload         7
      72: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      75: invokeinterface #210,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
      80: ifeq          148
      83: aload_3
      84: iload         5
      86: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      89: invokevirtual #213                // Method java/util/HashMap.containsKey:(Ljava/lang/Object;)Z
      92: ifne          121
      95: iload         5
      97: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     100: astore        9
     102: aload_3
     103: checkcast     #215                // class java/util/Map
     106: aload         9
     108: new           #146                // class java/util/ArrayList
     111: dup
     112: invokespecial #216                // Method java/util/ArrayList."<init>":()V
     115: invokeinterface #220,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     120: pop
     121: aload_3
     122: iload         5
     124: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     127: invokevirtual #223                // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     130: dup
     131: invokestatic  #186                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     134: checkcast     #111                // class java/util/List
     137: iload         7
     139: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     142: invokeinterface #224,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     147: pop
     148: iinc          6, 1
     151: goto          56
     154: new           #205                // class java/util/HashMap
     157: dup
     158: invokespecial #206                // Method java/util/HashMap."<init>":()V
     161: astore        4
     163: aload_2
     164: invokeinterface #207,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     169: astore        5
     171: aload         5
     173: invokeinterface #164,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          465
     181: aload         5
     183: invokeinterface #167,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: checkcast     #67                 // class java/lang/Number
     191: invokevirtual #71                 // Method java/lang/Number.intValue:()I
     194: istore        6
     196: aload_3
     197: iload         6
     199: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     202: invokevirtual #223                // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     205: checkcast     #111                // class java/util/List
     208: astore        7
     210: aload         7
     212: ifnonnull     241
     215: iload         6
     217: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     220: astore        9
     222: aload         4
     224: checkcast     #215                // class java/util/Map
     227: aload         9
     229: getstatic     #229                // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
     232: invokeinterface #220,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     237: pop
     238: goto          171
     241: aload         4
     243: checkcast     #215                // class java/util/Map
     246: astore        8
     248: iload         6
     250: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     253: astore        9
     255: aload         7
     257: checkcast     #144                // class java/lang/Iterable
     260: astore        10
     262: iconst_0
     263: istore        11
     265: aload         10
     267: astore        12
     269: new           #146                // class java/util/ArrayList
     272: dup
     273: aload         10
     275: bipush        10
     277: invokestatic  #152                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     280: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     283: checkcast     #106                // class java/util/Collection
     286: astore        13
     288: iconst_0
     289: istore        14
     291: aload         12
     293: invokeinterface #158,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     298: astore        15
     300: aload         15
     302: invokeinterface #164,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     307: ifeq          365
     310: aload         15
     312: invokeinterface #167,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     317: astore        16
     319: aload         13
     321: aload         16
     323: checkcast     #67                 // class java/lang/Number
     326: invokevirtual #71                 // Method java/lang/Number.intValue:()I
     329: istore        17
     331: astore        19
     333: iconst_0
     334: istore        18
     336: aload         4
     338: iload         17
     340: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     343: invokevirtual #223                // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     346: dup
     347: invokestatic  #186                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     350: checkcast     #226                // class java/math/BigInteger
     353: aload         19
     355: swap
     356: invokeinterface #175,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     361: pop
     362: goto          300
     365: aload         13
     367: checkcast     #111                // class java/util/List
     370: nop
     371: checkcast     #144                // class java/lang/Iterable
     374: astore        10
     376: lconst_0
     377: invokestatic  #232                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
     380: dup
     381: ldc           #234                // String valueOf(...)
     383: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     386: astore        11
     388: aload         10
     390: invokeinterface #158,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     395: astore        12
     397: aload         12
     399: invokeinterface #164,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     404: ifeq          446
     407: aload         12
     409: invokeinterface #167,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     414: aload         11
     416: swap
     417: checkcast     #226                // class java/math/BigInteger
     420: astore        14
     422: astore        19
     424: iconst_0
     425: istore        15
     427: aload         14
     429: aload         19
     431: swap
     432: invokevirtual #237                // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     435: dup
     436: ldc           #239                // String add(...)
     438: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     441: astore        11
     443: goto          397
     446: aload         11
     448: astore        10
     450: aload         8
     452: aload         9
     454: aload         10
     456: invokeinterface #220,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     461: pop
     462: goto          171
     465: aload_2
     466: checkcast     #144                // class java/lang/Iterable
     469: invokestatic  #183                // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     472: dup
     473: invokestatic  #186                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     476: checkcast     #67                 // class java/lang/Number
     479: invokevirtual #71                 // Method java/lang/Number.intValue:()I
     482: istore        5
     484: aload         4
     486: iload         5
     488: invokestatic  #121                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     491: invokevirtual #223                // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     494: dup
     495: invokestatic  #186                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     498: checkcast     #226                // class java/math/BigInteger
     501: areturn

  static {};
    Code:
       0: new           #2                  // class Puzzle10
       3: dup
       4: invokespecial #252                // Method "<init>":()V
       7: putstatic     #55                 // Field INSTANCE:LPuzzle10;
      10: return
}