import java.io.InputStreamReader
import java.net.URL
import java.util.*
import kotlin.math.absoluteValue
import java.io.File

data class Kettle(val id: Int, val room: String, var boilTime: Long, var ml: Int)

var room = "1"
var ml = 200

private const val MILLIES_IN_DAY = 86_400_000
private val start = "http://192.168.43.217:1000/" //File("ip.txt").readLines()[0]

private fun query(query: String): List<String> {
    val url = URL(start + query)
    return InputStreamReader(url.openConnection().getInputStream()).readLines()
}

private fun ask() = query("ask.php").map { it.toKettle() }
fun update(id: Int, boilTime: Long, ml: Int): List<String> {
    val query = "boil.php?id=$id&boil_time=$boilTime&ml=$ml"
    return query(query)
}
fun add(room: String) = query("add.php?room=$room").first().toInt()
fun delete(id: Int) = query("remove.php?id=$id")
fun byId(id: Int) = query("by_id.php?id=$id").first().toKettle()

var graph: TreeMap<String, TreeMap<String, Int>>? = null
private fun getMap() {
    if (graph == null) {
        graph = TreeMap<String, TreeMap<String, Int>>()
        val query = query("map.php")
        query.forEach {
            val (u, v, dist) = it.split(' ')
            graph!![u] = graph!!.getOrDefault(u, TreeMap<String, Int>())
            graph!![v] = graph!!.getOrDefault(v, TreeMap<String, Int>())
            graph!![u]!![v] = dist.toInt()
            graph!![v]!![u] = dist.toInt()
        }
    }
}

fun String.toKettle(): Kettle {
    val (id, room, boilTime, ml) = split(' ')
    return Kettle(id.toInt(), room, boilTime.toLong(), ml.toInt())
}

fun updateAllKettles() = ask()

fun nearKettles(currentRoom: String, ml: Int, currentTime: Long): List<Pair<Kettle, Int>> {
    getMap()
    val distance = TreeMap<String, Int>() //distance from currentRoom, calculated using Dijkstra algorithm
    distance[currentRoom] = 0
    val dijkstra = TreeSet<String> { s1, s2 ->
        distance.getOrDefault(s1, Int.MAX_VALUE) - distance.getOrDefault(s2, Int.MAX_VALUE)
    }
    dijkstra.add(currentRoom)
    while (dijkstra.isNotEmpty()) {
        val cur = dijkstra.first() //nearest that's not processed yet
        dijkstra.remove(cur)
        for ((next, dist) in (graph!![cur] ?: TreeMap<String, Int>())) {
            if (distance.getOrDefault(next, Int.MAX_VALUE) > distance[cur]!! + dist) {
                dijkstra.remove(next)
                distance[next] = distance[cur]!! + dist
                dijkstra.add(next)
            }
        }
    }
    val candidates = ask().filter { it.ml >= ml }
        .sortedWith(compareByDescending<Kettle> { it.boilTime.coerceAtMost(currentTime) }.thenBy { distance[it.room]!! })
    var currentBestDistance = Int.MAX_VALUE
    val optimums = mutableListOf<Pair<Kettle, Int>>()
    for (kettle in candidates) {
        if (currentBestDistance > distance.getOrDefault(kettle.room, Int.MAX_VALUE)) {
            optimums.add(kettle to distance[kettle.room]!!)
            currentBestDistance = distance[kettle.room]!!
        }
    }
    return optimums.filter { (kettle, _) -> (kettle.boilTime - System.currentTimeMillis()).absoluteValue < MILLIES_IN_DAY }
}

fun boilKettle(id: Int, volume: Int) {
    val boilingTime = (180L * 1000L * volume) / 1000L
    update(id, System.currentTimeMillis() + boilingTime, volume)
}
fun drink(id: Int, volumeRemaining: Int) = update(id, byId(id).boilTime, volumeRemaining)

Compiled from "Comparisons.kt"
public final class LogisticsKt$nearKettles$$inlined$thenBy$1<T> implements java.util.Comparator {
  final java.util.Comparator $this_thenBy;

  final java.util.TreeMap $distance$inlined;

  public LogisticsKt$nearKettles$$inlined$thenBy$1(java.util.Comparator, java.util.TreeMap);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #20                 // Field $this_thenBy:Ljava/util/Comparator;
       5: aload_0
       6: aload_2
       7: putfield      #22                 // Field $distance$inlined:Ljava/util/TreeMap;
      10: aload_0
      11: invokespecial #25                 // Method java/lang/Object."<init>":()V
      14: return

  public final int compare(T, T);
    Code:
       0: aload_0
       1: getfield      #20                 // Field $this_thenBy:Ljava/util/Comparator;
       4: aload_1
       5: aload_2
       6: invokeinterface #33,  3           // InterfaceMethod java/util/Comparator.compare:(Ljava/lang/Object;Ljava/lang/Object;)I
      11: istore_3
      12: iload_3
      13: ifeq          20
      16: iload_3
      17: goto          84
      20: aload_1
      21: checkcast     #35                 // class Kettle
      24: astore        4
      26: iconst_0
      27: istore        5
      29: aload_0
      30: getfield      #22                 // Field $distance$inlined:Ljava/util/TreeMap;
      33: aload         4
      35: invokevirtual #39                 // Method Kettle.getRoom:()Ljava/lang/String;
      38: invokevirtual #45                 // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
      41: dup
      42: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      45: checkcast     #53                 // class java/lang/Comparable
      48: aload_2
      49: checkcast     #35                 // class Kettle
      52: astore        4
      54: astore        6
      56: iconst_0
      57: istore        5
      59: aload_0
      60: getfield      #22                 // Field $distance$inlined:Ljava/util/TreeMap;
      63: aload         4
      65: invokevirtual #39                 // Method Kettle.getRoom:()Ljava/lang/String;
      68: invokevirtual #45                 // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
      71: dup
      72: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      75: checkcast     #53                 // class java/lang/Comparable
      78: aload         6
      80: swap
      81: invokestatic  #59                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      84: ireturn
}

Compiled from "logistics.kt"
public final class LogisticsKt {
  private static java.lang.String room;

  private static int ml;

  private static final int MILLIES_IN_DAY;

  private static final java.lang.String start;

  private static java.util.TreeMap<java.lang.String, java.util.TreeMap<java.lang.String, java.lang.Integer>> graph;

  public static final java.lang.String getRoom();
    Code:
       0: getstatic     #11                 // Field room:Ljava/lang/String;
       3: areturn

