package kata

import java.util.*
import java.util.stream.Collectors.toList

/*

    Input : an array of integers.

    Output : this array, but sorted in such a way that there are two wings:
        the left wing with numbers decreasing,
        the right wing with numbers increasing.

        the two wings have the same length. If the length of the array is odd the wings are around the bottom, if the length is even the bottom is considered to be part of the right wing.

        each integer l of the left wing must be greater or equal to its counterpart r in the right wing, the difference l - r being as small as possible. In other words the right wing must be nearly as steeply as the left wing.

    The function is make_valley or makeValley or make-valley.
 */

fun makeValley(arr: IntArray): IntArray {
    val sarr = arr.sortedArrayDescending()
    val n = sarr.size
    val half = n / 2 + (n % 2)
    val last = n - if (n % 2 == 0) 1 else 0
    return (0 until n)
            .map { i -> if (i < half) sarr[i * 2] else sarr[last - ((i - n / 2) * 2)] }
            .toList().toIntArray()
}

fun makeValley2(arr:IntArray) = when (arr.size) {
    1 -> arr
    else -> arr.sortedArrayDescending().withIndex().groupBy { it.index % 2 }.map { it.value.map { it.value } }.windowed(2) { it[0] + it[1].sorted() }.flatten().toIntArray()
}

fun makeValley3(arr:IntArray):IntArray {
    val answer = IntArray(arr.size)
    arr.sort()

    for (i in 0 until arr.size) {
        if (i % 2 == 0) {
            answer[i / 2] = arr[arr.size - 1 - i]
        } else {
            answer[arr.size - 1 - i / 2] = arr[arr.size - 1 - i]
        }
    }

    return answer
}

fun main(args: Array<String>) {
    val arr = arrayOf(79, 35, 54, 19, 35, 25)
    //val arr = arrayOf(67, 93, 100, -16, 65, 97, 92)

    val x =
            arr
                    .sortedArrayDescending()
                    .withIndex()
                    .groupBy { it.index % 2 }
                    //.map { it.value }
                    //.map { it.value.map { it.value } }
                    //.windowed(2) { it[0] + it[1].sorted() }
                    //.flatten()
                    //.forEach { println(it) }
                    //.forEach { t, u -> println("t=$t u=$u")  }
                    //.forEach { i -> System.out.println("index=${i.index} value=${i.value}")}

//    else -> arr.sortedArrayDescending().withIndex().groupBy { it.index % 2 }
// .map { it.value.map { it.value } }.windowed(2) { it[0] + it[1].sorted() }.flatten().toIntArray()

}

