/**
 * Array Data Structure Problem
 * Largest Sum Contiguous Sub-array
 * Kotlin solution :
 * 1- Simple approach = time complexity O(n*n) where n is size of array
 * 2- kadane approach = time complexity O(n) where n is size of array
 */
class MaximumSubArray {

    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            val array = arrayOf(1, 3, 8, -2, 6, -8, 5)
            val simpleApproach = simpleApproach(array)
            val kadaneSolution = kadaneSolution(array)
            print("Maximum Sub array : simpleSolution $simpleApproach  kadaneSolution $kadaneSolution")

        }

        private fun simpleApproach(array: Array<Int>): Int {
            var maximumSubArray = Int.MIN_VALUE
            for (i in array.indices) {
                var curSum = 0
                for (j in i until array.size) {
                    curSum += array[j]
                    if (curSum > maximumSubArray) {
                        maximumSubArray = curSum
                    }
                }// end of j
            }// end of i
            return maximumSubArray
        }

        private fun kadaneSolution(array: Array<Int>): Int {
            var maximumSubArray = Int.MIN_VALUE
            var currentSum = 0
            for (i in array.indices) {
                currentSum += array[i]
                if (currentSum > maximumSubArray) {
                    maximumSubArray = currentSum
                }
                if (currentSum < 0) {
                    currentSum = 0
                }
            }
            return maximumSubArray
        }
    }
}

Compiled from "MaximumSubArray.kt"
public final class MaximumSubArray {
  public static final MaximumSubArray$Companion Companion;

  public MaximumSubArray();
    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: getstatic     #18                 // Field Companion:LMaximumSubArray$Companion;
       3: aload_0
       4: invokevirtual #22                 // Method MaximumSubArray$Companion.main:([Ljava/lang/String;)V
       7: return

  static {};
    Code:
       0: new           #20                 // class MaximumSubArray$Companion
       3: dup
       4: aconst_null
       5: invokespecial #28                 // Method MaximumSubArray$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #18                 // Field Companion:LMaximumSubArray$Companion;
      11: return
}

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

  public final void main(java.lang.String[]);
    Code:
       0: aload_1
       1: ldc           #16                 // String args
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: bipush        7
       8: anewarray     #24                 // class java/lang/Integer
      11: astore_3
      12: aload_3
      13: iconst_0
      14: iconst_1
      15: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      18: aastore
      19: aload_3
      20: iconst_1
      21: iconst_3
      22: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: aastore
      26: aload_3
      27: iconst_2
      28: bipush        8
      30: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: aastore
      34: aload_3
      35: iconst_3
      36: bipush        -2
      38: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      41: aastore
      42: aload_3
      43: iconst_4
      44: bipush        6
      46: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      49: aastore
      50: aload_3
      51: iconst_5
      52: bipush        -8
      54: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: aastore
      58: aload_3
      59: bipush        6
      61: iconst_5
      62: invokestatic  #28                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      65: aastore
      66: aload_3
      67: astore_2
      68: aload_0
      69: aload_2
      70: invokespecial #32                 // Method simpleApproach:([Ljava/lang/Integer;)I
      73: istore_3
      74: aload_0
      75: aload_2
      76: invokespecial #35                 // Method kadaneSolution:([Ljava/lang/Integer;)I
      79: istore        4
      81: new           #37                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #38                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #40                 // String Maximum Sub array : simpleSolution
      90: invokevirtual #44                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: iload_3
      94: invokevirtual #47                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      97: ldc           #49                 // String   kadaneSolution
      99: invokevirtual #44                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     102: iload         4
     104: invokevirtual #47                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     107: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     110: getstatic     #59                 // Field java/lang/System.out:Ljava/io/PrintStream;
     113: swap
     114: invokevirtual #65                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     117: return

  private final int simpleApproach(java.lang.Integer[]);
    Code:
       0: ldc           #70                 // int -2147483648
       2: istore_2
       3: iconst_0
       4: istore_3
       5: aload_1
       6: arraylength
       7: istore        4
       9: iload_3
      10: iload         4
      12: if_icmpge     65
      15: iconst_0
      16: istore        5
      18: iload_3
      19: istore        6
      21: aload_1
      22: arraylength
      23: istore        7
      25: iload         6
      27: iload         7
      29: if_icmpge     59
      32: iload         5
      34: aload_1
      35: iload         6
      37: aaload
      38: invokevirtual #74                 // Method java/lang/Integer.intValue:()I
      41: iadd
      42: istore        5
      44: iload         5
      46: iload_2
      47: if_icmple     53
      50: iload         5
      52: istore_2
      53: iinc          6, 1
      56: goto          25
      59: iinc          3, 1
      62: goto          9
      65: iload_2
      66: ireturn

  private final int kadaneSolution(java.lang.Integer[]);
    Code:
       0: ldc           #70                 // int -2147483648
       2: istore_2
       3: iconst_0
       4: istore_3
       5: iconst_0
       6: istore        4
       8: aload_1
       9: arraylength
      10: istore        5
      12: iload         4
      14: iload         5
      16: if_icmpge     48
      19: iload_3
      20: aload_1
      21: iload         4
      23: aaload
      24: invokevirtual #74                 // Method java/lang/Integer.intValue:()I
      27: iadd
      28: istore_3
      29: iload_3
      30: iload_2
      31: if_icmple     36
      34: iload_3
      35: istore_2
      36: iload_3
      37: ifge          42
      40: iconst_0
      41: istore_3
      42: iinc          4, 1
      45: goto          12
      48: iload_2
      49: ireturn

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


strouilhet__KeepCalmAndCode3__f779bf1/séance 1 et 2 _ classe et objet/correction/Complexe.kt

import kotlin.math.PI
import kotlin.math.atan
import kotlin.math.round
import kotlin.math.sqrt

class Complexe(val reel: Double = 0.0, val im: Double = 0.0) {

    constructor(c: Complexe) : this(c.reel, c.im)

    fun module(): Double = sqrt(reel * reel + im * im)

    fun argument(): Double =
        if (reel == 0.0)
            if (im >= 0) PI / 2 else -PI / 2
        else atan(im / reel)

    fun add(z:Complexe): Complexe =Complexe(reel+z.reel, im+ z.im)

    fun mul(z:Complexe): Complexe = Complexe(reel*z.reel - im*z.im,reel*z.im + im*z.reel)

    /**
     * puissance
     * précondition n >=1
     * @param n, puissance
     * @return puissance (Complexe)
     */
    fun puissance(n:Int):Complexe {
      var r:Complexe=this
      for (i in 2..n) r=mul(r)
      return Complexe(round(r.reel), round(r.im))
    }

    fun puissanceBis(n: Int): Complexe {
        var r = Complexe(1.0, 0.0)
        for (i in 0 until n)  // n-1 compris
            r = r.mul(this)
        return r
    }

    /**
     * inverse du nombre complexe
     * précondition : this est non nul
     * @return inverse (Complexe)
     */
    fun inverse(): Complexe
            =Complexe(reel / (reel * reel + im * im), -im / (reel * reel + im * im))

    /**
     * division du nombre complexe par z
     * précondition : z non nul
     * @param z, diviseur
     * @return quotiont (Complexe)
     */
    fun div(z: Complexe): Complexe = this.mul(z.inverse())

    override fun toString(): String = "$reel + i $im"

    companion object {
        val I = Complexe(0.0, 1.0)
        val J = Complexe(-1 / 2.0, Math.sqrt(3.0) / 2)
    }

}

// question 1 --> avant l'ajout des getters
/*
class Complexe constructor(_reel:Double = 0.0, _im:Double= 0.0)  {
    private val reel:Double=_reel
    private val im: Double=_im

    constructor(c:Complexe): this(c.reel, c.im) {
    }
}*/

Compiled from "Complexe.kt"
public final class Complexe {
  public static final Complexe$Companion Companion;

  private final double reel;

  private final double im;

  private static final Complexe I;

  private static final Complexe J;

  public Complexe(double, double);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: dload_1
       6: putfield      #13                 // Field reel:D
       9: aload_0
      10: dload_3
      11: putfield      #16                 // Field im:D
      14: return