  public static final void setRoom(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #15                 // String <set-?>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: putstatic     #11                 // Field room:Ljava/lang/String;
      10: return

  public static final int getMl();
    Code:
       0: getstatic     #27                 // Field ml:I
       3: ireturn

  public static final void setMl(int);
    Code:
       0: iload_0
       1: putstatic     #27                 // Field ml:I
       4: return

  private static final java.util.List<java.lang.String> query(java.lang.String);
    Code:
       0: new           #34                 // class java/net/URL
       3: dup
       4: new           #36                 // class java/lang/StringBuilder
       7: dup
       8: invokespecial #40                 // Method java/lang/StringBuilder."<init>":()V
      11: getstatic     #43                 // Field start:Ljava/lang/String;
      14: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      17: aload_0
      18: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      21: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      24: invokespecial #52                 // Method java/net/URL."<init>":(Ljava/lang/String;)V
      27: astore_1
      28: new           #54                 // class java/io/InputStreamReader
      31: dup
      32: aload_1
      33: invokevirtual #58                 // Method java/net/URL.openConnection:()Ljava/net/URLConnection;
      36: invokevirtual #64                 // Method java/net/URLConnection.getInputStream:()Ljava/io/InputStream;
      39: invokespecial #67                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;)V
      42: checkcast     #69                 // class java/io/Reader
      45: invokestatic  #75                 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;
      48: areturn

  private static final java.util.List<Kettle> ask();
    Code:
       0: ldc           #82                 // String ask.php
       2: invokestatic  #84                 // Method query:(Ljava/lang/String;)Ljava/util/List;
       5: checkcast     #86                 // class java/lang/Iterable
       8: astore_0
       9: iconst_0
      10: istore_1
      11: aload_0
      12: astore_2
      13: new           #88                 // class java/util/ArrayList
      16: dup
      17: aload_0
      18: bipush        10
      20: invokestatic  #94                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      23: invokespecial #96                 // Method java/util/ArrayList."<init>":(I)V
      26: checkcast     #98                 // class java/util/Collection
      29: astore_3
      30: iconst_0
      31: istore        4
      33: aload_2
      34: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        5
      41: aload         5
      43: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          90
      51: aload         5
      53: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        6
      60: aload_3
      61: aload         6
      63: checkcast     #114                // class java/lang/String
      66: astore        7
      68: astore        9
      70: iconst_0
      71: istore        8
      73: aload         7
      75: invokestatic  #118                // Method toKettle:(Ljava/lang/String;)LKettle;
      78: aload         9
      80: swap
      81: invokeinterface #122,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      86: pop
      87: goto          41
      90: aload_3
      91: checkcast     #124                // class java/util/List
      94: nop
      95: areturn

  public static final java.util.List<java.lang.String> update(int, long, int);
    Code:
       0: new           #36                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #40                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #140                // String boil.php?id=
       9: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: iload_0
      13: invokevirtual #143                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      16: ldc           #145                // String &boil_time=
      18: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      21: lload_1
      22: invokevirtual #148                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      25: ldc           #150                // String &ml=
      27: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      30: iload_3
      31: invokevirtual #143                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      34: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      37: astore        4
      39: aload         4
      41: invokestatic  #84                 // Method query:(Ljava/lang/String;)Ljava/util/List;
      44: areturn

  public static final int add(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #155                // String room
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #36                 // class java/lang/StringBuilder
       9: dup
      10: invokespecial #40                 // Method java/lang/StringBuilder."<init>":()V
      13: ldc           #157                // String add.php?room=
      15: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      18: aload_0
      19: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      22: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      25: invokestatic  #84                 // Method query:(Ljava/lang/String;)Ljava/util/List;
      28: invokestatic  #161                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      31: checkcast     #114                // class java/lang/String
      34: invokestatic  #166                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      37: ireturn

  public static final java.util.List<java.lang.String> delete(int);
    Code:
       0: new           #36                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #40                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #171                // String remove.php?id=
       9: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: iload_0
      13: invokevirtual #143                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      16: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      19: invokestatic  #84                 // Method query:(Ljava/lang/String;)Ljava/util/List;
      22: areturn

  public static final Kettle byId(int);
    Code:
       0: new           #36                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #40                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #175                // String by_id.php?id=
       9: invokevirtual #47                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: iload_0
      13: invokevirtual #143                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      16: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      19: invokestatic  #84                 // Method query:(Ljava/lang/String;)Ljava/util/List;
      22: invokestatic  #161                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      25: checkcast     #114                // class java/lang/String
      28: invokestatic  #118                // Method toKettle:(Ljava/lang/String;)LKettle;
      31: areturn

  public static final java.util.TreeMap<java.lang.String, java.util.TreeMap<java.lang.String, java.lang.Integer>> getGraph();
    Code:
       0: getstatic     #183                // Field graph:Ljava/util/TreeMap;
       3: areturn

  public static final void setGraph(java.util.TreeMap<java.lang.String, java.util.TreeMap<java.lang.String, java.lang.Integer>>);
    Code:
       0: aload_0
       1: putstatic     #183                // Field graph:Ljava/util/TreeMap;
       4: return

  private static final void getMap();
    Code:
       0: getstatic     #183                // Field graph:Ljava/util/TreeMap;
       3: ifnonnull     282
       6: new           #189                // class java/util/TreeMap
       9: dup
      10: invokespecial #190                // Method java/util/TreeMap."<init>":()V
      13: putstatic     #183                // Field graph:Ljava/util/TreeMap;
      16: ldc           #192                // String map.php
      18: invokestatic  #84                 // Method query:(Ljava/lang/String;)Ljava/util/List;
      21: astore_0
      22: aload_0
      23: checkcast     #86                 // class java/lang/Iterable
      26: astore_1
      27: iconst_0
      28: istore_2
      29: aload_1
      30: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      35: astore_3
      36: aload_3
      37: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      42: ifeq          281
      45: aload_3
      46: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      51: astore        4
      53: aload         4
      55: checkcast     #114                // class java/lang/String
      58: astore        5
      60: iconst_0
      61: istore        6
      63: aload         5
      65: checkcast     #194                // class java/lang/CharSequence
      68: iconst_1
      69: newarray       char
      71: astore        7
      73: aload         7
      75: iconst_0
      76: bipush        32
      78: castore
      79: aload         7
      81: iconst_0
      82: iconst_0
      83: bipush        6
      85: aconst_null
      86: invokestatic  #200                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
      89: astore        8
      91: aload         8
      93: iconst_0
      94: invokeinterface #204,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      99: checkcast     #114                // class java/lang/String
     102: astore        7
     104: aload         8
     106: iconst_1
     107: invokeinterface #204,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     112: checkcast     #114                // class java/lang/String
     115: astore        9
     117: aload         8
     119: iconst_2
     120: invokeinterface #204,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     125: checkcast     #114                // class java/lang/String
     128: astore        10
     130: getstatic     #183                // Field graph:Ljava/util/TreeMap;
     133: dup
     134: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     137: checkcast     #210                // class java/util/Map
     140: aload         7
     142: getstatic     #183                // Field graph:Ljava/util/TreeMap;
     145: dup
     146: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     149: aload         7
     151: new           #189                // class java/util/TreeMap
     154: dup
     155: invokespecial #190                // Method java/util/TreeMap."<init>":()V
     158: invokevirtual #214                // Method java/util/TreeMap.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     161: invokeinterface #217,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     166: pop
     167: getstatic     #183                // Field graph:Ljava/util/TreeMap;
     170: dup
     171: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     174: checkcast     #210                // class java/util/Map
     177: aload         9
     179: getstatic     #183                // Field graph:Ljava/util/TreeMap;
     182: dup
     183: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     186: aload         9
     188: new           #189                // class java/util/TreeMap
     191: dup
     192: invokespecial #190                // Method java/util/TreeMap."<init>":()V
     195: invokevirtual #214                // Method java/util/TreeMap.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     198: invokeinterface #217,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     203: pop
     204: nop
     205: getstatic     #183                // Field graph:Ljava/util/TreeMap;
     208: dup
     209: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     212: aload         7
     214: invokevirtual #220                // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     217: dup
     218: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     221: checkcast     #210                // class java/util/Map
     224: aload         9
     226: aload         10
     228: invokestatic  #166                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     231: invokestatic  #224                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     234: invokeinterface #217,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     239: pop
     240: nop
     241: getstatic     #183                // Field graph:Ljava/util/TreeMap;
     244: dup
     245: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     248: aload         9
     250: invokevirtual #220                // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     253: dup
     254: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     257: checkcast     #210                // class java/util/Map
     260: aload         7
     262: aload         10
     264: invokestatic  #166                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     267: invokestatic  #224                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     270: invokeinterface #217,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     275: pop
     276: nop
     277: nop
     278: goto          36
     281: nop
     282: return

  public static final Kettle toKettle(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #234                // String <this>
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #194                // class java/lang/CharSequence
      10: iconst_1
      11: newarray       char
      13: astore_2
      14: aload_2
      15: iconst_0
      16: bipush        32
      18: castore
      19: aload_2
      20: iconst_0
      21: iconst_0
      22: bipush        6
      24: aconst_null
      25: invokestatic  #200                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
      28: astore_1
      29: aload_1
      30: iconst_0
      31: invokeinterface #204,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      36: checkcast     #114                // class java/lang/String
      39: astore_2
      40: aload_1
      41: iconst_1
      42: invokeinterface #204,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      47: checkcast     #114                // class java/lang/String
      50: astore_3
      51: aload_1
      52: iconst_2
      53: invokeinterface #204,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      58: checkcast     #114                // class java/lang/String
      61: astore        4
      63: aload_1
      64: iconst_3
      65: invokeinterface #204,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      70: checkcast     #114                // class java/lang/String
      73: astore        5
      75: new           #236                // class Kettle
      78: dup
      79: aload_2
      80: invokestatic  #166                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      83: aload_3
      84: aload         4
      86: invokestatic  #242                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      89: aload         5
      91: invokestatic  #166                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      94: invokespecial #245                // Method Kettle."<init>":(ILjava/lang/String;JI)V
      97: areturn

  public static final java.util.List<Kettle> updateAllKettles();
    Code:
       0: invokestatic  #249                // Method ask:()Ljava/util/List;
       3: areturn

  public static final java.util.List<kotlin.Pair<Kettle, java.lang.Integer>> nearKettles(java.lang.String, int, long);
    Code:
       0: aload_0
       1: ldc           #254                // String currentRoom
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #256                // Method getMap:()V
       9: new           #189                // class java/util/TreeMap
      12: dup
      13: invokespecial #190                // Method java/util/TreeMap."<init>":()V
      16: astore        4
      18: aload         4
      20: checkcast     #210                // class java/util/Map
      23: aload_0
      24: iconst_0
      25: invokestatic  #224                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      28: invokeinterface #217,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      33: pop
      34: new           #258                // class java/util/TreeSet
      37: dup
      38: aload         4
      40: invokedynamic #277,  0            // InvokeDynamic #0:invoke:(Ljava/util/TreeMap;)Lkotlin/jvm/functions/Function2;
      45: invokedynamic #288,  0            // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
      50: invokespecial #291                // Method java/util/TreeSet."<init>":(Ljava/util/Comparator;)V
      53: astore        5
      55: aload         5
      57: aload_0
      58: invokevirtual #292                // Method java/util/TreeSet.add:(Ljava/lang/Object;)Z
      61: pop
      62: aload         5
      64: checkcast     #98                 // class java/util/Collection
      67: invokeinterface #295,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      72: ifne          79
      75: iconst_1
      76: goto          80
      79: iconst_0
      80: ifeq          289
      83: aload         5
      85: invokevirtual #297                // Method java/util/TreeSet.first:()Ljava/lang/Object;
      88: checkcast     #114                // class java/lang/String
      91: astore        6
      93: aload         5
      95: aload         6
      97: invokevirtual #300                // Method java/util/TreeSet.remove:(Ljava/lang/Object;)Z
     100: pop
     101: getstatic     #183                // Field graph:Ljava/util/TreeMap;
     104: dup
     105: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     108: aload         6
     110: invokevirtual #220                // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     113: checkcast     #189                // class java/util/TreeMap
     116: dup
     117: ifnonnull     128
     120: pop
     121: new           #189                // class java/util/TreeMap
     124: dup
     125: invokespecial #190                // Method java/util/TreeMap."<init>":()V
     128: checkcast     #210                // class java/util/Map
     131: invokeinterface #304,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     136: invokeinterface #307,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     141: astore        7
     143: aload         7
     145: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     150: ifeq          62
     153: aload         7
     155: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     160: checkcast     #309                // class java/util/Map$Entry
     163: astore        8
     165: aload         8
     167: invokeinterface #312,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     172: checkcast     #114                // class java/lang/String
     175: astore        9
     177: aload         8
     179: invokeinterface #315,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     184: checkcast     #317                // class java/lang/Number
     187: invokevirtual #320                // Method java/lang/Number.intValue:()I
     190: istore        10
     192: aload         4
     194: aload         9
     196: ldc_w         #321                // int 2147483647
     199: invokestatic  #224                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     202: invokevirtual #214                // Method java/util/TreeMap.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     205: checkcast     #317                // class java/lang/Number
     208: invokevirtual #320                // Method java/lang/Number.intValue:()I
     211: aload         4
     213: aload         6
     215: invokevirtual #220                // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     218: dup
     219: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     222: checkcast     #317                // class java/lang/Number
     225: invokevirtual #320                // Method java/lang/Number.intValue:()I
     228: iload         10
     230: iadd
     231: if_icmple     143
     234: aload         5
     236: aload         9
     238: invokevirtual #300                // Method java/util/TreeSet.remove:(Ljava/lang/Object;)Z
     241: pop
     242: aload         4
     244: checkcast     #210                // class java/util/Map
     247: aload         9
     249: aload         4
     251: aload         6
     253: invokevirtual #220                // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     256: dup
     257: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     260: checkcast     #317                // class java/lang/Number
     263: invokevirtual #320                // Method java/lang/Number.intValue:()I
     266: iload         10
     268: iadd
     269: invokestatic  #224                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     272: invokeinterface #217,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     277: pop
     278: aload         5
     280: aload         9
     282: invokevirtual #292                // Method java/util/TreeSet.add:(Ljava/lang/Object;)Z
     285: pop
     286: goto          143
     289: invokestatic  #249                // Method ask:()Ljava/util/List;
     292: checkcast     #86                 // class java/lang/Iterable
     295: astore        7
     297: iconst_0
     298: istore        8
     300: aload         7
     302: astore        9
     304: new           #88                 // class java/util/ArrayList
     307: dup
     308: invokespecial #322                // Method java/util/ArrayList."<init>":()V
     311: checkcast     #98                 // class java/util/Collection
     314: astore        10
     316: iconst_0
     317: istore        11
     319: aload         9
     321: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     326: astore        12
     328: aload         12
     330: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     335: ifeq          387
     338: aload         12
     340: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     345: astore        13
     347: aload         13
     349: checkcast     #236                // class Kettle
     352: astore        14
     354: iconst_0
     355: istore        15
     357: aload         14
     359: invokevirtual #324                // Method Kettle.getMl:()I
     362: iload_1
     363: if_icmplt     370
     366: iconst_1
     367: goto          371
     370: iconst_0
     371: ifeq          328
     374: aload         10
     376: aload         13
     378: invokeinterface #122,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     383: pop
     384: goto          328
     387: aload         10
     389: checkcast     #124                // class java/util/List
     392: nop
     393: checkcast     #86                 // class java/lang/Iterable
     396: new           #326                // class LogisticsKt$nearKettles$$inlined$compareByDescending$1
     399: dup
     400: lload_2
     401: invokespecial #329                // Method LogisticsKt$nearKettles$$inlined$compareByDescending$1."<init>":(J)V
     404: checkcast     #331                // class java/util/Comparator
     407: astore        7
     409: new           #333                // class LogisticsKt$nearKettles$$inlined$thenBy$1
     412: dup
     413: aload         7
     415: aload         4
     417: invokespecial #336                // Method LogisticsKt$nearKettles$$inlined$thenBy$1."<init>":(Ljava/util/Comparator;Ljava/util/TreeMap;)V
     420: checkcast     #331                // class java/util/Comparator
     423: invokestatic  #340                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
     426: astore        6
     428: ldc_w         #321                // int 2147483647
     431: istore        7
     433: new           #88                 // class java/util/ArrayList
     436: dup
     437: invokespecial #322                // Method java/util/ArrayList."<init>":()V
     440: checkcast     #124                // class java/util/List
     443: astore        8
     445: aload         6
     447: invokeinterface #341,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     452: astore        9
     454: aload         9
     456: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     461: ifeq          555
     464: aload         9
     466: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     471: checkcast     #236                // class Kettle
     474: astore        10
     476: iload         7
     478: aload         4
     480: aload         10
     482: invokevirtual #343                // Method Kettle.getRoom:()Ljava/lang/String;
     485: ldc_w         #321                // int 2147483647
     488: invokestatic  #224                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     491: invokevirtual #214                // Method java/util/TreeMap.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     494: checkcast     #317                // class java/lang/Number
     497: invokevirtual #320                // Method java/lang/Number.intValue:()I
     500: if_icmple     454
     503: aload         8
     505: aload         10
     507: aload         4
     509: aload         10
     511: invokevirtual #343                // Method Kettle.getRoom:()Ljava/lang/String;
     514: invokevirtual #220                // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     517: dup
     518: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     521: invokestatic  #349                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     524: invokeinterface #350,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     529: pop
     530: aload         4
     532: aload         10
     534: invokevirtual #343                // Method Kettle.getRoom:()Ljava/lang/String;
     537: invokevirtual #220                // Method java/util/TreeMap.get:(Ljava/lang/Object;)Ljava/lang/Object;
     540: dup
     541: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     544: checkcast     #317                // class java/lang/Number
     547: invokevirtual #320                // Method java/lang/Number.intValue:()I
     550: istore        7
     552: goto          454
     555: aload         8
     557: checkcast     #86                 // class java/lang/Iterable
     560: astore        9
     562: iconst_0
     563: istore        10
     565: aload         9
     567: astore        11
     569: new           #88                 // class java/util/ArrayList
     572: dup
     573: invokespecial #322                // Method java/util/ArrayList."<init>":()V
     576: checkcast     #98                 // class java/util/Collection
     579: astore        12
     581: iconst_0
     582: istore        13
     584: aload         11
     586: invokeinterface #102,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     591: astore        14
     593: aload         14
     595: invokeinterface #108,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     600: ifeq          672
     603: aload         14
     605: invokeinterface #112,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     610: astore        15
     612: aload         15
     614: checkcast     #352                // class kotlin/Pair
     617: astore        16
     619: iconst_0
     620: istore        17
     622: aload         16
     624: invokevirtual #355                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     627: checkcast     #236                // class Kettle
     630: astore        18
     632: aload         18
     634: invokevirtual #359                // Method Kettle.getBoilTime:()J
     637: invokestatic  #364                // Method java/lang/System.currentTimeMillis:()J
     640: lsub
     641: invokestatic  #370                // Method java/lang/Math.abs:(J)J
     644: ldc2_w        #371                // long 86400000l
     647: lcmp
     648: ifge          655
     651: iconst_1
     652: goto          656
     655: iconst_0
     656: ifeq          593
     659: aload         12
     661: aload         15
     663: invokeinterface #122,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     668: pop
     669: goto          593
     672: aload         12
     674: checkcast     #124                // class java/util/List
     677: nop
     678: areturn

  public static final void boilKettle(int, int);
    Code:
       0: ldc2_w        #392                // long 180000l
       3: iload_1
       4: i2l
       5: lmul
       6: ldc2_w        #394                // long 1000l
       9: ldiv
      10: lstore_2
      11: iload_0
      12: invokestatic  #364                // Method java/lang/System.currentTimeMillis:()J
      15: lload_2
      16: ladd
      17: iload_1
      18: invokestatic  #397                // Method update:(IJI)Ljava/util/List;
      21: pop
      22: return

  public static final java.util.List<java.lang.String> drink(int, int);
    Code:
       0: iload_0
       1: iload_0
       2: invokestatic  #404                // Method byId:(I)LKettle;
       5: invokevirtual #359                // Method Kettle.getBoilTime:()J
       8: iload_1
       9: invokestatic  #397                // Method update:(IJI)Ljava/util/List;
      12: areturn

  private static final int nearKettles$lambda$2(java.util.TreeMap, java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
       5: aload_1
       6: ldc_w         #321                // int 2147483647
       9: invokestatic  #224                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: invokevirtual #214                // Method java/util/TreeMap.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      15: checkcast     #317                // class java/lang/Number
      18: invokevirtual #320                // Method java/lang/Number.intValue:()I
      21: aload_0
      22: aload_2
      23: invokestatic  #208                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      26: aload_2
      27: ldc_w         #321                // int 2147483647
      30: invokestatic  #224                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: invokevirtual #214                // Method java/util/TreeMap.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      36: checkcast     #317                // class java/lang/Number
      39: invokevirtual #320                // Method java/lang/Number.intValue:()I
      42: isub
      43: ireturn

  private static final int nearKettles$lambda$3(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #412,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #317                // class java/lang/Number
      11: invokevirtual #320                // Method java/lang/Number.intValue:()I
      14: ireturn

  static {};
    Code:
       0: ldc_w         #419                // String 1
       3: putstatic     #11                 // Field room:Ljava/lang/String;
       6: sipush        200
       9: putstatic     #27                 // Field ml:I
      12: ldc_w         #421                // String http://192.168.43.217:1000/
      15: putstatic     #43                 // Field start:Ljava/lang/String;
      18: return
}

Compiled from "Comparisons.kt"
public final class LogisticsKt$nearKettles$$inlined$compareByDescending$1<T> implements java.util.Comparator {
  final long $currentTime$inlined;

  public LogisticsKt$nearKettles$$inlined$compareByDescending$1(long);
    Code:
       0: aload_0
       1: lload_1
       2: putfield      #18                 // Field $currentTime$inlined:J
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public final int compare(T, T);
    Code:
       0: aload_2
       1: checkcast     #28                 // class Kettle
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #32                 // Method Kettle.getBoilTime:()J
      12: aload_0
      13: getfield      #18                 // Field $currentTime$inlined:J
      16: invokestatic  #38                 // Method kotlin/ranges/RangesKt.coerceAtMost:(JJ)J
      19: invokestatic  #44                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      22: checkcast     #46                 // class java/lang/Comparable
      25: aload_1
      26: checkcast     #28                 // class Kettle
      29: astore_3
      30: astore        5
      32: iconst_0
      33: istore        4
      35: aload_3
      36: invokevirtual #32                 // Method Kettle.getBoilTime:()J
      39: aload_0
      40: getfield      #18                 // Field $currentTime$inlined:J
      43: invokestatic  #38                 // Method kotlin/ranges/RangesKt.coerceAtMost:(JJ)J
      46: invokestatic  #44                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      49: checkcast     #46                 // class java/lang/Comparable
      52: aload         5
      54: swap
      55: invokestatic  #52                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      58: ireturn
}


//The prime numbers are not regularly spaced.
// For example from 2 to 3 the step is 1. From 3 to 5
// the step is 2. From 7 to 11 it is 4.
// Between 2 and 50 we have the following pairs of 2-steps primes:
//
//3, 5 - 5, 7, - 11, 13, - 17, 19, - 29, 31, - 41, 43
//
//We will write a function step with parameters:
//
//g (integer >= 2) which indicates the step we are looking for,
//
//m (integer >= 2) which gives the start of the search (m inclusive),
//
//n (integer >= m) which gives the end of the search (n inclusive)
//
//In the example above step(2, 2, 50) will return [3, 5]
//which is the first pair between 2 and 50 with a 2-steps.
//
//So this function should return the first pair of the
//two prime numbers spaced with a step of g between the limits m,
// n if these g-steps prime numbers exist otherwise
// nil or null or None or Nothing or [] or "0, 0" or {0, 0} or 0 0 or "" (depending on the language).
//
//Examples:
//step(2, 5, 7) --> [5, 7] or (5, 7) or {5, 7} or "5 7"
//
//step(2, 5, 5) --> nil or ... or [] in Ocaml or {0, 0} in C++
//
//step(4, 130, 200) --> [163, 167] or (163, 167) or {163, 167}
//
//See more examples for your language in "TESTS"
//
//Remarks:
//([193, 197] is also such a 4-steps primes between 130
//and 200 but it's not the first pair).
//
//step(6, 100, 110) --> [101, 107] though there is a
//prime between 101 and 107 which is 103; the pair 101-103 is a 2-step.
//
//Notes:
//The idea of "step" is close to that of "gap" but it is
//not exactly the same. For those interested they can have
//a look at http://mathworld.wolfram.com/PrimeGaps.html.
//
//A "gap" is more restrictive: there must be no primes in
//between (101-107 is a "step" but not a "gap". Next kata will be about "gaps":-).
//
//For Go: nil slice is expected when there are no step between m and n.
//Example: step(2,4900,4919) --> nil

object PrimeSteps {

    // if these g-steps prime numbers don't exist return []
    fun step(g: Int, m: Long, n: Long): LongArray {
        println("g = $g, m = $m, n = $n")
        if (n < m || m < 2 || g < 2)
            return LongArray(0)

        var array = LongArray(2)
        val listOfPrimes = mutableListOf<Long>()
        var stepCounter = 0
        var isPrime = true
        if (m == 2L || m == 3L || m == 5L) {
            array[0] = m
            listOfPrimes.add(m)
        }
        for (i in m..n) {
            if (i % 2 == 0L) {
                stepCounter++
                continue
            }
            for (p in 3 .. i / 2 step 2) {
                if (i % p == 0L) {
                    isPrime = false
                    break
                }
                isPrime = true
            }

            if (isPrime && i != 5L) {
                println(listOfPrimes)
                listOfPrimes.add(i)
            }

            listOfPrimes.forEachIndexed { index, l ->
                val differ = listOfPrimes[listOfPrimes.size - 1] - listOfPrimes[index]
                if(differ == g.toLong()) {
                    array[0] = listOfPrimes[index]
                    array[1] = listOfPrimes[listOfPrimes.size - 1]
                    return array
                }
            }
        }
        return if (array[1] == 0L) {
            return LongArray(0)
        } else {
            array
        }
    }
}

fun main(args: Array<String>) {
    var array = PrimeSteps.step(2, 7, 13)
    println(array.asList())
}

Compiled from "PrimeSteps.kt"
public final class PrimeStepsKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #21                 // Field PrimeSteps.INSTANCE:LPrimeSteps;
       9: iconst_2
      10: ldc2_w        #22                 // long 7l
      13: ldc2_w        #24                 // long 13l
      16: invokevirtual #29                 // Method PrimeSteps.step:(IJJ)[J
      19: astore_1
      20: aload_1
      21: invokestatic  #35                 // Method kotlin/collections/ArraysKt.asList:([J)Ljava/util/List;
      24: getstatic     #41                 // Field java/lang/System.out:Ljava/io/PrintStream;
      27: swap
      28: invokevirtual #47                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      31: return
}

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

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

  public final long[] step(int, long, long);
    Code:
       0: new           #15                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #16                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #18                 // String g =
       9: invokevirtual #22                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: iload_1
      13: invokevirtual #25                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      16: ldc           #27                 // String , m =
      18: invokevirtual #22                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      21: lload_2
      22: invokevirtual #30                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      25: ldc           #32                 // String , n =
      27: invokevirtual #22                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      30: lload         4
      32: invokevirtual #30                 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      35: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      38: getstatic     #42                 // Field java/lang/System.out:Ljava/io/PrintStream;
      41: swap
      42: invokevirtual #48                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      45: lload         4
      47: lload_2
      48: lcmp
      49: iflt          65
      52: lload_2
      53: ldc2_w        #49                 // long 2l
      56: lcmp
      57: iflt          65
      60: iload_1
      61: iconst_2
      62: if_icmpge     69
      65: iconst_0
      66: newarray       long
      68: areturn
      69: aconst_null
      70: astore        6
      72: iconst_2
      73: newarray       long
      75: astore        6
      77: new           #52                 // class java/util/ArrayList
      80: dup
      81: invokespecial #53                 // Method java/util/ArrayList."<init>":()V
      84: checkcast     #55                 // class java/util/List
      87: astore        7
      89: iconst_0
      90: istore        8
      92: iconst_1
      93: istore        9
      95: lload_2
      96: ldc2_w        #49                 // long 2l
      99: lcmp
     100: ifeq          119
     103: lload_2
     104: ldc2_w        #56                 // long 3l
     107: lcmp
     108: ifeq          119
     111: lload_2
     112: ldc2_w        #58                 // long 5l
     115: lcmp
     116: ifne          136
     119: aload         6
     121: iconst_0
     122: lload_2
     123: lastore
     124: aload         7
     126: lload_2
     127: invokestatic  #65                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     130: invokeinterface #69,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     135: pop
     136: lload_2
     137: lstore        10
     139: lload         10
     141: lload         4
     143: lcmp
     144: ifgt          461
     147: lload         10
     149: iconst_2
     150: i2l
     151: lrem
     152: lconst_0
     153: lcmp
     154: ifne          163
     157: iinc          8, 1
     160: goto          444
     163: lload         10
     165: iconst_2
     166: i2l
     167: ldiv
     168: lstore        12
     170: ldc2_w        #56                 // long 3l
     173: lstore        14
     175: ldc2_w        #56                 // long 3l
     178: lload         12
     180: ldc2_w        #49                 // long 2l
     183: invokestatic  #75                 // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(JJJ)J
     186: lstore        16
     188: lload         14
     190: lload         16
     192: lcmp
     193: ifgt          234
     196: lload         10
     198: lload         14
     200: lrem
     201: lconst_0
     202: lcmp
     203: ifne          212
     206: iconst_0
     207: istore        9
     209: goto          234
     212: iconst_1
     213: istore        9
     215: lload         14
     217: lload         16
     219: lcmp
     220: ifeq          234
     223: lload         14
     225: ldc2_w        #49                 // long 2l
     228: ladd
     229: lstore        14
     231: goto          196
     234: iload         9
     236: ifeq          269
     239: lload         10
     241: ldc2_w        #58                 // long 5l
     244: lcmp
     245: ifeq          269
     248: getstatic     #42                 // Field java/lang/System.out:Ljava/io/PrintStream;
     251: aload         7
     253: invokevirtual #48                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     256: aload         7
     258: lload         10
     260: invokestatic  #65                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     263: invokeinterface #69,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     268: pop
     269: aload         7
     271: checkcast     #77                 // class java/lang/Iterable
     274: astore        12
     276: iconst_0
     277: istore        13
     279: iconst_0
     280: istore        14
     282: aload         12
     284: invokeinterface #81,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     289: astore        15
     291: aload         15
     293: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     298: ifeq          443
     301: aload         15
     303: invokeinterface #91,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     308: astore        16
     310: iload         14
     312: iinc          14, 1
     315: istore        17
     317: iload         17
     319: ifge          325
     322: invokestatic  #96                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     325: iload         17
     327: aload         16
     329: checkcast     #98                 // class java/lang/Number
     332: invokevirtual #102                // Method java/lang/Number.longValue:()J
     335: lstore        18
     337: istore        20
     339: iconst_0
     340: istore        21
     342: aload         7
     344: aload         7
     346: invokeinterface #106,  1          // InterfaceMethod java/util/List.size:()I
     351: iconst_1
     352: isub
     353: invokeinterface #110,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     358: checkcast     #98                 // class java/lang/Number
     361: invokevirtual #102                // Method java/lang/Number.longValue:()J
     364: aload         7
     366: iload         20
     368: invokeinterface #110,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     373: checkcast     #98                 // class java/lang/Number
     376: invokevirtual #102                // Method java/lang/Number.longValue:()J
     379: lsub
     380: lstore        22
     382: lload         22
     384: iload_1
     385: i2l
     386: lcmp
     387: ifne          438
     390: aload         6
     392: iconst_0
     393: aload         7
     395: iload         20
     397: invokeinterface #110,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     402: checkcast     #98                 // class java/lang/Number
     405: invokevirtual #102                // Method java/lang/Number.longValue:()J
     408: lastore
     409: aload         6
     411: iconst_1
     412: aload         7
     414: aload         7
     416: invokeinterface #106,  1          // InterfaceMethod java/util/List.size:()I
     421: iconst_1
     422: isub
     423: invokeinterface #110,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     428: checkcast     #98                 // class java/lang/Number
     431: invokevirtual #102                // Method java/lang/Number.longValue:()J
     434: lastore
     435: aload         6
     437: areturn
     438: nop
     439: nop
     440: goto          291
     443: nop
     444: lload         10
     446: lload         4
     448: lcmp
     449: ifeq          461
     452: lload         10
     454: lconst_1
     455: ladd
     456: lstore        10
     458: goto          147
     461: aload         6
     463: iconst_1
     464: laload
     465: lconst_0
     466: lcmp
     467: ifne          474
     470: iconst_0
     471: newarray       long
     473: areturn
     474: aload         6
     476: areturn

  static {};
    Code:
       0: new           #2                  // class PrimeSteps
       3: dup
       4: invokespecial #137                // Method "<init>":()V
       7: putstatic     #140                // Field INSTANCE:LPrimeSteps;
      10: return
}


//A format for expressing an ordered list of
//integers is to use a comma separated list of either
//
//individual integers
//or a range of integers denoted by the
//starting integer separated from the end integer in
//the range by a dash, '-'. The range includes all
//integers in the interval including both endpoints.
//It is not considered a range unless it spans at least
//3 numbers. For example "12,13,15-17"
//Complete the solution so that it takes a
//list of integers in increasing order and returns a
//correctly formatted string in the range format.
//
//Example:
//
//solution([-6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20]);
// returns "-6,-3-1,3-5,7-11,14,15,17-20"

object RangeExtraction {

    fun rangeExtraction(arr: IntArray): String {
        var listOfRangedNumbers = mutableListOf<Int>()
        var finalString = ""
        var rangeString = ""
        var isNext = false

        arr.forEachIndexed { index, i ->
            if (i <= 1) {
                val nextIndex: Int = try {
                    arr[index + 1]
                } catch (e: Exception) {
                    arr[index]
                }
                if (i == nextIndex - 1) {
                    isNext = true
                    listOfRangedNumbers.add(i)
                } else {
                    if (isNext)
                        listOfRangedNumbers.add(i)
                    if (listOfRangedNumbers.size > 2) {
                        rangeString =
                            rangeString.plus("${listOfRangedNumbers[0]}-${listOfRangedNumbers[listOfRangedNumbers.size - 1]},")
                        finalString = finalString.plus(rangeString)
                        rangeString = ""
                        listOfRangedNumbers = mutableListOf()
                    } else {
                        listOfRangedNumbers.forEach {
                            finalString = finalString.plus("$it,")

                        }
                        listOfRangedNumbers = mutableListOf()
                    }
                }
            }
            if (i > 1) {
                val nextIndex: Int = try {
                    arr[index + 1]
                } catch (e: Exception) {
                    0
                }
                if (i == nextIndex - 1) {
                    isNext = true
                    listOfRangedNumbers.add(i)
                } else {
                    if (isNext)
                        listOfRangedNumbers.add(i)
                    if (listOfRangedNumbers.size > 2) {
                        rangeString =
                            rangeString.plus("${listOfRangedNumbers[0]}-${listOfRangedNumbers[listOfRangedNumbers.size - 1]},")
                        finalString = finalString.plus(rangeString)
                        rangeString = ""
                        listOfRangedNumbers = mutableListOf()
                    } else {
                        listOfRangedNumbers.forEach {
                            finalString = finalString.plus("$it,")

                        }
                        listOfRangedNumbers = mutableListOf()
                    }
                }
            }
            if (!isNext) {
                finalString = finalString.plus("$i,")
            }
        }
        finalString = finalString.dropLast(1)
        println(finalString)
        return finalString
    }

}

fun main(args: Array<String>) {
    val array = intArrayOf(-6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20)
    RangeExtraction.rangeExtraction(array)
}

//best solution

fun rangeExtraction(
    arr: IntArray
): String = arr.fold(emptyList<Pair<Int, Int>>())
{ rs, x ->
    rs.lastOrNull().run {
        if (this != null && x - second == 1)
            rs.dropLast(1) + (first to x)
        else rs + (x to x)
    }
}.joinToString(",")
{ (x, y) ->
    if (y - x > 1) "$x-$y" else (x..y).joinToString(",")
}

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

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

  public final java.lang.String rangeExtraction(int[]);
    Code:
       0: aload_1
       1: ldc           #17                 // String arr
       3: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aconst_null
       7: astore_2
       8: new           #25                 // class java/util/ArrayList
      11: dup
      12: invokespecial #26                 // Method java/util/ArrayList."<init>":()V
      15: checkcast     #28                 // class java/util/List
      18: astore_2
      19: aconst_null
      20: astore_3
      21: ldc           #30                 // String
      23: astore_3
      24: aconst_null
      25: astore        4
      27: ldc           #30                 // String
      29: astore        4
      31: iconst_0
      32: istore        5
      34: aload_1
      35: astore        6
      37: iconst_0
      38: istore        7
      40: iconst_0
      41: istore        8
      43: iconst_0
      44: istore        9
      46: aload         6
      48: arraylength
      49: istore        10
      51: iload         9
      53: iload         10
      55: if_icmpge     676
      58: aload         6
      60: iload         9
      62: iaload
      63: istore        11
      65: iload         8
      67: iinc          8, 1
      70: iload         11
      72: istore        12
      74: istore        13
      76: iconst_0
      77: istore        14
      79: iload         12
      81: iconst_1
      82: if_icmpgt     360
      85: nop
      86: aload_1
      87: iload         13
      89: iconst_1
      90: iadd
      91: iaload
      92: istore        15
      94: goto          105
      97: astore        16
      99: aload_1
     100: iload         13
     102: iaload
     103: istore        15
     105: iload         15
     107: istore        17
     109: iload         12
     111: iload         17
     113: iconst_1
     114: isub
     115: if_icmpne     136
     118: iconst_1
     119: istore        5
     121: aload_2
     122: iload         12
     124: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     127: invokeinterface #40,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     132: pop
     133: goto          360
     136: iload         5
     138: ifeq          153
     141: aload_2
     142: iload         12
     144: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     147: invokeinterface #40,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     152: pop
     153: aload_2
     154: invokeinterface #44,  1           // InterfaceMethod java/util/List.size:()I
     159: iconst_2
     160: if_icmple     268
     163: nop
     164: new           #46                 // class java/lang/StringBuilder
     167: dup
     168: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
     171: aload         4
     173: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     176: aload_2
     177: iconst_0
     178: invokeinterface #55,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     183: checkcast     #57                 // class java/lang/Number
     186: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     189: invokevirtual #63                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     192: bipush        45
     194: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     197: aload_2
     198: aload_2
     199: invokeinterface #44,  1           // InterfaceMethod java/util/List.size:()I
     204: iconst_1
     205: isub
     206: invokeinterface #55,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     211: checkcast     #57                 // class java/lang/Number
     214: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     217: invokevirtual #63                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     220: bipush        44
     222: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     225: invokevirtual #70                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     228: astore        4
     230: new           #46                 // class java/lang/StringBuilder
     233: dup
     234: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
     237: aload_3
     238: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     241: aload         4
     243: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     246: invokevirtual #70                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     249: astore_3
     250: ldc           #30                 // String
     252: astore        4
     254: new           #25                 // class java/util/ArrayList
     257: dup
     258: invokespecial #26                 // Method java/util/ArrayList."<init>":()V
     261: checkcast     #28                 // class java/util/List
     264: astore_2
     265: goto          360
     268: aload_2
     269: checkcast     #72                 // class java/lang/Iterable
     272: astore        15
     274: iconst_0
     275: istore        16
     277: aload         15
     279: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     284: astore        18
     286: aload         18
     288: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     293: ifeq          348
     296: aload         18
     298: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     303: astore        19
     305: aload         19
     307: checkcast     #57                 // class java/lang/Number
     310: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     313: istore        20
     315: iconst_0
     316: istore        21
     318: new           #46                 // class java/lang/StringBuilder
     321: dup
     322: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
     325: aload_3
     326: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     329: iload         20
     331: invokevirtual #63                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     334: bipush        44
     336: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     339: invokevirtual #70                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     342: astore_3
     343: nop
     344: nop
     345: goto          286
     348: nop
     349: new           #25                 // class java/util/ArrayList
     352: dup
     353: invokespecial #26                 // Method java/util/ArrayList."<init>":()V
     356: checkcast     #28                 // class java/util/List
     359: astore_2
     360: iload         12
     362: iconst_1
     363: if_icmple     638
     366: nop
     367: aload_1
     368: iload         13
     370: iconst_1
     371: iadd
     372: iaload
     373: istore        15
     375: goto          383
     378: astore        16
     380: iconst_0
     381: istore        15
     383: iload         15
     385: istore        17
     387: iload         12
     389: iload         17
     391: iconst_1
     392: isub
     393: if_icmpne     414
     396: iconst_1
     397: istore        5
     399: aload_2
     400: iload         12
     402: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     405: invokeinterface #40,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     410: pop
     411: goto          638
     414: iload         5
     416: ifeq          431
     419: aload_2
     420: iload         12
     422: invokestatic  #36                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     425: invokeinterface #40,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     430: pop
     431: aload_2
     432: invokeinterface #44,  1           // InterfaceMethod java/util/List.size:()I
     437: iconst_2
     438: if_icmple     546
     441: nop
     442: new           #46                 // class java/lang/StringBuilder
     445: dup
     446: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
     449: aload         4
     451: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     454: aload_2
     455: iconst_0
     456: invokeinterface #55,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     461: checkcast     #57                 // class java/lang/Number
     464: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     467: invokevirtual #63                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     470: bipush        45
     472: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     475: aload_2
     476: aload_2
     477: invokeinterface #44,  1           // InterfaceMethod java/util/List.size:()I
     482: iconst_1
     483: isub
     484: invokeinterface #55,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     489: checkcast     #57                 // class java/lang/Number
     492: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     495: invokevirtual #63                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     498: bipush        44
     500: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     503: invokevirtual #70                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     506: astore        4
     508: new           #46                 // class java/lang/StringBuilder
     511: dup
     512: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
     515: aload_3
     516: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     519: aload         4
     521: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     524: invokevirtual #70                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     527: astore_3
     528: ldc           #30                 // String
     530: astore        4
     532: new           #25                 // class java/util/ArrayList
     535: dup
     536: invokespecial #26                 // Method java/util/ArrayList."<init>":()V
     539: checkcast     #28                 // class java/util/List
     542: astore_2
     543: goto          638
     546: aload_2
     547: checkcast     #72                 // class java/lang/Iterable
     550: astore        15
     552: iconst_0
     553: istore        16
     555: aload         15
     557: invokeinterface #76,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     562: astore        18
     564: aload         18
     566: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     571: ifeq          626
     574: aload         18
     576: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     581: astore        19
     583: aload         19
     585: checkcast     #57                 // class java/lang/Number
     588: invokevirtual #60                 // Method java/lang/Number.intValue:()I
     591: istore        20
     593: iconst_0
     594: istore        21
     596: new           #46                 // class java/lang/StringBuilder
     599: dup
     600: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
     603: aload_3
     604: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     607: iload         20
     609: invokevirtual #63                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     612: bipush        44
     614: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     617: invokevirtual #70                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     620: astore_3
     621: nop
     622: nop
     623: goto          564
     626: nop
     627: new           #25                 // class java/util/ArrayList
     630: dup
     631: invokespecial #26                 // Method java/util/ArrayList."<init>":()V
     634: checkcast     #28                 // class java/util/List
     637: astore_2
     638: iload         5
     640: ifne          668
     643: new           #46                 // class java/lang/StringBuilder
     646: dup
     647: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
     650: aload_3
     651: invokevirtual #51                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     654: iload         12
     656: invokevirtual #63                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     659: bipush        44
     661: invokevirtual #66                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     664: invokevirtual #70                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     667: astore_3
     668: nop
     669: nop
     670: iinc          9, 1
     673: goto          51
     676: nop
     677: aload_3
     678: iconst_1
     679: invokestatic  #92                 // Method kotlin/text/StringsKt.dropLast:(Ljava/lang/String;I)Ljava/lang/String;
     682: astore_3
     683: aload_3
     684: getstatic     #98                 // Field java/lang/System.out:Ljava/io/PrintStream;
     687: swap
     688: invokevirtual #104                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     691: aload_3
     692: areturn
    Exception table:
       from    to  target type
          85    94    97   Class java/lang/Exception
         366   375   378   Class java/lang/Exception

  static {};
    Code:
       0: new           #2                  // class RangeExtraction
       3: dup
       4: invokespecial #134                // Method "<init>":()V
       7: putstatic     #137                // Field INSTANCE:LRangeExtraction;
      10: return
}

Compiled from "RangeExtraction.kt"
public final class RangeExtractionKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: bipush        20
       8: newarray       int
      10: astore_2
      11: aload_2
      12: iconst_0
      13: bipush        -6
      15: iastore
      16: aload_2
      17: iconst_1
      18: bipush        -3
      20: iastore
      21: aload_2
      22: iconst_2
      23: bipush        -2
      25: iastore
      26: aload_2
      27: iconst_3
      28: iconst_m1
      29: iastore
      30: aload_2
      31: iconst_4
      32: iconst_0
      33: iastore
      34: aload_2
      35: iconst_5
      36: iconst_1
      37: iastore
      38: aload_2
      39: bipush        6
      41: iconst_3
      42: iastore
      43: aload_2
      44: bipush        7
      46: iconst_4
      47: iastore
      48: aload_2
      49: bipush        8
      51: iconst_5
      52: iastore
      53: aload_2
      54: bipush        9
      56: bipush        7
      58: iastore
      59: aload_2
      60: bipush        10
      62: bipush        8
      64: iastore
      65: aload_2
      66: bipush        11
      68: bipush        9
      70: iastore
      71: aload_2
      72: bipush        12
      74: bipush        10
      76: iastore
      77: aload_2
      78: bipush        13
      80: bipush        11
      82: iastore
      83: aload_2
      84: bipush        14
      86: bipush        14
      88: iastore
      89: aload_2
      90: bipush        15
      92: bipush        15
      94: iastore
      95: aload_2
      96: bipush        16
      98: bipush        17
     100: iastore
     101: aload_2
     102: bipush        17
     104: bipush        18
     106: iastore
     107: aload_2
     108: bipush        18
     110: bipush        19
     112: iastore
     113: aload_2
     114: bipush        19
     116: bipush        20
     118: iastore
     119: aload_2
     120: astore_1
     121: getstatic     #21                 // Field RangeExtraction.INSTANCE:LRangeExtraction;
     124: aload_1
     125: invokevirtual #25                 // Method RangeExtraction.rangeExtraction:([I)Ljava/lang/String;
     128: pop
     129: return

  public static final java.lang.String rangeExtraction(int[]);
    Code:
       0: aload_0
       1: ldc           #30                 // String arr
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      11: astore_2
      12: iconst_0
      13: istore_3
      14: aload_2
      15: astore        4
      17: iconst_0
      18: istore        5
      20: aload_1
      21: arraylength
      22: istore        6
      24: iload         5
      26: iload         6
      28: if_icmpge     143
      31: aload_1
      32: iload         5
      34: iaload
      35: istore        7
      37: aload         4
      39: iload         7
      41: istore        8
      43: astore        9
      45: iconst_0
      46: istore        10
      48: aload         9
      50: invokestatic  #40                 // Method kotlin/collections/CollectionsKt.lastOrNull:(Ljava/util/List;)Ljava/lang/Object;
      53: checkcast     #42                 // class kotlin/Pair
      56: astore        11
      58: iconst_0
      59: istore        12
      61: aload         11
      63: ifnull        112
      66: iload         8
      68: aload         11
      70: invokevirtual #46                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      73: checkcast     #48                 // class java/lang/Number
      76: invokevirtual #52                 // Method java/lang/Number.intValue:()I
      79: isub
      80: iconst_1
      81: if_icmpne     112
      84: aload         9
      86: iconst_1
      87: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;
      90: checkcast     #58                 // class java/util/Collection
      93: aload         11
      95: invokevirtual #61                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      98: iload         8
     100: invokestatic  #67                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: invokestatic  #73                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     106: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     109: goto          133
     112: aload         9
     114: checkcast     #58                 // class java/util/Collection
     117: iload         8
     119: invokestatic  #67                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     122: iload         8
     124: invokestatic  #67                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     127: invokestatic  #73                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     130: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     133: nop
     134: nop
     135: astore        4
     137: iinc          5, 1
     140: goto          24
     143: aload         4
     145: checkcast     #79                 // class java/lang/Iterable
     148: ldc           #81                 // String ,
     150: checkcast     #83                 // class java/lang/CharSequence
     153: aconst_null
     154: aconst_null
     155: iconst_0
     156: aconst_null
     157: invokedynamic #102,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     162: bipush        30
     164: aconst_null
     165: invokestatic  #106                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     168: areturn

  private static final java.lang.CharSequence rangeExtraction$lambda$2(kotlin.Pair);
    Code:
       0: aload_0
       1: ldc           #125                // String <destruct>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #128                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      10: checkcast     #48                 // class java/lang/Number
      13: invokevirtual #52                 // Method java/lang/Number.intValue:()I
      16: istore_1
      17: aload_0
      18: invokevirtual #131                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      21: checkcast     #48                 // class java/lang/Number
      24: invokevirtual #52                 // Method java/lang/Number.intValue:()I
      27: istore_2
      28: iload_2
      29: iload_1
      30: isub
      31: iconst_1
      32: if_icmple     64
      35: new           #133                // class java/lang/StringBuilder
      38: dup
      39: invokespecial #137                // Method java/lang/StringBuilder."<init>":()V
      42: iload_1
      43: invokevirtual #141                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      46: bipush        45
      48: invokevirtual #144                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      51: iload_2
      52: invokevirtual #141                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      55: invokevirtual #148                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      58: checkcast     #83                 // class java/lang/CharSequence
      61: goto          95
      64: new           #150                // class kotlin/ranges/IntRange
      67: dup
      68: iload_1
      69: iload_2
      70: invokespecial #153                // Method kotlin/ranges/IntRange."<init>":(II)V
      73: checkcast     #79                 // class java/lang/Iterable
      76: ldc           #81                 // String ,
      78: checkcast     #83                 // class java/lang/CharSequence
      81: aconst_null
      82: aconst_null
      83: iconst_0
      84: aconst_null
      85: aconst_null
      86: bipush        62
      88: aconst_null
      89: invokestatic  #106                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      92: checkcast     #83                 // class java/lang/CharSequence
      95: areturn
}