Compiled from "HowGreenIsMyValley.kt"
public final class kata.HowGreenIsMyValleyKt {
  public static final int[] makeValley(int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String arr
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #20                 // Method kotlin/collections/ArraysKt.sortedArrayDescending:([I)[I
      10: astore_1
      11: aload_1
      12: arraylength
      13: istore_2
      14: iload_2
      15: iconst_2
      16: idiv
      17: iload_2
      18: iconst_2
      19: irem
      20: iadd
      21: istore_3
      22: iload_2
      23: iload_2
      24: iconst_2
      25: irem
      26: ifne          33
      29: iconst_1
      30: goto          34
      33: iconst_0
      34: isub
      35: istore        4
      37: iconst_0
      38: iload_2
      39: invokestatic  #26                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      42: checkcast     #28                 // class java/lang/Iterable
      45: astore        5
      47: nop
      48: iconst_0
      49: istore        6
      51: aload         5
      53: astore        7
      55: new           #30                 // class java/util/ArrayList
      58: dup
      59: aload         5
      61: bipush        10
      63: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      66: invokespecial #40                 // Method java/util/ArrayList."<init>":(I)V
      69: checkcast     #42                 // class java/util/Collection
      72: astore        8
      74: iconst_0
      75: istore        9
      77: aload         7
      79: invokeinterface #46,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      84: astore        10
      86: aload         10
      88: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      93: ifeq          160
      96: aload         10
      98: checkcast     #54                 // class kotlin/collections/IntIterator
     101: invokevirtual #58                 // Method kotlin/collections/IntIterator.nextInt:()I
     104: istore        11
     106: aload         8
     108: iload         11
     110: istore        12
     112: astore        14
     114: iconst_0
     115: istore        13
     117: iload         12
     119: iload_3
     120: if_icmpge     132
     123: aload_1
     124: iload         12
     126: iconst_2
     127: imul
     128: iaload
     129: goto          145
     132: aload_1
     133: iload         4
     135: iload         12
     137: iload_2
     138: iconst_2
     139: idiv
     140: isub
     141: iconst_2
     142: imul
     143: isub
     144: iaload
     145: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     148: aload         14
     150: swap
     151: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     156: pop
     157: goto          86
     160: aload         8
     162: checkcast     #70                 // class java/util/List
     165: nop
     166: checkcast     #28                 // class java/lang/Iterable
     169: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     172: checkcast     #42                 // class java/util/Collection
     175: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     178: areturn

  public static final int[] makeValley2(int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String arr
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: arraylength
       8: iconst_1
       9: if_icmpne     16
      12: aload_0
      13: goto          407
      16: aload_0
      17: invokestatic  #20                 // Method kotlin/collections/ArraysKt.sortedArrayDescending:([I)[I
      20: invokestatic  #100                // Method kotlin/collections/ArraysKt.withIndex:([I)Ljava/lang/Iterable;
      23: astore_1
      24: iconst_0
      25: istore_2
      26: aload_1
      27: astore_3
      28: new           #102                // class java/util/LinkedHashMap
      31: dup
      32: invokespecial #105                // Method java/util/LinkedHashMap."<init>":()V
      35: checkcast     #107                // class java/util/Map
      38: astore        4
      40: iconst_0
      41: istore        5
      43: aload_3
      44: invokeinterface #46,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      49: astore        6
      51: aload         6
      53: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          168
      61: aload         6
      63: invokeinterface #111,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: astore        7
      70: aload         7
      72: checkcast     #113                // class kotlin/collections/IndexedValue
      75: astore        8
      77: iconst_0
      78: istore        9
      80: aload         8
      82: invokevirtual #116                // Method kotlin/collections/IndexedValue.getIndex:()I
      85: iconst_2
      86: irem
      87: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      90: astore        10
      92: aload         4
      94: astore        11
      96: iconst_0
      97: istore        12
      99: aload         11
     101: aload         10
     103: invokeinterface #120,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     108: astore        13
     110: aload         13
     112: ifnonnull     147
     115: iconst_0
     116: istore        14
     118: new           #30                 // class java/util/ArrayList
     121: dup
     122: invokespecial #121                // Method java/util/ArrayList."<init>":()V
     125: checkcast     #70                 // class java/util/List
     128: astore        14
     130: aload         11
     132: aload         10
     134: aload         14
     136: invokeinterface #125,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     141: pop
     142: aload         14
     144: goto          149
     147: aload         13
     149: nop
     150: checkcast     #70                 // class java/util/List
     153: astore        8
     155: aload         8
     157: aload         7
     159: invokeinterface #126,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     164: pop
     165: goto          51
     168: aload         4
     170: nop
     171: astore_1
     172: nop
     173: iconst_0
     174: istore_2
     175: aload_1
     176: astore_3
     177: new           #30                 // class java/util/ArrayList
     180: dup
     181: aload_1
     182: invokeinterface #129,  1          // InterfaceMethod java/util/Map.size:()I
     187: invokespecial #40                 // Method java/util/ArrayList."<init>":(I)V
     190: checkcast     #42                 // class java/util/Collection
     193: astore        4
     195: iconst_0
     196: istore        5
     198: aload_3
     199: invokeinterface #133,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     204: invokeinterface #136,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     209: astore        6
     211: aload         6
     213: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     218: ifeq          372
     221: aload         6
     223: invokeinterface #111,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     228: checkcast     #138                // class java/util/Map$Entry
     231: astore        7
     233: aload         4
     235: aload         7
     237: astore        8
     239: astore        20
     241: iconst_0
     242: istore        9
     244: aload         8
     246: invokeinterface #141,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     251: checkcast     #28                 // class java/lang/Iterable
     254: astore        10
     256: iconst_0
     257: istore        11
     259: aload         10
     261: astore        12
     263: new           #30                 // class java/util/ArrayList
     266: dup
     267: aload         10
     269: bipush        10
     271: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     274: invokespecial #40                 // Method java/util/ArrayList."<init>":(I)V
     277: checkcast     #42                 // class java/util/Collection
     280: astore        13
     282: iconst_0
     283: istore        14
     285: aload         12
     287: invokeinterface #46,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     292: astore        15
     294: aload         15
     296: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     301: ifeq          353
     304: aload         15
     306: invokeinterface #111,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     311: astore        16
     313: aload         13
     315: aload         16
     317: checkcast     #113                // class kotlin/collections/IndexedValue
     320: astore        17
     322: astore        18
     324: iconst_0
     325: istore        19
     327: aload         17
     329: invokevirtual #142                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     332: checkcast     #144                // class java/lang/Number
     335: invokevirtual #147                // Method java/lang/Number.intValue:()I
     338: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     341: aload         18
     343: swap
     344: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     349: pop
     350: goto          294
     353: aload         13
     355: checkcast     #70                 // class java/util/List
     358: nop
     359: nop
     360: aload         20
     362: swap
     363: invokeinterface #68,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     368: pop
     369: goto          211
     372: aload         4
     374: checkcast     #70                 // class java/util/List
     377: nop
     378: checkcast     #28                 // class java/lang/Iterable
     381: iconst_2
     382: iconst_0
     383: iconst_0
     384: invokedynamic #165,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     389: bipush        6
     391: aconst_null
     392: invokestatic  #169                // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;
     395: checkcast     #28                 // class java/lang/Iterable
     398: invokestatic  #172                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     401: checkcast     #42                 // class java/util/Collection
     404: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     407: areturn

  public static final int[] makeValley3(int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String arr
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: arraylength
       8: newarray       int
      10: astore_1
      11: aload_0
      12: invokestatic  #198                // Method kotlin/collections/ArraysKt.sort:([I)V
      15: iconst_0
      16: istore_2
      17: aload_0
      18: arraylength
      19: istore_3
      20: iload_2
      21: iload_3
      22: if_icmpge     71
      25: iload_2
      26: iconst_2
      27: irem
      28: ifne          47
      31: aload_1
      32: iload_2
      33: iconst_2
      34: idiv
      35: aload_0
      36: aload_0
      37: arraylength
      38: iconst_1
      39: isub
      40: iload_2
      41: isub
      42: iaload
      43: iastore
      44: goto          65
      47: aload_1
      48: aload_0
      49: arraylength
      50: iconst_1
      51: isub
      52: iload_2
      53: iconst_2
      54: idiv
      55: isub
      56: aload_0
      57: aload_0
      58: arraylength
      59: iconst_1
      60: isub
      61: iload_2
      62: isub
      63: iaload
      64: iastore
      65: iinc          2, 1
      68: goto          20
      71: aload_1
      72: areturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #203                // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: bipush        6
       8: anewarray     #60                 // class java/lang/Integer
      11: astore_2
      12: aload_2
      13: iconst_0
      14: bipush        79
      16: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      19: aastore
      20: aload_2
      21: iconst_1
      22: bipush        35
      24: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      27: aastore
      28: aload_2
      29: iconst_2
      30: bipush        54
      32: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aastore
      36: aload_2
      37: iconst_3
      38: bipush        19
      40: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: aastore
      44: aload_2
      45: iconst_4
      46: bipush        35
      48: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      51: aastore
      52: aload_2
      53: iconst_5
      54: bipush        25
      56: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      59: aastore
      60: aload_2
      61: astore_1
      62: aload_1
      63: checkcast     #205                // class "[Ljava/lang/Comparable;"
      66: invokestatic  #208                // Method kotlin/collections/ArraysKt.sortedArrayDescending:([Ljava/lang/Comparable;)[Ljava/lang/Comparable;
      69: invokestatic  #211                // Method kotlin/collections/ArraysKt.withIndex:([Ljava/lang/Object;)Ljava/lang/Iterable;
      72: astore_3
      73: nop
      74: iconst_0
      75: istore        4
      77: aload_3
      78: astore        5
      80: new           #102                // class java/util/LinkedHashMap
      83: dup
      84: invokespecial #105                // Method java/util/LinkedHashMap."<init>":()V
      87: checkcast     #107                // class java/util/Map
      90: astore        6
      92: iconst_0
      93: istore        7
      95: aload         5
      97: invokeinterface #46,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     102: astore        8
     104: aload         8
     106: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     111: ifeq          221
     114: aload         8
     116: invokeinterface #111,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     121: astore        9
     123: aload         9
     125: checkcast     #113                // class kotlin/collections/IndexedValue
     128: astore        10
     130: iconst_0
     131: istore        11
     133: aload         10
     135: invokevirtual #116                // Method kotlin/collections/IndexedValue.getIndex:()I
     138: iconst_2
     139: irem
     140: invokestatic  #64                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     143: astore        12
     145: aload         6
     147: astore        13
     149: iconst_0
     150: istore        14
     152: aload         13
     154: aload         12
     156: invokeinterface #120,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     161: astore        15
     163: aload         15
     165: ifnonnull     200
     168: iconst_0
     169: istore        16
     171: new           #30                 // class java/util/ArrayList
     174: dup
     175: invokespecial #121                // Method java/util/ArrayList."<init>":()V
     178: checkcast     #70                 // class java/util/List
     181: astore        16
     183: aload         13
     185: aload         12
     187: aload         16
     189: invokeinterface #125,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     194: pop
     195: aload         16
     197: goto          202
     200: aload         15
     202: nop
     203: checkcast     #70                 // class java/util/List
     206: astore        10
     208: aload         10
     210: aload         9
     212: invokeinterface #126,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     217: pop
     218: goto          104
     221: aload         6
     223: nop
     224: astore_2
     225: return

  private static final java.util.List makeValley2$lambda$4(java.util.List);
    Code:
       0: aload_0
       1: ldc           #218                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iconst_0
       8: invokeinterface #221,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #42                 // class java/util/Collection
      16: aload_0
      17: iconst_1
      18: invokeinterface #221,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      23: checkcast     #28                 // class java/lang/Iterable
      26: invokestatic  #224                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      29: checkcast     #28                 // class java/lang/Iterable
      32: invokestatic  #228                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      35: areturn
}


package com.cristianovecchi.mikrokanon.dataAnalysis

// version 1.2.21

import java.util.Random
import kotlin.math.*

data class Point(var x: Double, var y: Double, var group: Int, val partIndex: Int, val noteIndex: Int)

typealias LPoint = List<Point>
typealias MLPoint = MutableList<Point>

val origin get() = Point(0.0, 0.0, 0, 0, 0)
val r = Random()
val hugeVal = Double.POSITIVE_INFINITY

const val RAND_MAX = Int.MAX_VALUE
const val PTS = 40
const val K = 10 // number of groups
const val W = 400
const val H = 400

fun main() {
    val points = genXY(PTS, 10.0)
    val centroids = lloyd(points, PTS, K)
//    println("POINTS(${points.size}): $points")
//    println("CENTROIDS(${centroids.size}): $centroids")
    points.forEach{
        println("$it -> ${centroids[it.group]}")
    }
    val sums = points.groupingBy { it.group }.eachCount().toSortedMap()
    println(sums)
    //printEps(points, PTS, centroids, K)
}

fun rand() = r.nextInt(RAND_MAX)

fun randf(m: Double) = m * rand() / (RAND_MAX - 1)

fun genXY(count: Int, radius: Double): LPoint {
    val pts = List(count) { origin }

    /* note: this is not a uniform 2-d distribution */
    for (i in 0 until count) {
        val ang = randf(2.0 * PI)
        val r = randf(radius)
        pts[i].x = r * cos(ang)
        pts[i].y = r * sin(ang)
    }
    return pts
}

fun dist2(a: Point, b: Point): Double {
    val x = a.x - b.x
    val y = a.y - b.y
    return x * x + y * y
}

fun nearest(pt: Point, cent: LPoint, nCluster: Int): Pair<Int, Double> {
    var minD = hugeVal
    var minI = pt.group
    for (i in 0 until nCluster) {
        val d = dist2(cent[i], pt)
        if (minD > d) {
            minD = d
            minI = i
        }
    }
    return minI to minD
}

fun kpp(pts: LPoint, len: Int, cent: MLPoint) {
    if (pts.isEmpty() || len == 0) return
    val nCent = cent.size
    val d = DoubleArray(len)
    //println("points size:${pts.size}  length:$len")
    cent[0] = pts[rand() % len].copy()
    for (nCluster in 1 until nCent) {
        var sum = 0.0
        for (j in 0 until len) {
            d[j] = nearest(pts[j], cent, nCluster).second
            sum += d[j]
        }
        sum = randf(sum)
        for (j in 0 until len) {
            sum -= d[j]
            if (sum > 0.0) continue
            cent[nCluster] = pts[j].copy()
            break
        }
    }
    for (j in 0 until len) pts[j].group = nearest(pts[j], cent, nCent).first
}

fun lloyd(pts: LPoint, len: Int, nCluster: Int): LPoint {
    val cent = MutableList(nCluster) { origin }
    kpp(pts, len, cent)
    do {
        /* group element for centroids are used as counters */
        for (i in 0 until nCluster) {
            with (cent[i]) { x = 0.0; y = 0.0; group = 0 }
        }
        for (j in 0 until len) {
            val p = pts[j]
            val c = cent[p.group]
            with (c) { group++; x += p.x; y += p.y }
        }
        for (i in 0 until nCluster) {
            val c = cent[i]
            c.x /= c.group
            c.y /= c.group
        }
        var changed = 0

        /* find closest centroid of each point */
        for (j in 0 until len) {
            val p = pts[j]
            val minI = nearest(p, cent, nCluster).first
            if (minI != p.group) {
                changed++
                p.group = minI
            }
        }
    }
    while (changed > (len shr 10))  /* stop when 99.9% of points are good */

    for (i in 0 until nCluster) cent[i].group = i
    return cent
}

fun printEps(pts: LPoint, len: Int, cent: LPoint, nCluster: Int) {
    val colors = DoubleArray(nCluster * 3)
    for (i in 0 until nCluster) {
        colors[3 * i + 0] = (3 * (i + 1) % 11) / 11.0
        colors[3 * i + 1] = (7 * i % 11) / 11.0
        colors[3 * i + 2] = (9 * i % 11) / 11.0
    }
    var minX = hugeVal
    var minY = hugeVal
    var maxX = -hugeVal
    var maxY = -hugeVal
    for (j in 0 until len) {
        val p = pts[j]
        if (maxX < p.x) maxX = p.x
        if (minX > p.x) minX = p.x
        if (maxY < p.y) maxY = p.y
        if (minY > p.y) minY = p.y
    }
    val scale = minOf(W / (maxX - minX), H / (maxY - minY))
    val cx = (maxX + minX) / 2.0
    val cy = (maxY + minY) / 2.0

    print("%%!PS-Adobe-3.0\n%%%%BoundingBox: -5 -5 %${W + 10} ${H + 10}\n")
    print("/l {rlineto} def /m {rmoveto} def\n")
    print("/c { .25 sub exch .25 sub exch .5 0 360 arc fill } def\n")
    print("/s { moveto -2 0 m 2 2 l 2 -2 l -2 -2 l closepath ")
    print("	gsave 1 setgray fill grestore gsave 3 setlinewidth")
    print(" 1 setgray stroke grestore 0 setgray stroke }def\n")
    val f1 = "%g %g %g setrgbcolor"
    val f2 = "%.3f %.3f c"
    val f3 = "\n0 setgray %g %g s"
    for (i in 0 until nCluster) {
        val c = cent[i]
        println(f1.format(colors[3 * i], colors[3 * i + 1], colors[3 * i + 2]))
        for (j in 0 until len) {
            val p = pts[j]
            if (p.group != i) continue
            println(f2.format((p.x - cx) * scale + W / 2, (p.y - cy) * scale + H / 2))
        }
        println(f3.format((c.x - cx) * scale + W / 2, (c.y - cy) * scale + H / 2))
    }
    print("\n%%%%EOF")
}

Compiled from "_Collections.kt"
public final class com.cristianovecchi.mikrokanon.dataAnalysis.KmeansKt$main$$inlined$groupingBy$1 implements kotlin.collections.Grouping<com.cristianovecchi.mikrokanon.dataAnalysis.Point, java.lang.Integer> {
  final java.lang.Iterable $this_groupingBy;

  public com.cristianovecchi.mikrokanon.dataAnalysis.KmeansKt$main$$inlined$groupingBy$1(java.lang.Iterable);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<com.cristianovecchi.mikrokanon.dataAnalysis.Point> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       4: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: areturn

  public java.lang.Integer keyOf(com.cristianovecchi.mikrokanon.dataAnalysis.Point);
    Code:
       0: aload_1
       1: checkcast     #37                 // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: invokevirtual #41                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
      11: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: areturn
}

Compiled from "Kmeans.kt"
public final class com.cristianovecchi.mikrokanon.dataAnalysis.KmeansKt {
  private static final java.util.Random r;

  private static final double hugeVal;

  public static final int RAND_MAX;

  public static final int PTS;

  public static final int K;

  public static final int W;

  public static final int H;

  public static final com.cristianovecchi.mikrokanon.dataAnalysis.Point getOrigin();
    Code:
       0: new           #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
       3: dup
       4: dconst_0
       5: dconst_0
       6: iconst_0
       7: iconst_0
       8: iconst_0
       9: invokespecial #13                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point."<init>":(DDIII)V
      12: areturn

  public static final java.util.Random getR();
    Code:
       0: getstatic     #19                 // Field r:Ljava/util/Random;
       3: areturn

  public static final double getHugeVal();
    Code:
       0: getstatic     #25                 // Field hugeVal:D
       3: dreturn

  public static final void main();
    Code:
       0: bipush        40
       2: ldc2_w        #28                 // double 10.0d
       5: invokestatic  #33                 // Method genXY:(ID)Ljava/util/List;
       8: astore_0
       9: aload_0
      10: bipush        40
      12: bipush        10
      14: invokestatic  #37                 // Method lloyd:(Ljava/util/List;II)Ljava/util/List;
      17: astore_1
      18: aload_0
      19: checkcast     #39                 // class java/lang/Iterable
      22: astore_2
      23: iconst_0
      24: istore_3
      25: aload_2
      26: invokeinterface #43,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        4
      33: aload         4
      35: invokeinterface #49,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          108
      43: aload         4
      45: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        5
      52: aload         5
      54: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
      57: astore        6
      59: iconst_0
      60: istore        7
      62: new           #55                 // class java/lang/StringBuilder
      65: dup
      66: invokespecial #57                 // Method java/lang/StringBuilder."<init>":()V
      69: aload         6
      71: invokevirtual #61                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      74: ldc           #63                 // String  ->
      76: invokevirtual #66                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      79: aload_1
      80: aload         6
      82: invokevirtual #70                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
      85: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      90: invokevirtual #61                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      93: invokevirtual #80                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      96: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
      99: swap
     100: invokevirtual #92                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     103: nop
     104: nop
     105: goto          33
     108: nop
     109: aload_0
     110: checkcast     #39                 // class java/lang/Iterable
     113: astore_3
     114: iconst_0
     115: istore        4
     117: new           #94                 // class com/cristianovecchi/mikrokanon/dataAnalysis/KmeansKt$main$$inlined$groupingBy$1
     120: dup
     121: aload_3
     122: invokespecial #97                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/KmeansKt$main$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
     125: checkcast     #99                 // class kotlin/collections/Grouping
     128: invokestatic  #105                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
     131: invokestatic  #111                // Method kotlin/collections/MapsKt.toSortedMap:(Ljava/util/Map;)Ljava/util/SortedMap;
     134: astore_2
     135: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     138: aload_2
     139: invokevirtual #92                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     142: return

  public static final int rand();
    Code:
       0: getstatic     #19                 // Field r:Ljava/util/Random;
       3: ldc           #129                // int 2147483647
       5: invokevirtual #135                // Method java/util/Random.nextInt:(I)I
       8: ireturn

  public static final double randf(double);
    Code:
       0: dload_0
       1: invokestatic  #139                // Method rand:()I
       4: i2d
       5: dmul
       6: ldc           #140                // int 2147483646
       8: i2d
       9: ddiv
      10: dreturn

  public static final java.util.List<com.cristianovecchi.mikrokanon.dataAnalysis.Point> genXY(int, double);
    Code:
       0: new           #144                // class java/util/ArrayList
       3: dup
       4: iload_0
       5: invokespecial #147                // Method java/util/ArrayList."<init>":(I)V
       8: astore        4
      10: iconst_0
      11: istore        5
      13: iload         5
      15: iload_0
      16: if_icmpge     50
      19: iload         5
      21: istore        6
      23: aload         4
      25: iload         6
      27: istore        7
      29: astore        9
      31: iconst_0
      32: istore        8
      34: invokestatic  #149                // Method getOrigin:()Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;
      37: aload         9
      39: swap
      40: invokevirtual #153                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      43: pop
      44: iinc          5, 1
      47: goto          13
      50: aload         4
      52: checkcast     #72                 // class java/util/List
      55: astore_3
      56: iconst_0
      57: istore        4
      59: iload         4
      61: iload_0
      62: if_icmpge     129
      65: ldc2_w        #154                // double 6.283185307179586d
      68: invokestatic  #157                // Method randf:(D)D
      71: dstore        5
      73: dload_1
      74: invokestatic  #157                // Method randf:(D)D
      77: dstore        7
      79: aload_3
      80: iload         4
      82: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      87: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
      90: dload         7
      92: dload         5
      94: invokestatic  #162                // Method java/lang/Math.cos:(D)D
      97: dmul
      98: invokevirtual #166                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setX:(D)V
     101: aload_3
     102: iload         4
     104: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     109: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     112: dload         7
     114: dload         5
     116: invokestatic  #169                // Method java/lang/Math.sin:(D)D
     119: dmul
     120: invokevirtual #172                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setY:(D)V
     123: iinc          4, 1
     126: goto          59
     129: aload_3
     130: areturn

  public static final double dist2(com.cristianovecchi.mikrokanon.dataAnalysis.Point, com.cristianovecchi.mikrokanon.dataAnalysis.Point);
    Code:
       0: aload_0
       1: ldc           #182                // String a
       3: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #190                // String b
       9: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
      16: aload_1
      17: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
      20: dsub
      21: dstore_2
      22: aload_0
      23: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
      26: aload_1
      27: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
      30: dsub
      31: dstore        4
      33: dload_2
      34: dload_2
      35: dmul
      36: dload         4
      38: dload         4
      40: dmul
      41: dadd
      42: dreturn

  public static final kotlin.Pair<java.lang.Integer, java.lang.Double> nearest(com.cristianovecchi.mikrokanon.dataAnalysis.Point, java.util.List<com.cristianovecchi.mikrokanon.dataAnalysis.Point>, int);
    Code:
       0: aload_0
       1: ldc           #203                // String pt
       3: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #205                // String cent
       9: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: getstatic     #25                 // Field hugeVal:D
      15: dstore_3
      16: aload_0
      17: invokevirtual #70                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
      20: istore        5
      22: iconst_0
      23: istore        6
      25: iload         6
      27: iload_2
      28: if_icmpge     68
      31: aload_1
      32: iload         6
      34: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      39: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
      42: aload_0
      43: invokestatic  #207                // Method dist2:(Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;)D
      46: dstore        7
      48: dload_3
      49: dload         7
      51: dcmpl
      52: ifle          62
      55: dload         7
      57: dstore_3
      58: iload         6
      60: istore        5
      62: iinc          6, 1
      65: goto          25
      68: iload         5
      70: invokestatic  #213                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      73: dload_3
      74: invokestatic  #218                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      77: invokestatic  #224                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      80: areturn

  public static final void kpp(java.util.List<com.cristianovecchi.mikrokanon.dataAnalysis.Point>, int, java.util.List<com.cristianovecchi.mikrokanon.dataAnalysis.Point>);
    Code:
       0: aload_0
       1: ldc           #232                // String pts
       3: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #205                // String cent
       9: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokeinterface #235,  1          // InterfaceMethod java/util/List.isEmpty:()Z
      18: ifne          25
      21: iload_1
      22: ifne          26
      25: return
      26: aload_2
      27: invokeinterface #238,  1          // InterfaceMethod java/util/List.size:()I
      32: istore_3
      33: iload_1
      34: newarray       double
      36: astore        4
      38: aload_2
      39: iconst_0
      40: aload_0
      41: invokestatic  #139                // Method rand:()I
      44: iload_1
      45: irem
      46: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      51: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
      54: dconst_0
      55: dconst_0
      56: iconst_0
      57: iconst_0
      58: iconst_0
      59: bipush        31
      61: aconst_null
      62: invokestatic  #242                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.copy$default:(Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;DDIIIILjava/lang/Object;)Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;
      65: invokeinterface #246,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
      70: pop
      71: iconst_1
      72: istore        5
      74: iload         5
      76: iload_3
      77: if_icmpge     218
      80: dconst_0
      81: dstore        6
      83: iconst_0
      84: istore        8
      86: iload         8
      88: iload_1
      89: if_icmpge     139
      92: aload         4
      94: iload         8
      96: aload_0
      97: iload         8
      99: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     104: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     107: aload_2
     108: iload         5
     110: invokestatic  #248                // Method nearest:(Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;Ljava/util/List;I)Lkotlin/Pair;
     113: invokevirtual #253                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     116: checkcast     #255                // class java/lang/Number
     119: invokevirtual #258                // Method java/lang/Number.doubleValue:()D
     122: dastore
     123: dload         6
     125: aload         4
     127: iload         8
     129: daload
     130: dadd
     131: dstore        6
     133: iinc          8, 1
     136: goto          86
     139: dload         6
     141: invokestatic  #157                // Method randf:(D)D
     144: dstore        6
     146: iconst_0
     147: istore        8
     149: iload         8
     151: iload_1
     152: if_icmpge     212
     155: dload         6
     157: aload         4
     159: iload         8
     161: daload
     162: dsub
     163: dstore        6
     165: dload         6
     167: dconst_0
     168: dcmpl
     169: ifgt          206
     172: aload_2
     173: iload         5
     175: aload_0
     176: iload         8
     178: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     183: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     186: dconst_0
     187: dconst_0
     188: iconst_0
     189: iconst_0
     190: iconst_0
     191: bipush        31
     193: aconst_null
     194: invokestatic  #242                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.copy$default:(Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;DDIIIILjava/lang/Object;)Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;
     197: invokeinterface #246,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     202: pop
     203: goto          212
     206: iinc          8, 1
     209: goto          149
     212: iinc          5, 1
     215: goto          74
     218: iconst_0
     219: istore        5
     221: iload         5
     223: iload_1
     224: if_icmpge     272
     227: aload_0
     228: iload         5
     230: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     235: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     238: aload_0
     239: iload         5
     241: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     246: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     249: aload_2
     250: iload_3
     251: invokestatic  #248                // Method nearest:(Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;Ljava/util/List;I)Lkotlin/Pair;
     254: invokevirtual #261                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     257: checkcast     #255                // class java/lang/Number
     260: invokevirtual #264                // Method java/lang/Number.intValue:()I
     263: invokevirtual #267                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setGroup:(I)V
     266: iinc          5, 1
     269: goto          221
     272: return

  public static final java.util.List<com.cristianovecchi.mikrokanon.dataAnalysis.Point> lloyd(java.util.List<com.cristianovecchi.mikrokanon.dataAnalysis.Point>, int, int);
    Code:
       0: aload_0
       1: ldc           #232                // String pts
       3: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #144                // class java/util/ArrayList
       9: dup
      10: iload_2
      11: invokespecial #147                // Method java/util/ArrayList."<init>":(I)V
      14: astore        4
      16: iconst_0
      17: istore        5
      19: iload         5
      21: iload_2
      22: if_icmpge     56
      25: iload         5
      27: istore        6
      29: aload         4
      31: iload         6
      33: istore        7
      35: astore        10
      37: iconst_0
      38: istore        8
      40: invokestatic  #149                // Method getOrigin:()Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;
      43: aload         10
      45: swap
      46: invokevirtual #153                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      49: pop
      50: iinc          5, 1
      53: goto          19
      56: aload         4
      58: checkcast     #72                 // class java/util/List
      61: astore_3
      62: aload_0
      63: iload_1
      64: aload_3
      65: invokestatic  #276                // Method kpp:(Ljava/util/List;ILjava/util/List;)V
      68: iconst_0
      69: istore        4
      71: iload         4
      73: iload_2
      74: if_icmpge     118
      77: aload_3
      78: iload         4
      80: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      85: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
      88: astore        6
      90: iconst_0
      91: istore        7
      93: aload         6
      95: dconst_0
      96: invokevirtual #166                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setX:(D)V
      99: aload         6
     101: dconst_0
     102: invokevirtual #172                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setY:(D)V
     105: aload         6
     107: iconst_0
     108: invokevirtual #267                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setGroup:(I)V
     111: nop
     112: iinc          4, 1
     115: goto          71
     118: iconst_0
     119: istore        4
     121: iload         4
     123: iload_1
     124: if_icmpge     218
     127: aload_0
     128: iload         4
     130: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     135: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     138: astore        5
     140: aload_3
     141: aload         5
     143: invokevirtual #70                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
     146: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     151: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     154: astore        6
     156: aload         6
     158: astore        7
     160: iconst_0
     161: istore        8
     163: aload         7
     165: invokevirtual #70                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
     168: istore        9
     170: aload         7
     172: iload         9
     174: iconst_1
     175: iadd
     176: invokevirtual #267                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setGroup:(I)V
     179: aload         7
     181: aload         7
     183: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     186: aload         5
     188: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     191: dadd
     192: invokevirtual #166                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setX:(D)V
     195: aload         7
     197: aload         7
     199: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     202: aload         5
     204: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     207: dadd
     208: invokevirtual #172                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setY:(D)V
     211: nop
     212: iinc          4, 1
     215: goto          121
     218: iconst_0
     219: istore        4
     221: iload         4
     223: iload_2
     224: if_icmpge     280
     227: aload_3
     228: iload         4
     230: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     235: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     238: astore        5
     240: aload         5
     242: aload         5
     244: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     247: aload         5
     249: invokevirtual #70                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
     252: i2d
     253: ddiv
     254: invokevirtual #166                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setX:(D)V
     257: aload         5
     259: aload         5
     261: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     264: aload         5
     266: invokevirtual #70                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
     269: i2d
     270: ddiv
     271: invokevirtual #172                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setY:(D)V
     274: iinc          4, 1
     277: goto          221
     280: iconst_0
     281: istore        4
     283: iconst_0
     284: istore        5
     286: iload         5
     288: iload_1
     289: if_icmpge     349
     292: aload_0
     293: iload         5
     295: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     300: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     303: astore        6
     305: aload         6
     307: aload_3
     308: iload_2
     309: invokestatic  #248                // Method nearest:(Lcom/cristianovecchi/mikrokanon/dataAnalysis/Point;Ljava/util/List;I)Lkotlin/Pair;
     312: invokevirtual #261                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     315: checkcast     #255                // class java/lang/Number
     318: invokevirtual #264                // Method java/lang/Number.intValue:()I
     321: istore        7
     323: iload         7
     325: aload         6
     327: invokevirtual #70                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
     330: if_icmpeq     343
     333: iinc          4, 1
     336: aload         6
     338: iload         7
     340: invokevirtual #267                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setGroup:(I)V
     343: iinc          5, 1
     346: goto          286
     349: iload         4
     351: iload_1
     352: bipush        10
     354: ishr
     355: if_icmpgt     68
     358: iconst_0
     359: istore        4
     361: iload         4
     363: iload_2
     364: if_icmpge     389
     367: aload_3
     368: iload         4
     370: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     375: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     378: iload         4
     380: invokevirtual #267                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.setGroup:(I)V
     383: iinc          4, 1
     386: goto          361
     389: aload_3
     390: areturn

  public static final void printEps(java.util.List<com.cristianovecchi.mikrokanon.dataAnalysis.Point>, int, java.util.List<com.cristianovecchi.mikrokanon.dataAnalysis.Point>, int);
    Code:
       0: aload_0
       1: ldc           #232                // String pts
       3: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #205                // String cent
       9: invokestatic  #188                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iload_3
      13: iconst_3
      14: imul
      15: newarray       double
      17: astore        4
      19: iconst_0
      20: istore        5
      22: iload         5
      24: iload_3
      25: if_icmpge     101
      28: aload         4
      30: iconst_3
      31: iload         5
      33: imul
      34: iconst_0
      35: iadd
      36: iconst_3
      37: iload         5
      39: iconst_1
      40: iadd
      41: imul
      42: bipush        11
      44: irem
      45: i2d
      46: ldc2_w        #288                // double 11.0d
      49: ddiv
      50: dastore
      51: aload         4
      53: iconst_3
      54: iload         5
      56: imul
      57: iconst_1
      58: iadd
      59: bipush        7
      61: iload         5
      63: imul
      64: bipush        11
      66: irem
      67: i2d
      68: ldc2_w        #288                // double 11.0d
      71: ddiv
      72: dastore
      73: aload         4
      75: iconst_3
      76: iload         5
      78: imul
      79: iconst_2
      80: iadd
      81: bipush        9
      83: iload         5
      85: imul
      86: bipush        11
      88: irem
      89: i2d
      90: ldc2_w        #288                // double 11.0d
      93: ddiv
      94: dastore
      95: iinc          5, 1
      98: goto          22
     101: getstatic     #25                 // Field hugeVal:D
     104: dstore        5
     106: getstatic     #25                 // Field hugeVal:D
     109: dstore        7
     111: getstatic     #25                 // Field hugeVal:D
     114: dneg
     115: dstore        9
     117: getstatic     #25                 // Field hugeVal:D
     120: dneg
     121: dstore        11
     123: iconst_0
     124: istore        13
     126: iload         13
     128: iload_1
     129: if_icmpge     223
     132: aload_0
     133: iload         13
     135: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     140: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     143: astore        14
     145: dload         9
     147: aload         14
     149: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     152: dcmpg
     153: ifge          163
     156: aload         14
     158: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     161: dstore        9
     163: dload         5
     165: aload         14
     167: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     170: dcmpl
     171: ifle          181
     174: aload         14
     176: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     179: dstore        5
     181: dload         11
     183: aload         14
     185: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     188: dcmpg
     189: ifge          199
     192: aload         14
     194: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     197: dstore        11
     199: dload         7
     201: aload         14
     203: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     206: dcmpl
     207: ifle          217
     210: aload         14
     212: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     215: dstore        7
     217: iinc          13, 1
     220: goto          126
     223: sipush        400
     226: i2d
     227: dload         9
     229: dload         5
     231: dsub
     232: ddiv
     233: sipush        400
     236: i2d
     237: dload         11
     239: dload         7
     241: dsub
     242: ddiv
     243: invokestatic  #293                // Method java/lang/Math.min:(DD)D
     246: dstore        13
     248: dload         9
     250: dload         5
     252: dadd
     253: ldc2_w        #294                // double 2.0d
     256: ddiv
     257: dstore        15
     259: dload         11
     261: dload         7
     263: dadd
     264: ldc2_w        #294                // double 2.0d
     267: ddiv
     268: dstore        17
     270: ldc_w         #297                // String %%!PS-Adobe-3.0\n%%%%BoundingBox: -5 -5 %410 410\n
     273: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     276: swap
     277: invokevirtual #300                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     280: ldc_w         #302                // String /l {rlineto} def /m {rmoveto} def\n
     283: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     286: swap
     287: invokevirtual #300                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     290: ldc_w         #304                // String /c { .25 sub exch .25 sub exch .5 0 360 arc fill } def\n
     293: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     296: swap
     297: invokevirtual #300                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     300: ldc_w         #306                // String /s { moveto -2 0 m 2 2 l 2 -2 l -2 -2 l closepath
     303: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     306: swap
     307: invokevirtual #300                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     310: ldc_w         #308                // String \tgsave 1 setgray fill grestore gsave 3 setlinewidth
     313: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     316: swap
     317: invokevirtual #300                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     320: ldc_w         #310                // String  1 setgray stroke grestore 0 setgray stroke }def\n
     323: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     326: swap
     327: invokevirtual #300                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     330: ldc_w         #312                // String %g %g %g setrgbcolor
     333: astore        19
     335: ldc_w         #314                // String %.3f %.3f c
     338: astore        20
     340: ldc_w         #316                // String \n0 setgray %g %g s
     343: astore        21
     345: iconst_0
     346: istore        22
     348: iload         22
     350: iload_3
     351: if_icmpge     681
     354: aload_2
     355: iload         22
     357: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     362: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     365: astore        23
     367: aload         19
     369: astore        24
     371: iconst_3
     372: anewarray     #4                  // class java/lang/Object
     375: astore        25
     377: aload         25
     379: iconst_0
     380: aload         4
     382: iconst_3
     383: iload         22
     385: imul
     386: daload
     387: invokestatic  #218                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     390: aastore
     391: aload         25
     393: iconst_1
     394: aload         4
     396: iconst_3
     397: iload         22
     399: imul
     400: iconst_1
     401: iadd
     402: daload
     403: invokestatic  #218                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     406: aastore
     407: aload         25
     409: iconst_2
     410: aload         4
     412: iconst_3
     413: iload         22
     415: imul
     416: iconst_2
     417: iadd
     418: daload
     419: invokestatic  #218                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     422: aastore
     423: aload         25
     425: astore        25
     427: aload         24
     429: aload         25
     431: aload         25
     433: arraylength
     434: invokestatic  #322                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     437: invokestatic  #328                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     440: dup
     441: ldc_w         #330                // String format(...)
     444: invokestatic  #333                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     447: astore        24
     449: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     452: aload         24
     454: invokevirtual #92                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     457: iconst_0
     458: istore        24
     460: iload         24
     462: iload_1
     463: if_icmpge     585
     466: aload_0
     467: iload         24
     469: invokeinterface #76,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     474: checkcast     #9                  // class com/cristianovecchi/mikrokanon/dataAnalysis/Point
     477: astore        25
     479: aload         25
     481: invokevirtual #70                 // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getGroup:()I
     484: iload         22
     486: if_icmpne     579
     489: aload         20
     491: astore        26
     493: iconst_2
     494: anewarray     #4                  // class java/lang/Object
     497: astore        27
     499: aload         27
     501: iconst_0
     502: aload         25
     504: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     507: dload         15
     509: dsub
     510: dload         13
     512: dmul
     513: sipush        200
     516: i2d
     517: dadd
     518: invokestatic  #218                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     521: aastore
     522: aload         27
     524: iconst_1
     525: aload         25
     527: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     530: dload         17
     532: dsub
     533: dload         13
     535: dmul
     536: sipush        200
     539: i2d
     540: dadd
     541: invokestatic  #218                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     544: aastore
     545: aload         27
     547: astore        27
     549: aload         26
     551: aload         27
     553: aload         27
     555: arraylength
     556: invokestatic  #322                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     559: invokestatic  #328                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     562: dup
     563: ldc_w         #330                // String format(...)
     566: invokestatic  #333                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     569: astore        26
     571: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     574: aload         26
     576: invokevirtual #92                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     579: iinc          24, 1
     582: goto          460
     585: aload         21
     587: astore        24
     589: iconst_2
     590: anewarray     #4                  // class java/lang/Object
     593: astore        25
     595: aload         25
     597: iconst_0
     598: aload         23
     600: invokevirtual #193                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getX:()D
     603: dload         15
     605: dsub
     606: dload         13
     608: dmul
     609: sipush        200
     612: i2d
     613: dadd
     614: invokestatic  #218                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     617: aastore
     618: aload         25
     620: iconst_1
     621: aload         23
     623: invokevirtual #196                // Method com/cristianovecchi/mikrokanon/dataAnalysis/Point.getY:()D
     626: dload         17
     628: dsub
     629: dload         13
     631: dmul
     632: sipush        200
     635: i2d
     636: dadd
     637: invokestatic  #218                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     640: aastore
     641: aload         25
     643: astore        25
     645: aload         24
     647: aload         25
     649: aload         25
     651: arraylength
     652: invokestatic  #322                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     655: invokestatic  #328                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     658: dup
     659: ldc_w         #330                // String format(...)
     662: invokestatic  #333                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     665: astore        24
     667: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     670: aload         24
     672: invokevirtual #92                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     675: iinc          22, 1
     678: goto          348
     681: ldc_w         #335                // String \n%%%%EOF
     684: getstatic     #86                 // Field java/lang/System.out:Ljava/io/PrintStream;
     687: swap
     688: invokevirtual #300                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     691: return

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

  static {};
    Code:
       0: new           #131                // class java/util/Random
       3: dup
       4: invokespecial #354                // Method java/util/Random."<init>":()V
       7: putstatic     #19                 // Field r:Ljava/util/Random;
      10: ldc2_w        #355                // double Infinityd
      13: putstatic     #25                 // Field hugeVal:D
      16: return
}