  public Complexe(double, double, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         5
       2: iconst_1
       3: iand
       4: ifeq          9
       7: dconst_0
       8: dstore_1
       9: iload         5
      11: iconst_2
      12: iand
      13: ifeq          18
      16: dconst_0
      17: dstore_3
      18: aload_0
      19: dload_1
      20: dload_3
      21: invokespecial #21                 // Method "<init>":(DD)V
      24: return

  public final double getReel();
    Code:
       0: aload_0
       1: getfield      #13                 // Field reel:D
       4: dreturn

  public final double getIm();
    Code:
       0: aload_0
       1: getfield      #16                 // Field im:D
       4: dreturn

  public Complexe(Complexe);
    Code:
       0: aload_1
       1: ldc           #28                 // String c
       3: invokestatic  #34                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: getfield      #13                 // Field reel:D
      11: aload_1
      12: getfield      #16                 // Field im:D
      15: invokespecial #21                 // Method "<init>":(DD)V
      18: return

  public final double module();
    Code:
       0: aload_0
       1: getfield      #13                 // Field reel:D
       4: aload_0
       5: getfield      #13                 // Field reel:D
       8: dmul
       9: aload_0
      10: getfield      #16                 // Field im:D
      13: aload_0
      14: getfield      #16                 // Field im:D
      17: dmul
      18: dadd
      19: invokestatic  #41                 // Method java/lang/Math.sqrt:(D)D
      22: dreturn

  public final double argument();
    Code:
       0: aload_0
       1: getfield      #13                 // Field reel:D
       4: dconst_0
       5: dcmpg
       6: ifne          13
       9: iconst_1
      10: goto          14
      13: iconst_0
      14: ifeq          38
      17: aload_0
      18: getfield      #16                 // Field im:D
      21: dconst_0
      22: dcmpl
      23: iflt          32
      26: ldc2_w        #43                 // double 1.5707963267948966d
      29: goto          50
      32: ldc2_w        #45                 // double -1.5707963267948966d
      35: goto          50
      38: aload_0
      39: getfield      #16                 // Field im:D
      42: aload_0
      43: getfield      #13                 // Field reel:D
      46: ddiv
      47: invokestatic  #49                 // Method java/lang/Math.atan:(D)D
      50: dreturn

  public final Complexe add(Complexe);
    Code:
       0: aload_1
       1: ldc           #53                 // String z
       3: invokestatic  #34                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class Complexe
       9: dup
      10: aload_0
      11: getfield      #13                 // Field reel:D
      14: aload_1
      15: getfield      #13                 // Field reel:D
      18: dadd
      19: aload_0
      20: getfield      #16                 // Field im:D
      23: aload_1
      24: getfield      #16                 // Field im:D
      27: dadd
      28: invokespecial #21                 // Method "<init>":(DD)V
      31: areturn

  public final Complexe mul(Complexe);
    Code:
       0: aload_1
       1: ldc           #53                 // String z
       3: invokestatic  #34                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class Complexe
       9: dup
      10: aload_0
      11: getfield      #13                 // Field reel:D
      14: aload_1
      15: getfield      #13                 // Field reel:D
      18: dmul
      19: aload_0
      20: getfield      #16                 // Field im:D
      23: aload_1
      24: getfield      #16                 // Field im:D
      27: dmul
      28: dsub
      29: aload_0
      30: getfield      #13                 // Field reel:D
      33: aload_1
      34: getfield      #16                 // Field im:D
      37: dmul
      38: aload_0
      39: getfield      #16                 // Field im:D
      42: aload_1
      43: getfield      #13                 // Field reel:D
      46: dmul
      47: dadd
      48: invokespecial #21                 // Method "<init>":(DD)V
      51: areturn

  public final Complexe puissance(int);
    Code:
       0: aload_0
       1: astore_2
       2: iconst_2
       3: istore_3
       4: iload_3
       5: iload_1
       6: if_icmpgt     26
       9: aload_0
      10: aload_2
      11: invokevirtual #58                 // Method mul:(LComplexe;)LComplexe;
      14: astore_2
      15: iload_3
      16: iload_1
      17: if_icmpeq     26
      20: iinc          3, 1
      23: goto          9
      26: new           #2                  // class Complexe
      29: dup
      30: aload_2
      31: getfield      #13                 // Field reel:D
      34: invokestatic  #61                 // Method java/lang/Math.rint:(D)D
      37: aload_2
      38: getfield      #16                 // Field im:D
      41: invokestatic  #61                 // Method java/lang/Math.rint:(D)D
      44: invokespecial #21                 // Method "<init>":(DD)V
      47: areturn

  public final Complexe puissanceBis(int);
    Code:
       0: new           #2                  // class Complexe
       3: dup
       4: dconst_1
       5: dconst_0
       6: invokespecial #21                 // Method "<init>":(DD)V
       9: astore_2
      10: iconst_0
      11: istore_3
      12: iload_3
      13: iload_1
      14: if_icmpge     29
      17: aload_2
      18: aload_0
      19: invokevirtual #58                 // Method mul:(LComplexe;)LComplexe;
      22: astore_2
      23: iinc          3, 1
      26: goto          12
      29: aload_2
      30: areturn

  public final Complexe inverse();
    Code:
       0: new           #2                  // class Complexe
       3: dup
       4: aload_0
       5: getfield      #13                 // Field reel:D
       8: aload_0
       9: getfield      #13                 // Field reel:D
      12: aload_0
      13: getfield      #13                 // Field reel:D
      16: dmul
      17: aload_0
      18: getfield      #16                 // Field im:D
      21: aload_0
      22: getfield      #16                 // Field im:D
      25: dmul
      26: dadd
      27: ddiv
      28: aload_0
      29: getfield      #16                 // Field im:D
      32: dneg
      33: aload_0
      34: getfield      #13                 // Field reel:D
      37: aload_0
      38: getfield      #13                 // Field reel:D
      41: dmul
      42: aload_0
      43: getfield      #16                 // Field im:D
      46: aload_0
      47: getfield      #16                 // Field im:D
      50: dmul
      51: dadd
      52: ddiv
      53: invokespecial #21                 // Method "<init>":(DD)V
      56: areturn

  public final Complexe div(Complexe);
    Code:
       0: aload_1
       1: ldc           #53                 // String z
       3: invokestatic  #34                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokevirtual #71                 // Method inverse:()LComplexe;
      11: invokevirtual #58                 // Method mul:(LComplexe;)LComplexe;
      14: areturn

  public java.lang.String toString();
    Code:
       0: new           #75                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #76                 // Method java/lang/StringBuilder."<init>":()V
       7: aload_0
       8: getfield      #13                 // Field reel:D
      11: invokevirtual #80                 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;
      14: ldc           #82                 // String  + i
      16: invokevirtual #85                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: aload_0
      20: getfield      #16                 // Field im:D
      23: invokevirtual #80                 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;
      26: invokevirtual #87                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      29: areturn

  public Complexe();
    Code:
       0: aload_0
       1: dconst_0
       2: dconst_0
       3: iconst_3
       4: aconst_null
       5: invokespecial #89                 // Method "<init>":(DDILkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: return

  public static final Complexe access$getI$cp();
    Code:
       0: getstatic     #92                 // Field I:LComplexe;
       3: areturn

  public static final Complexe access$getJ$cp();
    Code:
       0: getstatic     #96                 // Field J:LComplexe;
       3: areturn

  static {};
    Code:
       0: new           #99                 // class Complexe$Companion
       3: dup
       4: aconst_null
       5: invokespecial #102                // Method Complexe$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #106                // Field Companion:LComplexe$Companion;
      11: new           #2                  // class Complexe
      14: dup
      15: dconst_0
      16: dconst_1
      17: invokespecial #21                 // Method "<init>":(DD)V
      20: putstatic     #92                 // Field I:LComplexe;
      23: new           #2                  // class Complexe
      26: dup
      27: ldc2_w        #107                // double -0.5d
      30: ldc2_w        #109                // double 3.0d
      33: invokestatic  #41                 // Method java/lang/Math.sqrt:(D)D
      36: iconst_2
      37: i2d
      38: ddiv
      39: invokespecial #21                 // Method "<init>":(DD)V
      42: putstatic     #96                 // Field J:LComplexe;
      45: return
}

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

  public final Complexe getI();
    Code:
       0: invokestatic  #18                 // Method Complexe.access$getI$cp:()LComplexe;
       3: areturn

  public final Complexe getJ();
    Code:
       0: invokestatic  #22                 // Method Complexe.access$getJ$cp:()LComplexe;
       3: areturn

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


fun doHash(lengths: List<Int>, n: Int, rounds: Int): Array<Int> {
    var pos = 0
    var skip = 0
    val list = Array(n, { it })
    for (round in 0 until rounds) {
        for (i in lengths.indices) {
            val listAgain = list.copyOf()
            for (j in 0 until lengths[i]) {
                list[(pos + j) % n] = listAgain[(pos + lengths[i] - 1 - j) % n]
            }
            pos += lengths[i] + skip
            skip++;
        }
    }
    return list
}

fun firstProd(list: Array<Int>): Int {
    return list[0] * list[1]
}

fun denseHash(list: Array<Int>, n: Int): String {
    var output = ""
    val blockSize = list.size / n
    for (i in 0 until n) {
        val byte = list.slice(i * blockSize until (i + 1) * blockSize).reduce(
            { j, k -> j xor k })
        output += byte.toString(16).padStart(2, '0')
    }
    return output
}

fun main(args: Array<String>) {
    val line = readLine()!!
    val extra = arrayOf(17, 31, 73, 47, 23)
    println(firstProd(doHash(line.split(",").map({ it.toInt() }), 256, 1)))
    println(denseHash(doHash(line.map({ it.toInt() }) + extra, 256, 64), 16))
}

Compiled from "day10.kt"
public final class Day10Kt {
  public static final java.lang.Integer[] doHash(java.util.List<java.lang.Integer>, int, int);
    Code:
       0: aload_0
       1: ldc           #10                 // String lengths
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_3
       8: iconst_0
       9: istore        4
      11: iconst_0
      12: istore        6
      14: iload_1
      15: anewarray     #18                 // class java/lang/Integer
      18: astore        7
      20: iload         6
      22: iload_1
      23: if_icmpge     46
      26: iload         6
      28: istore        8
      30: aload         7
      32: iload         8
      34: iload         8
      36: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: aastore
      40: iinc          6, 1
      43: goto          20
      46: aload         7
      48: astore        5
      50: iconst_0
      51: istore        6
      53: iload         6
      55: iload_2
      56: if_icmpge     200
      59: iconst_0
      60: istore        7
      62: aload_0
      63: checkcast     #24                 // class java/util/Collection
      66: invokeinterface #28,  1           // InterfaceMethod java/util/Collection.size:()I
      71: istore        8
      73: iload         7
      75: iload         8
      77: if_icmpge     194
      80: aload         5
      82: dup
      83: arraylength
      84: invokestatic  #34                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
      87: dup
      88: ldc           #36                 // String copyOf(...)
      90: invokestatic  #39                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      93: checkcast     #41                 // class "[Ljava/lang/Integer;"
      96: astore        9
      98: iconst_0
      99: istore        10
     101: aload_0
     102: iload         7
     104: invokeinterface #47,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     109: checkcast     #49                 // class java/lang/Number
     112: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     115: istore        11
     117: iload         10
     119: iload         11
     121: if_icmpge     165
     124: aload         5
     126: iload_3
     127: iload         10
     129: iadd
     130: iload_1
     131: irem
     132: aload         9
     134: iload_3
     135: aload_0
     136: iload         7
     138: invokeinterface #47,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     143: checkcast     #49                 // class java/lang/Number
     146: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     149: iadd
     150: iconst_1
     151: isub
     152: iload         10
     154: isub
     155: iload_1
     156: irem
     157: aaload
     158: aastore
     159: iinc          10, 1
     162: goto          117
     165: iload_3
     166: aload_0
     167: iload         7
     169: invokeinterface #47,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     174: checkcast     #49                 // class java/lang/Number
     177: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     180: iload         4
     182: iadd
     183: iadd
     184: istore_3
     185: iinc          4, 1
     188: iinc          7, 1
     191: goto          73
     194: iinc          6, 1
     197: goto          53
     200: aload         5
     202: areturn

  public static final int firstProd(java.lang.Integer[]);
    Code:
       0: aload_0
       1: ldc           #66                 // String list
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: aaload
       9: invokevirtual #67                 // Method java/lang/Integer.intValue:()I
      12: aload_0
      13: iconst_1
      14: aaload
      15: invokevirtual #67                 // Method java/lang/Integer.intValue:()I
      18: imul
      19: ireturn

  public static final java.lang.String denseHash(java.lang.Integer[], int);
    Code:
       0: aload_0
       1: ldc           #66                 // String list
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #71                 // String
       8: astore_2
       9: aload_0
      10: arraylength
      11: iload_1
      12: idiv
      13: istore_3
      14: iconst_0
      15: istore        4
      17: iload         4
      19: iload_1
      20: if_icmpge     193
      23: aload_0
      24: iload         4
      26: iload_3
      27: imul
      28: iload         4
      30: iconst_1
      31: iadd
      32: iload_3
      33: imul
      34: invokestatic  #77                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      37: invokestatic  #83                 // Method kotlin/collections/ArraysKt.slice:([Ljava/lang/Object;Lkotlin/ranges/IntRange;)Ljava/util/List;
      40: checkcast     #85                 // class java/lang/Iterable
      43: astore        6
      45: iconst_0
      46: istore        7
      48: aload         6
      50: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      55: astore        8
      57: aload         8
      59: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      64: ifne          77
      67: new           #97                 // class java/lang/UnsupportedOperationException
      70: dup
      71: ldc           #99                 // String Empty collection can\'t be reduced.
      73: invokespecial #103                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
      76: athrow
      77: aload         8
      79: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      84: astore        9
      86: aload         8
      88: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      93: ifeq          137
      96: aload         9
      98: aload         8
     100: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     105: checkcast     #49                 // class java/lang/Number
     108: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     111: istore        10
     113: checkcast     #49                 // class java/lang/Number
     116: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     119: istore        11
     121: iconst_0
     122: istore        12
     124: iload         11
     126: iload         10
     128: ixor
     129: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     132: astore        9
     134: goto          86
     137: aload         9
     139: checkcast     #49                 // class java/lang/Number
     142: invokevirtual #52                 // Method java/lang/Number.intValue:()I
     145: istore        5
     147: new           #109                // class java/lang/StringBuilder
     150: dup
     151: invokespecial #112                // Method java/lang/StringBuilder."<init>":()V
     154: aload_2
     155: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     158: iload         5
     160: bipush        16
     162: invokestatic  #122                // Method kotlin/text/CharsKt.checkRadix:(I)I
     165: invokestatic  #126                // Method java/lang/Integer.toString:(II)Ljava/lang/String;
     168: dup
     169: ldc           #128                // String toString(...)
     171: invokestatic  #39                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     174: iconst_2
     175: bipush        48
     177: invokestatic  #134                // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;
     180: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     183: invokevirtual #137                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     186: astore_2
     187: iinc          4, 1
     190: goto          17
     193: aload_2
     194: areturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #156                // String args
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #161                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       9: dup
      10: invokestatic  #165                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      13: astore_1
      14: iconst_5
      15: anewarray     #18                 // class java/lang/Integer
      18: astore_3
      19: aload_3
      20: iconst_0
      21: bipush        17
      23: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      26: aastore
      27: aload_3
      28: iconst_1
      29: bipush        31
      31: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      34: aastore
      35: aload_3
      36: iconst_2
      37: bipush        73
      39: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      42: aastore
      43: aload_3
      44: iconst_3
      45: bipush        47
      47: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      50: aastore
      51: aload_3
      52: iconst_4
      53: bipush        23
      55: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      58: aastore
      59: aload_3
      60: astore_2
      61: aload_1
      62: checkcast     #167                // class java/lang/CharSequence
      65: iconst_1
      66: anewarray     #152                // class java/lang/String
      69: astore_3
      70: aload_3
      71: iconst_0
      72: ldc           #169                // String ,
      74: aastore
      75: aload_3
      76: iconst_0
      77: iconst_0
      78: bipush        6
      80: aconst_null
      81: invokestatic  #173                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      84: checkcast     #85                 // class java/lang/Iterable
      87: astore_3
      88: iconst_0
      89: istore        4
      91: aload_3
      92: astore        5
      94: new           #175                // class java/util/ArrayList
      97: dup
      98: aload_3
      99: bipush        10
     101: invokestatic  #181                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     104: invokespecial #184                // Method java/util/ArrayList."<init>":(I)V
     107: checkcast     #24                 // class java/util/Collection
     110: astore        6
     112: iconst_0
     113: istore        7
     115: aload         5
     117: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     122: astore        8
     124: aload         8
     126: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     131: ifeq          178
     134: aload         8
     136: invokeinterface #107,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     141: astore        9
     143: aload         6
     145: aload         9
     147: checkcast     #152                // class java/lang/String
     150: astore        10
     152: astore        12
     154: iconst_0
     155: istore        11
     157: aload         10
     159: invokestatic  #188                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     162: nop
     163: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     166: aload         12
     168: swap
     169: invokeinterface #192,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     174: pop
     175: goto          124
     178: aload         6
     180: checkcast     #43                 // class java/util/List
     183: nop
     184: sipush        256
     187: iconst_1
     188: invokestatic  #194                // Method doHash:(Ljava/util/List;II)[Ljava/lang/Integer;
     191: invokestatic  #196                // Method firstProd:([Ljava/lang/Integer;)I
     194: istore_3
     195: getstatic     #202                // Field java/lang/System.out:Ljava/io/PrintStream;
     198: iload_3
     199: invokevirtual #207                // Method java/io/PrintStream.println:(I)V
     202: aload_1
     203: checkcast     #167                // class java/lang/CharSequence
     206: astore_3
     207: iconst_0
     208: istore        4
     210: aload_3
     211: astore        5
     213: new           #175                // class java/util/ArrayList
     216: dup
     217: aload_3
     218: invokeinterface #210,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     223: invokespecial #184                // Method java/util/ArrayList."<init>":(I)V
     226: checkcast     #24                 // class java/util/Collection
     229: astore        6
     231: iconst_0
     232: istore        7
     234: iconst_0
     235: istore        8
     237: iload         8
     239: aload         5
     241: invokeinterface #210,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     246: if_icmpge     291
     249: aload         5
     251: iload         8
     253: invokeinterface #214,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     258: istore        9
     260: aload         6
     262: iload         9
     264: istore        10
     266: astore        12
     268: iconst_0
     269: istore        11
     271: iload         10
     273: invokestatic  #22                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     276: aload         12
     278: swap
     279: invokeinterface #192,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     284: pop
     285: iinc          8, 1
     288: goto          237
     291: aload         6
     293: checkcast     #43                 // class java/util/List
     296: nop
     297: checkcast     #24                 // class java/util/Collection
     300: aload_2
     301: invokestatic  #218                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;[Ljava/lang/Object;)Ljava/util/List;
     304: sipush        256
     307: bipush        64
     309: invokestatic  #194                // Method doHash:(Ljava/util/List;II)[Ljava/lang/Integer;
     312: bipush        16
     314: invokestatic  #220                // Method denseHash:([Ljava/lang/Integer;I)Ljava/lang/String;
     317: getstatic     #202                // Field java/lang/System.out:Ljava/io/PrintStream;
     320: swap
     321: invokevirtual #222                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     324: return
}


fun printArray(x: IntArray) {
    for (i in x.indices)
        print(x[i].toString() + " ")
}

fun IntArray.sort(low: Int = 0, high: Int = this.size - 1) {
    if (low >= high) return

    val middle = partition(low, high)
    sort(low, middle - 1)
    sort(middle + 1, high)
}

fun IntArray.partition(low: Int, high: Int): Int {
    val middle = low + (high - low) / 2
    val a = this
    swap(a, middle, high)

    var storeIndex = low
    for (i in low until high) {
        if (a[i] < a[high]) {
            swap(a, storeIndex, i)
            storeIndex++
        }
    }
    swap(a, high, storeIndex)
    return storeIndex
}

fun swap(a: IntArray, i: Int, j: Int) {
    val temp = a[i]
    a[i] = a[j]
    a[j] = temp
}

fun main(args: Array<String>) {
    println("Enter the number of elements :")
    val n = readLine()!!.toInt()

    val arr = IntArray(n)

    println("Enter the elements.")

    for (i in 0 until n) {
        arr[i] = readLine()!!.toInt()
    }

    println("Given array")
    printArray(arr)

    arr.sort()

    println("\nSorted array")
    printArray(arr)

}

Compiled from "QuickSort.kt"
public final class QuickSortKt {
  public static final void printArray(int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String x
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: arraylength
      10: istore_2
      11: iload_1
      12: iload_2
      13: if_icmpge     50
      16: new           #17                 // class java/lang/StringBuilder
      19: dup
      20: invokespecial #21                 // Method java/lang/StringBuilder."<init>":()V
      23: aload_0
      24: iload_1
      25: iaload
      26: invokevirtual #25                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      29: bipush        32
      31: invokevirtual #28                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      34: invokevirtual #32                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      37: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      40: swap
      41: invokevirtual #44                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      44: iinc          1, 1
      47: goto          11
      50: return

  public static final void sort(int[], int, int);
    Code:
       0: aload_0
       1: ldc           #51                 // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: iload_2
       8: if_icmplt     12
      11: return
      12: aload_0
      13: iload_1
      14: iload_2
      15: invokestatic  #55                 // Method partition:([III)I
      18: istore_3
      19: aload_0
      20: iload_1
      21: iload_3
      22: iconst_1
      23: isub
      24: invokestatic  #57                 // Method sort:([III)V
      27: aload_0
      28: iload_3
      29: iconst_1
      30: iadd
      31: iload_2
      32: invokestatic  #57                 // Method sort:([III)V
      35: return

  public static void sort$default(int[], int, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: iload_3
       9: iconst_2
      10: iand
      11: ifeq          19
      14: aload_0
      15: arraylength
      16: iconst_1
      17: isub
      18: istore_2
      19: aload_0
      20: iload_1
      21: iload_2
      22: invokestatic  #57                 // Method sort:([III)V
      25: return

  public static final int partition(int[], int, int);
    Code:
       0: aload_0
       1: ldc           #51                 // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: iload_2
       8: iload_1
       9: isub
      10: iconst_2
      11: idiv
      12: iadd
      13: istore_3
      14: aload_0
      15: astore        4
      17: aload         4
      19: iload_3
      20: iload_2
      21: invokestatic  #66                 // Method swap:([III)V
      24: iload_1
      25: istore        5
      27: iload_1
      28: istore        6
      30: iload         6
      32: iload_2
      33: if_icmpge     66
      36: aload         4
      38: iload         6
      40: iaload
      41: aload         4
      43: iload_2
      44: iaload
      45: if_icmpge     60
      48: aload         4
      50: iload         5
      52: iload         6
      54: invokestatic  #66                 // Method swap:([III)V
      57: iinc          5, 1
      60: iinc          6, 1
      63: goto          30
      66: aload         4
      68: iload_2
      69: iload         5
      71: invokestatic  #66                 // Method swap:([III)V
      74: iload         5
      76: ireturn

  public static final void swap(int[], int, int);
    Code:
       0: aload_0
       1: ldc           #71                 // String a
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: iaload
       9: istore_3
      10: aload_0
      11: iload_1
      12: aload_0
      13: iload_2
      14: iaload
      15: iastore
      16: aload_0
      17: iload_2
      18: iload_3
      19: iastore
      20: return

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #77                 // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #79                 // String Enter the number of elements :
       8: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: swap
      12: invokevirtual #82                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      15: invokestatic  #87                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      18: dup
      19: invokestatic  #90                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      22: invokestatic  #96                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      25: istore_1
      26: iload_1
      27: newarray       int
      29: astore_2
      30: ldc           #98                 // String Enter the elements.
      32: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      35: swap
      36: invokevirtual #82                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      39: iconst_0
      40: istore_3
      41: iload_3
      42: iload_1
      43: if_icmpge     65
      46: aload_2
      47: iload_3
      48: invokestatic  #87                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      51: dup
      52: invokestatic  #90                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      55: invokestatic  #96                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      58: iastore
      59: iinc          3, 1
      62: goto          41
      65: ldc           #100                // String Given array
      67: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      70: swap
      71: invokevirtual #82                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      74: aload_2
      75: invokestatic  #102                // Method printArray:([I)V
      78: aload_2
      79: iconst_0
      80: iconst_0
      81: iconst_3
      82: aconst_null
      83: invokestatic  #104                // Method sort$default:([IIIILjava/lang/Object;)V
      86: ldc           #106                // String \nSorted array
      88: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      91: swap
      92: invokevirtual #82                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      95: aload_2
      96: invokestatic  #102                // Method printArray:([I)V
      99: return
}


import java.io.File

fun main() {
    fun parseInput(input: String) : List<Int> {
        fun getNext(rest: List<Int?>): Pair<Int,List<Int?>> {
            val next = rest.takeWhile {it != null} as List<Int>
            val temp = rest.dropWhile {it != null}
            val rest = if (temp.isEmpty()) {
                temp
            } else {
                temp.drop(1) //drop null
            }
            return Pair(next.sum(), rest)
        }

        var rest = input.lines().map {it.toIntOrNull()}
        val sums = mutableListOf<Int>()

        while (rest.isNotEmpty()) {
            val (sum, temp) = getNext(rest)
            rest = temp
            sums.add(sum)
        }

        return sums
    }

    fun part1(input: String): Int {
        val data = parseInput(input)
        return data.max()
    }

    fun part2(input:String): Int {
        val data = parseInput(input)
        return data
            .sortedDescending()
            .take(3)
            .sum()
    }

    val input = File("src/Day01.txt").readText()

    println(part1(input))
    println(part2(input))

}

Compiled from "Day01.kt"
public final class Day01Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String src/Day01.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      15: astore_0
      16: aload_0
      17: invokestatic  #24                 // Method main$part1:(Ljava/lang/String;)I
      20: istore_1
      21: getstatic     #30                 // Field java/lang/System.out:Ljava/io/PrintStream;
      24: iload_1
      25: invokevirtual #36                 // Method java/io/PrintStream.println:(I)V
      28: aload_0
      29: invokestatic  #39                 // Method main$part2:(Ljava/lang/String;)I
      32: istore_1
      33: getstatic     #30                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: iload_1
      37: invokevirtual #36                 // Method java/io/PrintStream.println:(I)V
      40: return

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

  private static final kotlin.Pair<java.lang.Integer, java.util.List<java.lang.Integer>> main$parseInput$getNext(java.util.List<java.lang.Integer>);
    Code:
       0: aload_0
       1: checkcast     #51                 // class java/lang/Iterable
       4: astore_3
       5: iconst_0
       6: istore        4
       8: new           #53                 // class java/util/ArrayList
      11: dup
      12: invokespecial #55                 // Method java/util/ArrayList."<init>":()V
      15: astore        5
      17: aload_3
      18: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      23: astore        6
      25: aload         6
      27: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          81
      35: aload         6
      37: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        7
      44: aload         7
      46: checkcast     #71                 // class java/lang/Integer
      49: astore        8
      51: iconst_0
      52: istore        9
      54: aload         8
      56: ifnull        63
      59: iconst_1
      60: goto          64
      63: iconst_0
      64: ifne          70
      67: goto          81
      70: aload         5
      72: aload         7
      74: invokevirtual #75                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      77: pop
      78: goto          25
      81: aload         5
      83: checkcast     #77                 // class java/util/List
      86: astore_1
      87: aload_0
      88: checkcast     #51                 // class java/lang/Iterable
      91: astore_3
      92: iconst_0
      93: istore        4
      95: iconst_0
      96: istore        5
      98: new           #53                 // class java/util/ArrayList
     101: dup
     102: invokespecial #55                 // Method java/util/ArrayList."<init>":()V
     105: astore        6
     107: aload_3
     108: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     113: astore        7
     115: aload         7
     117: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     122: ifeq          187
     125: aload         7
     127: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     132: astore        8
     134: iload         5
     136: ifeq          150
     139: aload         6
     141: aload         8
     143: invokevirtual #75                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     146: pop
     147: goto          115
     150: aload         8
     152: checkcast     #71                 // class java/lang/Integer
     155: astore        9
     157: iconst_0
     158: istore        10
     160: aload         9
     162: ifnull        169
     165: iconst_1
     166: goto          170
     169: iconst_0
     170: ifne          115
     173: aload         6
     175: aload         8
     177: invokevirtual #75                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     180: pop
     181: iconst_1
     182: istore        5
     184: goto          115
     187: aload         6
     189: checkcast     #77                 // class java/util/List
     192: astore_2
     193: aload_2
     194: invokeinterface #80,  1           // InterfaceMethod java/util/List.isEmpty:()Z
     199: ifeq          206
     202: aload_2
     203: goto          214
     206: aload_2
     207: checkcast     #51                 // class java/lang/Iterable
     210: iconst_1
     211: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     214: astore_3
     215: new           #88                 // class kotlin/Pair
     218: dup
     219: aload_1
     220: checkcast     #51                 // class java/lang/Iterable
     223: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     226: invokestatic  #96                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     229: aload_3
     230: invokespecial #99                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     233: areturn

  private static final java.util.List<java.lang.Integer> main$parseInput(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #123                // class java/lang/CharSequence
       4: invokestatic  #129                // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
       7: checkcast     #51                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: astore        4
      16: new           #53                 // class java/util/ArrayList
      19: dup
      20: aload_2
      21: bipush        10
      23: invokestatic  #133                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #135                // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #137                // class java/util/Collection
      32: astore        5
      34: iconst_0
      35: istore        6
      37: aload         4
      39: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        7
      46: aload         7
      48: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          96
      56: aload         7
      58: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        8
      65: aload         5
      67: aload         8
      69: checkcast     #139                // class java/lang/String
      72: astore        9
      74: astore        11
      76: iconst_0
      77: istore        10
      79: aload         9
      81: invokestatic  #143                // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;
      84: aload         11
      86: swap
      87: invokeinterface #144,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      92: pop
      93: goto          46
      96: aload         5
      98: checkcast     #77                 // class java/util/List
     101: nop
     102: astore_1
     103: new           #53                 // class java/util/ArrayList
     106: dup
     107: invokespecial #55                 // Method java/util/ArrayList."<init>":()V
     110: checkcast     #77                 // class java/util/List
     113: astore_2
     114: aload_1
     115: checkcast     #137                // class java/util/Collection
     118: invokeinterface #145,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     123: ifne          130
     126: iconst_1
     127: goto          131
     130: iconst_0
     131: ifeq          178
     134: aload_1
     135: invokestatic  #147                // Method main$parseInput$getNext:(Ljava/util/List;)Lkotlin/Pair;
     138: astore_3
     139: aload_3
     140: invokevirtual #150                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     143: checkcast     #152                // class java/lang/Number
     146: invokevirtual #156                // Method java/lang/Number.intValue:()I
     149: istore        4
     151: aload_3
     152: invokevirtual #159                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     155: checkcast     #77                 // class java/util/List
     158: astore        5
     160: aload         5
     162: astore_1
     163: aload_2
     164: iload         4
     166: invokestatic  #96                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     169: invokeinterface #160,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     174: pop
     175: goto          114
     178: aload_2
     179: areturn

  private static final int main$part1(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #172                // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;
       4: astore_1
       5: aload_1
       6: checkcast     #51                 // class java/lang/Iterable
       9: invokestatic  #176                // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      12: checkcast     #152                // class java/lang/Number
      15: invokevirtual #156                // Method java/lang/Number.intValue:()I
      18: ireturn

  private static final int main$part2(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #172                // Method main$parseInput:(Ljava/lang/String;)Ljava/util/List;
       4: astore_1
       5: aload_1
       6: checkcast     #51                 // class java/lang/Iterable
       9: invokestatic  #181                // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;
      12: checkcast     #51                 // class java/lang/Iterable
      15: iconst_3
      16: invokestatic  #184                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
      19: checkcast     #51                 // class java/lang/Iterable
      22: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
      25: ireturn
}


import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
import kotlin.math.absoluteValue

/**
 * Reads lines from the given input txt file.
 */
fun readInput(name: String) = File("src", "$name.txt").readLines()

/**
 * Converts string to md5 hash.
 */
fun String.md5(): String = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray())).toString(16).padStart(32, '0')

typealias Graph = Map<String, List<String>>
typealias Path = List<String>
typealias Fold = Pair<Char, Int>

data class Point2D (var x: Int, var y: Int) {
    operator fun plus(inc: Point2D) = Point2D(x + inc.x, y + inc.y)
    operator fun minus(inc: Point2D) = Point2D(x - inc.x, y - inc.y)

    fun neighbors4(): List<Point2D> {
        val neighborPoints = listOf(Point2D(1,0), Point2D(0,1), Point2D(-1, 0), Point2D(0,-1))
        return neighborPoints.map { this + it }.sortedWith(Point2DComparator())
    }

    fun neighbors8(): List<Point2D> {
        val neighborPoints = listOf(
            Point2D(1,0),
            Point2D(1,1),
            Point2D(0,1),
            Point2D(-1,1),
            Point2D(-1,0),
            Point2D(-1,-1),
            Point2D(0,-1),
            Point2D(1,-1)
        )
        return neighborPoints.map { this + it }.sortedWith(Point2DComparator())
    }

    fun neighbors4AndSelf(): List<Point2D> {
        val neighborPoints = neighbors4().toMutableList()
        neighborPoints.add(this)
        return neighborPoints.sortedWith(Point2DComparator())
    }

    fun neighbors8AndSelf(): List<Point2D> {
        val neighborPoints = neighbors8().toMutableList()
        neighborPoints.add(this)
        return neighborPoints.sortedWith(Point2DComparator())
    }

    fun distanceTo(other: Point2D) = (this.x - other.x).absoluteValue + (this.y - other.y).absoluteValue

    class Point2DComparator: Comparator<Point2D> {
        override fun compare(p0: Point2D?, p1: Point2D?): Int {
            return if (p0 == null || p1 == null)
                0
            else {
                when {
                    (p0.y > p1.y) -> 1
                    (p0.y < p1.y) -> -1
                    else -> {
                        when {
                            (p0.x > p1.x) -> 1
                            (p0.x < p1.x) -> -1
                            else -> 0
                        }
                    }
                }
            }
        }
    }

}

class Line(coords: List<String>) {
    val start: Point2D
    val end: Point2D

    init {
        val startPoint = coords[0].split(",")
        val endPoint = coords[1].split(",")
        this.start = Point2D(startPoint[0].toInt(), startPoint[1].toInt())
        this.end = Point2D(endPoint[0].toInt(), endPoint[1].toInt())
    }

    fun isHorizontal() = start.y == end.y
    fun isVertical() = start.x == end.x
    fun contains(point: Point2D) = point.y == getYAt(point.x)
    fun getYAt(x: Int) = ((end.y - start.y)/(end.x - start.x)) * (x - start.x) + start.y

    fun getAllIntegerPoints(): List<Point2D> {
        return when {
            isHorizontal() -> {
                when {
                    (start.x < end.x) -> IntRange(start.x, end.x).map{ p -> Point2D(p, start.y) }
                    else -> IntRange(end.x, start.x).map{ p -> Point2D(p, start.y) }
                }
            }
            isVertical() -> {
                when {
                    (start.y < end.y) -> IntRange(start.y, end.y).map{ p -> Point2D(start.x, p) }
                    else -> IntRange(end.y, start.y).map { p -> Point2D(start.x, p) }
                }
            }
            else -> {
                when {
                    (start.x < end.x) -> IntRange(start.x, end.x).map{ p -> Point2D(p, getYAt(p)) }
                    else -> IntRange(end.x, start.x).map{ p -> Point2D(p, getYAt(p)) }
                }
            }
        }
    }

    override fun toString(): String {
        return "(${start.x}, ${start.y}) -> (${end.x}, ${end.y})"
    }
}

class MyStack<E>(vararg items: E): Collection<E> {
    private val elements = items.toMutableList()

    fun push(element: E) = elements.add(element)
    fun peek(): E = elements.last()
    fun pop(): E = elements.removeAt(elements.size-1)
    override fun isEmpty() = elements.isEmpty()
    override fun contains(element: E) = elements.contains(element)
    override fun containsAll(elements: Collection<E>) = elements.containsAll(elements)
    override fun toString() = "Stack(${elements.joinToString()})"
    override fun iterator() = elements.iterator()
    override val size: Int
        get() = elements.size
}

data class Area<T>(var points: List<MutableList<T>>) {
    fun at(p: Point2D): T? {
        return points.getOrElse(p.y) { listOf() }.getOrNull(p.x)
    }

    fun setValue(p: Point2D, v: T) {
        if (at(p) != null) points[p.y][p.x] = v
    }

    companion object Factory {
        fun toIntArea(input: List<String>): Area<Int> {
            return Area(input.map { it.map { ch -> ch.toString().toInt() }.toMutableList() })
        }

        fun toBinaryArea(input: List<String>, one: Char, zero: Char): Area<Int> {
            return Area(input.map {
                it.map { c ->
                    when (c) {
                        one -> 1
                        zero -> 0
                        else -> 0
                    }
                }.toMutableList()
            })
        }
    }
}

data class Point3D(val x: Int, val y: Int, val z: Int) {
    operator fun plus(inc: Point3D) = Point3D(x + inc.x, y + inc.y, z + inc.z)
    operator fun minus(inc: Point3D) = Point3D(x - inc.x, y - inc.y, z - inc.z)
}

fun <T> List<T>.partitionGroups(divider: T): List<List<T>> {
    var startIndex = 0
    val result = mutableListOf<List<T>>()

    this.forEachIndexed { index, t ->
        if (t == divider) {
            result.add(this.subList(startIndex, index))
            startIndex = index + 1
        }
    }
    if (startIndex < this.size)
        result.add(this.subList(startIndex, this.size))
    return result
}

Compiled from "Utils.kt"
public final class UtilsKt {
  public static final java.util.List<java.lang.String> readInput(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String name
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #18                 // class java/io/File
       9: dup
      10: ldc           #20                 // String src
      12: new           #22                 // class java/lang/StringBuilder
      15: dup
      16: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
      19: aload_0
      20: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      23: ldc           #32                 // String .txt
      25: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      28: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      31: invokespecial #39                 // Method java/io/File."<init>":(Ljava/lang/String;Ljava/lang/String;)V
      34: aconst_null
      35: iconst_1
      36: aconst_null
      37: invokestatic  #45                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      40: areturn

  public static final java.lang.String md5(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #50                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #52                 // class java/math/BigInteger
       9: dup
      10: iconst_1
      11: ldc           #54                 // String MD5
      13: invokestatic  #60                 // Method java/security/MessageDigest.getInstance:(Ljava/lang/String;)Ljava/security/MessageDigest;
      16: aload_0
      17: astore_1
      18: getstatic     #66                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      21: aload_1
      22: swap
      23: invokevirtual #72                 // Method java/lang/String.getBytes:(Ljava/nio/charset/Charset;)[B
      26: dup
      27: ldc           #74                 // String getBytes(...)
      29: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      32: invokevirtual #81                 // Method java/security/MessageDigest.digest:([B)[B
      35: invokespecial #84                 // Method java/math/BigInteger."<init>":(I[B)V
      38: bipush        16
      40: invokevirtual #87                 // Method java/math/BigInteger.toString:(I)Ljava/lang/String;
      43: dup
      44: ldc           #89                 // String toString(...)
      46: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      49: bipush        32
      51: bipush        48
      53: invokestatic  #95                 // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;
      56: areturn

  public static final <T> java.util.List<java.util.List<T>> partitionGroups(java.util.List<? extends T>, T);
    Code:
       0: aload_0
       1: ldc           #50                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: new           #101                // class java/util/ArrayList
      11: dup
      12: invokespecial #102                // Method java/util/ArrayList."<init>":()V
      15: checkcast     #104                // class java/util/List
      18: astore_3
      19: aload_0
      20: checkcast     #106                // class java/lang/Iterable
      23: astore        4
      25: iconst_0
      26: istore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          120
      50: aload         7
      52: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: iload         6
      61: iinc          6, 1
      64: istore        9
      66: iload         9
      68: ifge          74
      71: invokestatic  #125                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      74: iload         9
      76: aload         8
      78: astore        10
      80: istore        11
      82: iconst_0
      83: istore        12
      85: aload         10
      87: aload_1
      88: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      91: ifeq          115
      94: aload_3
      95: aload_0
      96: iload_2
      97: iload         11
      99: invokeinterface #133,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     104: invokeinterface #137,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     109: pop
     110: iload         11
     112: iconst_1
     113: iadd
     114: istore_2
     115: nop
     116: nop
     117: goto          40
     120: nop
     121: iload_2
     122: aload_0
     123: invokeinterface #141,  1          // InterfaceMethod java/util/List.size:()I
     128: if_icmpge     151
     131: aload_3
     132: aload_0
     133: iload_2
     134: aload_0
     135: invokeinterface #141,  1          // InterfaceMethod java/util/List.size:()I
     140: invokeinterface #133,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     145: invokeinterface #137,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     150: pop
     151: aload_3
     152: areturn
}


/** Power function for integers */
fun Int.pow(exp: Int): Long {
    return this.toBigInteger().pow(exp).toLong()
}

/**
 * Sum decimal digits with power.
 *
 * @param x Calculate the digit powerd sum of this int.
 * @param p The exponent of the most significant digit.
 * @return sum of all decimal digits with power p,p+1,..
 */
fun digitSum(x: Int, p: Int): Long {
    var digits = IntArray(32)
    assert( 10.pow(digits.size) > Int.MAX_VALUE.toLong() )
    var nDigits = 0
    var rest = x
    while (rest > 0) {
        digits[nDigits] = rest % 10
        rest /= 10
        nDigits++
    }
    var sum: Long = 0
    for (i in 0..nDigits - 1) {
        sum += digits[i].pow(p + nDigits - i - 1)
    }
    return sum
}

/**
 * Calculates funny integer.
 *
 * @param n Integer to analyse.
 * @param p exponent of the most significant digit in the sum.
 * @return k with k*n = powered decimal digit sum of n.
 */
fun digPow(n: Int, p: Int): Int {
    val s = digitSum(n, p)
    return if (s % n == 0L) (s / n).toInt() else -1
}

Compiled from "Playing_with_digits.kt"
public final class Playing_with_digitsKt {
  public static final long pow(int, int);
    Code:
       0: iload_0
       1: i2l
       2: invokestatic  #12                 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
       5: dup
       6: ldc           #14                 // String valueOf(...)
       8: invokestatic  #20                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      11: iload_1
      12: invokevirtual #23                 // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;
      15: invokevirtual #27                 // Method java/math/BigInteger.longValue:()J
      18: lreturn

  public static final long digitSum(int, int);
    Code:
       0: bipush        32
       2: newarray       int
       4: astore_2
       5: bipush        10
       7: aload_2
       8: arraylength
       9: invokestatic  #33                 // Method pow:(II)J
      12: ldc2_w        #34                 // long 2147483647l
      15: lcmp
      16: ifle          23
      19: iconst_1
      20: goto          24
      23: iconst_0
      24: istore_3
      25: getstatic     #41                 // Field kotlin/_Assertions.ENABLED:Z
      28: ifeq          49
      31: iload_3
      32: ifne          49
      35: ldc           #43                 // String Assertion failed
      37: astore        4
      39: new           #45                 // class java/lang/AssertionError
      42: dup
      43: aload         4
      45: invokespecial #49                 // Method java/lang/AssertionError."<init>":(Ljava/lang/Object;)V
      48: athrow
      49: iconst_0
      50: istore_3
      51: iload_0
      52: istore        4
      54: iload         4
      56: ifle          80
      59: aload_2
      60: iload_3
      61: iload         4
      63: bipush        10
      65: irem
      66: iastore
      67: iload         4
      69: bipush        10
      71: idiv
      72: istore        4
      74: iinc          3, 1
      77: goto          54
      80: lconst_0
      81: lstore        5
      83: iconst_0
      84: istore        7
      86: iload_3
      87: iconst_1
      88: isub
      89: istore        8
      91: iload         7
      93: iload         8
      95: if_icmpgt     131
      98: lload         5
     100: aload_2
     101: iload         7
     103: iaload
     104: iload_1
     105: iload_3
     106: iadd
     107: iload         7
     109: isub
     110: iconst_1
     111: isub
     112: invokestatic  #33                 // Method pow:(II)J
     115: ladd
     116: lstore        5
     118: iload         7
     120: iload         8
     122: if_icmpeq     131
     125: iinc          7, 1
     128: goto          98
     131: lload         5
     133: lreturn

  public static final int digPow(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: invokestatic  #63                 // Method digitSum:(II)J
       5: lstore_2
       6: lload_2
       7: iload_0
       8: i2l
       9: lrem
      10: lconst_0
      11: lcmp
      12: ifne          23
      15: lload_2
      16: iload_0
      17: i2l
      18: ldiv
      19: l2i
      20: goto          24
      23: iconst_m1
      24: ireturn
}


/**
 * Generates all possible PINs based on the observed PIN. The true PIN is around the observed PIN.
 * Each key could be also the key around the observed key.
 *
 * @param The observed PIN.
 * @return All possible PINs.
 */
fun getPINs(observed: String): List<String> =
    when (observed.length) {
        0 -> emptyList()
        1 -> keyNeighbours[observed[0]]!!.map { it.toString() }
        else -> {
            var accu = emptyList<String>()
            val lhs = keyNeighbours[observed[0]]!!
            getPINs(observed.substring(1)).forEach { rhs -> lhs.forEach { it -> accu += it + rhs } }
            accu
        }
    }

/**
 * Map from observed key to all possible input kyes. Maps to an empty array if the key is not on the
 * keypad.
 */
private val keyNeighbours: Map<Char, CharArray> = generateKeyNeighbours("123,456,789, 0 ")

/**
 * Generates the map from observed key to possible keys.
 *
 * @param layout The layout of the keypad. Rows of the key pad are separated by comma.
 * @return Map observerd key -> possible keys.
 */
private fun generateKeyNeighbours(layout: String): Map<Char, CharArray> {
    var accu = HashMap<Char, CharArray>().withDefault { CharArray(0) }
    val keys: Array<String> = layout.split(',').toTypedArray()
    fun getKey(x: Int, y: Int): Char? =
        if (y in keys.indices && x in keys[y].indices && keys[y][x] != ' ') keys[y][x] else null
    for (row in keys.indices) for (col in keys[row].indices) getKey(col, row)?.let { k ->
        var options = emptyList<Char>()
        listOf(Pair(0, +1), Pair(0, -1), Pair(+1, 0), Pair(-1, 0), Pair(0, 0)).forEach { (x, y) ->
            getKey(col + x, row + y)?.let { options += it }
        }
        accu[k] = options.toCharArray()
    }
    return accu
}

Compiled from "The_observed_PIN.kt"
public final class The_observed_PINKt {
  private static final java.util.Map<java.lang.Character, char[]> keyNeighbours;

  public static final java.util.List<java.lang.String> getPINs(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String observed
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #22                 // Method java/lang/String.length:()I
      10: tableswitch   { // 0 to 1
                     0: 32
                     1: 38
               default: 143
          }
      32: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      35: goto          313
      38: getstatic     #32                 // Field keyNeighbours:Ljava/util/Map;
      41: aload_0
      42: iconst_0
      43: invokevirtual #36                 // Method java/lang/String.charAt:(I)C
      46: invokestatic  #42                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      49: invokeinterface #48,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      54: dup
      55: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      58: checkcast     #54                 // class "[C"
      61: astore_1
      62: iconst_0
      63: istore_2
      64: aload_1
      65: astore_3
      66: new           #56                 // class java/util/ArrayList
      69: dup
      70: aload_1
      71: arraylength
      72: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      75: checkcast     #62                 // class java/util/Collection
      78: astore        4
      80: iconst_0
      81: istore        5
      83: iconst_0
      84: istore        6
      86: aload_3
      87: arraylength
      88: istore        7
      90: iload         6
      92: iload         7
      94: if_icmpge     134
      97: aload_3
      98: iload         6
     100: caload
     101: istore        8
     103: aload         4
     105: iload         8
     107: istore        9
     109: astore        17
     111: iconst_0
     112: istore        10
     114: iload         9
     116: invokestatic  #65                 // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     119: aload         17
     121: swap
     122: invokeinterface #69,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     127: pop
     128: iinc          6, 1
     131: goto          90
     134: aload         4
     136: checkcast     #71                 // class java/util/List
     139: nop
     140: goto          313
     143: aconst_null
     144: astore_1
     145: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     148: astore_1
     149: getstatic     #32                 // Field keyNeighbours:Ljava/util/Map;
     152: aload_0
     153: iconst_0
     154: invokevirtual #36                 // Method java/lang/String.charAt:(I)C
     157: invokestatic  #42                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     160: invokeinterface #48,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     165: dup
     166: invokestatic  #52                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     169: checkcast     #54                 // class "[C"
     172: astore_2
     173: aload_0
     174: iconst_1
     175: invokevirtual #75                 // Method java/lang/String.substring:(I)Ljava/lang/String;
     178: dup
     179: ldc           #77                 // String substring(...)
     181: invokestatic  #80                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     184: invokestatic  #82                 // Method getPINs:(Ljava/lang/String;)Ljava/util/List;
     187: checkcast     #84                 // class java/lang/Iterable
     190: astore_3
     191: iconst_0
     192: istore        4
     194: aload_3
     195: invokeinterface #88,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     200: astore        5
     202: aload         5
     204: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     209: ifeq          311
     212: aload         5
     214: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     219: astore        6
     221: aload         6
     223: checkcast     #18                 // class java/lang/String
     226: astore        7
     228: iconst_0
     229: istore        8
     231: aload_2
     232: astore        9
     234: iconst_0
     235: istore        10
     237: iconst_0
     238: istore        11
     240: aload         9
     242: arraylength
     243: istore        12
     245: iload         11
     247: iload         12
     249: if_icmpge     305
     252: aload         9
     254: iload         11
     256: caload
     257: istore        13
     259: iload         13
     261: istore        14
     263: iconst_0
     264: istore        15
     266: aload_1
     267: checkcast     #62                 // class java/util/Collection
     270: iload         14
     272: istore        16
     274: new           #100                // class java/lang/StringBuilder
     277: dup
     278: invokespecial #103                // Method java/lang/StringBuilder."<init>":()V
     281: iload         16
     283: invokevirtual #107                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     286: aload         7
     288: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     291: invokevirtual #114                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     294: invokestatic  #118                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     297: astore_1
     298: nop
     299: iinc          11, 1
     302: goto          245
     305: nop
     306: nop
     307: nop
     308: goto          202
     311: nop
     312: aload_1
     313: areturn

  private static final java.util.Map<java.lang.Character, char[]> generateKeyNeighbours(java.lang.String);
    Code:
       0: aconst_null
       1: astore_1
       2: new           #145                // class java/util/HashMap
       5: dup
       6: invokespecial #146                // Method java/util/HashMap."<init>":()V
       9: checkcast     #44                 // class java/util/Map
      12: invokedynamic #165,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      17: invokestatic  #171                // Method kotlin/collections/MapsKt.withDefaultMutable:(Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Ljava/util/Map;
      20: astore_1
      21: aload_0
      22: checkcast     #173                // class java/lang/CharSequence
      25: iconst_1
      26: newarray       char
      28: astore_3
      29: aload_3
      30: iconst_0
      31: bipush        44
      33: castore
      34: aload_3
      35: iconst_0
      36: iconst_0
      37: bipush        6
      39: aconst_null
      40: invokestatic  #179                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
      43: checkcast     #62                 // class java/util/Collection
      46: astore_3
      47: iconst_0
      48: istore        4
      50: aload_3
      51: astore        5
      53: aload         5
      55: iconst_0
      56: anewarray     #18                 // class java/lang/String
      59: invokeinterface #183,  2          // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
      64: checkcast     #185                // class "[Ljava/lang/String;"
      67: astore_2
      68: iconst_0
      69: istore_3
      70: aload_2
      71: arraylength
      72: istore        4
      74: iload_3
      75: iload         4
      77: if_icmpge     400
      80: iconst_0
      81: istore        5
      83: aload_2
      84: iload_3
      85: aaload
      86: checkcast     #173                // class java/lang/CharSequence
      89: invokeinterface #186,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      94: istore        6
      96: iload         5
      98: iload         6
     100: if_icmpge     394
     103: aload_2
     104: iload         5
     106: iload_3
     107: invokestatic  #190                // Method generateKeyNeighbours$getKey:([Ljava/lang/String;II)Ljava/lang/Character;
     110: dup
     111: ifnull        387
     114: invokevirtual #194                // Method java/lang/Character.charValue:()C
     117: istore        7
     119: iconst_0
     120: istore        8
     122: aconst_null
     123: astore        9
     125: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     128: astore        9
     130: iconst_5
     131: anewarray     #196                // class kotlin/Pair
     134: astore        10
     136: aload         10
     138: iconst_0
     139: new           #196                // class kotlin/Pair
     142: dup
     143: iconst_0
     144: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     147: iconst_1
     148: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     151: invokespecial #204                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     154: aastore
     155: aload         10
     157: iconst_1
     158: new           #196                // class kotlin/Pair
     161: dup
     162: iconst_0
     163: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     166: iconst_m1
     167: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     170: invokespecial #204                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     173: aastore
     174: aload         10
     176: iconst_2
     177: new           #196                // class kotlin/Pair
     180: dup
     181: iconst_1
     182: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     185: iconst_0
     186: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     189: invokespecial #204                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     192: aastore
     193: aload         10
     195: iconst_3
     196: new           #196                // class kotlin/Pair
     199: dup
     200: iconst_m1
     201: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     204: iconst_0
     205: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     208: invokespecial #204                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     211: aastore
     212: aload         10
     214: iconst_4
     215: new           #196                // class kotlin/Pair
     218: dup
     219: iconst_0
     220: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     223: iconst_0
     224: invokestatic  #201                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     227: invokespecial #204                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     230: aastore
     231: aload         10
     233: invokestatic  #208                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     236: checkcast     #84                 // class java/lang/Iterable
     239: astore        10
     241: iconst_0
     242: istore        11
     244: aload         10
     246: invokeinterface #88,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     251: astore        12
     253: aload         12
     255: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     260: ifeq          358
     263: aload         12
     265: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     270: astore        13
     272: aload         13
     274: checkcast     #196                // class kotlin/Pair
     277: astore        14
     279: iconst_0
     280: istore        15
     282: aload         14
     284: invokevirtual #211                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     287: checkcast     #213                // class java/lang/Number
     290: invokevirtual #216                // Method java/lang/Number.intValue:()I
     293: istore        16
     295: aload         14
     297: invokevirtual #219                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     300: checkcast     #213                // class java/lang/Number
     303: invokevirtual #216                // Method java/lang/Number.intValue:()I
     306: istore        17
     308: aload_2
     309: iload         5
     311: iload         16
     313: iadd
     314: iload_3
     315: iload         17
     317: iadd
     318: invokestatic  #190                // Method generateKeyNeighbours$getKey:([Ljava/lang/String;II)Ljava/lang/Character;
     321: dup
     322: ifnull        351
     325: invokevirtual #194                // Method java/lang/Character.charValue:()C
     328: istore        18
     330: iconst_0
     331: istore        19
     333: aload         9
     335: checkcast     #62                 // class java/util/Collection
     338: iload         18
     340: invokestatic  #42                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     343: invokestatic  #118                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     346: astore        9
     348: goto          353
     351: pop
     352: nop
     353: nop
     354: nop
     355: goto          253
     358: nop
     359: iload         7
     361: invokestatic  #42                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     364: astore        11
     366: aload_1
     367: aload         11
     369: aload         9
     371: checkcast     #62                 // class java/util/Collection
     374: invokestatic  #223                // Method kotlin/collections/CollectionsKt.toCharArray:(Ljava/util/Collection;)[C
     377: invokeinterface #227,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     382: pop
     383: nop
     384: goto          388
     387: pop
     388: iinc          5, 1
     391: goto          96
     394: iinc          3, 1
     397: goto          74
     400: aload_1
     401: areturn

  private static final char[] generateKeyNeighbours$lambda$3(char);
    Code:
       0: iconst_0
       1: newarray       char
       3: areturn

  private static final java.lang.Character generateKeyNeighbours$getKey(java.lang.String[], int, int);
    Code:
       0: iconst_0
       1: iload_2
       2: if_icmpgt     19
       5: iload_2
       6: aload_0
       7: arraylength
       8: if_icmpge     15
      11: iconst_1
      12: goto          20
      15: iconst_0
      16: goto          20
      19: iconst_0
      20: ifeq          80
      23: iconst_0
      24: iload_1
      25: if_icmpgt     51
      28: iload_1
      29: aload_0
      30: iload_2
      31: aaload
      32: checkcast     #173                // class java/lang/CharSequence
      35: invokeinterface #186,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      40: if_icmpge     47
      43: iconst_1
      44: goto          52
      47: iconst_0
      48: goto          52
      51: iconst_0
      52: ifeq          80
      55: aload_0
      56: iload_2
      57: aaload
      58: iload_1
      59: invokevirtual #36                 // Method java/lang/String.charAt:(I)C
      62: bipush        32
      64: if_icmpeq     80
      67: aload_0
      68: iload_2
      69: aaload
      70: iload_1
      71: invokevirtual #36                 // Method java/lang/String.charAt:(I)C
      74: invokestatic  #42                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      77: goto          81
      80: aconst_null
      81: areturn

  static {};
    Code:
       0: ldc           #244                // String 123,456,789, 0
       2: invokestatic  #246                // Method generateKeyNeighbours:(Ljava/lang/String;)Ljava/util/Map;
       5: putstatic     #32                 // Field keyNeighbours:Ljava/util/Map;
       8: return
}