import java.io.File
import kotlin.math.*

fun wasteland(in1: Int): Int {
	var lines = File("day2308_puzzle_input.txt").readLines()
	var network = mutableMapOf<String, Pair<String, String>>()
	var instructions = lines[0]
	for (i in 2..lines.size - 1) {
		network.put(
			lines[i].substringBefore(" ="),
			Pair(lines[i].substringAfter("(").substringBefore(","), lines[i].substringAfter(", ").substringBefore(")"))
		)
	}

	var position = "AAA"
	var count = 0

	while (position != "ZZZ") {
		var nextStep = instructions[count % instructions.length]

		if (nextStep == 'R') {
			position = network.getValue(position).second
		} else {
			position = network.getValue(position).first
		}
		count += 1
		if (position.takeLast(1) == "Z") {
			println("$position, $count")
		}
	}
	return count
}

fun wasteland2(in1: Int): Long {
	var lines = File("day2308_puzzle_input.txt").readLines()
	var network = mutableMapOf<String, Pair<String, String>>()
	var instructions = lines[0]
	for (i in 2..lines.size - 1) {
		network.put(
			lines[i].substringBefore(" ="),
			Pair(lines[i].substringAfter("(").substringBefore(","), lines[i].substringAfter(", ").substringBefore(")"))
		)
	}

	var position = mutableListOf<String>()
	network.forEach {
		if(it.key.takeLast(1) == "A") {
			position.add(it.key)
		}
	}
	var count = 0L
	var instructionLength = instructions.length.toLong()
    println(position)
    while (position.map {it.last()}.distinct().size != 1 || position.map {it.takeLast(1)}.distinct()[0] != "Z") {
		var nextStep = instructions[(count % instructionLength).toInt()]

		for (i in 0..position.size-1)
		if (nextStep == 'R') {
			position[i] = network.getValue(position[i]).second
		} else {
			position[i] = network.getValue(position[i]).first
		}
		count += 1L
		//println("$nextStep: $position")
	}
	return count
}

fun main() {
	var t1 = System.currentTimeMillis()

	var solution1 = wasteland(1)
	var solution2 = wasteland2(2)
	//das läuft ewig. Wenn man nur jeweils einen Wert anschaut sieht man, dass man mit einem Eingangswert nur einen Ausgangswert erreicht, und das mit einer bestimmten Periode.
	//Berechnet man daraus das kleinste gemeinsame Vielfache, bekommt man die richtige Lösung. Aber ist das zwingend bei allen Inputs so - theoretisch könnte es mehrere Zielpunkte
	// geben mit unterschiedlichen Frequenzen und Offset? -> ich habe das hier nicht merh angepasst
	//AAA		GPA		VDA		GTA		BBA		VSA
  //ZZZ		CVZ		STZ		FPZ		SKZ		MKZ
  //17287		13771	23147	20803	19631	17873   -> KgV = 18625484023687

// print solution for part 1
	println("*******************************")
	println("--- Day 8: Haunted Wasteland ---")
	println("*******************************")
	println("Solution for part1")
	println("   $solution1 steps are required to reach ZZZ")
	println()
// print solution for part 2
	println("*******************************")
	println("Solution for part2")
	println("   $solution2 steps does it take before you're only on nodes that end with Z")
	println()

	t1 = System.currentTimeMillis() - t1
	println("puzzle solved in ${t1} ms")
}

Compiled from "day2308_1_2.kt"
public final class Day2308_1_2Kt {
  public static final int wasteland(int);
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String day2308_puzzle_input.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_1
      16: new           #22                 // class java/util/LinkedHashMap
      19: dup
      20: invokespecial #25                 // Method java/util/LinkedHashMap."<init>":()V
      23: checkcast     #27                 // class java/util/Map
      26: astore_2
      27: aload_1
      28: iconst_0
      29: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      34: checkcast     #35                 // class java/lang/String
      37: astore_3
      38: iconst_2
      39: istore        4
      41: aload_1
      42: invokeinterface #39,  1           // InterfaceMethod java/util/List.size:()I
      47: istore        5
      49: iload         4
      51: iload         5
      53: if_icmpge     149
      56: aload_2
      57: aload_1
      58: iload         4
      60: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      65: checkcast     #35                 // class java/lang/String
      68: ldc           #41                 // String  =
      70: aconst_null
      71: iconst_2
      72: aconst_null
      73: invokestatic  #47                 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      76: new           #49                 // class kotlin/Pair
      79: dup
      80: aload_1
      81: iload         4
      83: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      88: checkcast     #35                 // class java/lang/String
      91: ldc           #51                 // String (
      93: aconst_null
      94: iconst_2
      95: aconst_null
      96: invokestatic  #54                 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      99: ldc           #56                 // String ,
     101: aconst_null
     102: iconst_2
     103: aconst_null
     104: invokestatic  #47                 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     107: aload_1
     108: iload         4
     110: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     115: checkcast     #35                 // class java/lang/String
     118: ldc           #58                 // String ,
     120: aconst_null
     121: iconst_2
     122: aconst_null
     123: invokestatic  #54                 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     126: ldc           #60                 // String )
     128: aconst_null
     129: iconst_2
     130: aconst_null
     131: invokestatic  #47                 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     134: invokespecial #63                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     137: invokeinterface #67,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     142: pop
     143: iinc          4, 1
     146: goto          49
     149: ldc           #69                 // String AAA
     151: astore        4
     153: iconst_0
     154: istore        5
     156: aload         4
     158: ldc           #71                 // String ZZZ
     160: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     163: ifne          275
     166: aload_3
     167: iload         5
     169: aload_3
     170: invokevirtual #80                 // Method java/lang/String.length:()I
     173: irem
     174: invokevirtual #84                 // Method java/lang/String.charAt:(I)C
     177: istore        6
     179: iload         6
     181: bipush        82
     183: if_icmpne     206
     186: aload_2
     187: aload         4
     189: invokestatic  #90                 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     192: checkcast     #49                 // class kotlin/Pair
     195: invokevirtual #94                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     198: checkcast     #35                 // class java/lang/String
     201: astore        4
     203: goto          223
     206: aload_2
     207: aload         4
     209: invokestatic  #90                 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     212: checkcast     #49                 // class kotlin/Pair
     215: invokevirtual #97                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     218: checkcast     #35                 // class java/lang/String
     221: astore        4
     223: iinc          5, 1
     226: aload         4
     228: iconst_1
     229: invokestatic  #101                // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;
     232: ldc           #103                // String Z
     234: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     237: ifeq          156
     240: new           #105                // class java/lang/StringBuilder
     243: dup
     244: invokespecial #106                // Method java/lang/StringBuilder."<init>":()V
     247: aload         4
     249: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     252: ldc           #58                 // String ,
     254: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     257: iload         5
     259: invokevirtual #113                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     262: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     265: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
     268: swap
     269: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     272: goto          156
     275: iload         5
     277: ireturn

  public static final long wasteland2(int);
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String day2308_puzzle_input.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_1
      16: new           #22                 // class java/util/LinkedHashMap
      19: dup
      20: invokespecial #25                 // Method java/util/LinkedHashMap."<init>":()V
      23: checkcast     #27                 // class java/util/Map
      26: astore_2
      27: aload_1
      28: iconst_0
      29: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      34: checkcast     #35                 // class java/lang/String
      37: astore_3
      38: iconst_2
      39: istore        4
      41: aload_1
      42: invokeinterface #39,  1           // InterfaceMethod java/util/List.size:()I
      47: istore        5
      49: iload         4
      51: iload         5
      53: if_icmpge     149
      56: aload_2
      57: aload_1
      58: iload         4
      60: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      65: checkcast     #35                 // class java/lang/String
      68: ldc           #41                 // String  =
      70: aconst_null
      71: iconst_2
      72: aconst_null
      73: invokestatic  #47                 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      76: new           #49                 // class kotlin/Pair
      79: dup
      80: aload_1
      81: iload         4
      83: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      88: checkcast     #35                 // class java/lang/String
      91: ldc           #51                 // String (
      93: aconst_null
      94: iconst_2
      95: aconst_null
      96: invokestatic  #54                 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      99: ldc           #56                 // String ,
     101: aconst_null
     102: iconst_2
     103: aconst_null
     104: invokestatic  #47                 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     107: aload_1
     108: iload         4
     110: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     115: checkcast     #35                 // class java/lang/String
     118: ldc           #58                 // String ,
     120: aconst_null
     121: iconst_2
     122: aconst_null
     123: invokestatic  #54                 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     126: ldc           #60                 // String )
     128: aconst_null
     129: iconst_2
     130: aconst_null
     131: invokestatic  #47                 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     134: invokespecial #63                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     137: invokeinterface #67,  3           // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     142: pop
     143: iinc          4, 1
     146: goto          49
     149: aconst_null
     150: astore        4
     152: new           #146                // class java/util/ArrayList
     155: dup
     156: invokespecial #147                // Method java/util/ArrayList."<init>":()V
     159: checkcast     #29                 // class java/util/List
     162: astore        4
     164: aload_2
     165: astore        5
     167: iconst_0
     168: istore        6
     170: aload         5
     172: invokeinterface #151,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     177: invokeinterface #157,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     182: astore        7
     184: aload         7
     186: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     191: ifeq          255
     194: aload         7
     196: invokeinterface #166,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     201: checkcast     #168                // class java/util/Map$Entry
     204: astore        8
     206: aload         8
     208: astore        9
     210: iconst_0
     211: istore        10
     213: aload         9
     215: invokeinterface #171,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     220: checkcast     #35                 // class java/lang/String
     223: iconst_1
     224: invokestatic  #101                // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;
     227: ldc           #173                // String A
     229: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     232: ifeq          250
     235: aload         4
     237: aload         9
     239: invokeinterface #171,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     244: invokeinterface #177,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     249: pop
     250: nop
     251: nop
     252: goto          184
     255: nop
     256: lconst_0
     257: lstore        5
     259: aload_3
     260: invokevirtual #80                 // Method java/lang/String.length:()I
     263: i2l
     264: lstore        7
     266: aload         4
     268: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
     271: swap
     272: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     275: aload         4
     277: checkcast     #179                // class java/lang/Iterable
     280: astore        9
     282: iconst_0
     283: istore        10
     285: aload         9
     287: astore        11
     289: new           #146                // class java/util/ArrayList
     292: dup
     293: aload         9
     295: bipush        10
     297: invokestatic  #185                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     300: invokespecial #188                // Method java/util/ArrayList."<init>":(I)V
     303: checkcast     #190                // class java/util/Collection
     306: astore        12
     308: iconst_0
     309: istore        13
     311: aload         11
     313: invokeinterface #191,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     318: astore        14
     320: aload         14
     322: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     327: ifeq          376
     330: aload         14
     332: invokeinterface #166,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     337: astore        15
     339: aload         12
     341: aload         15
     343: checkcast     #35                 // class java/lang/String
     346: astore        16
     348: astore        18
     350: iconst_0
     351: istore        17
     353: aload         16
     355: checkcast     #193                // class java/lang/CharSequence
     358: invokestatic  #197                // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C
     361: invokestatic  #203                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     364: aload         18
     366: swap
     367: invokeinterface #204,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     372: pop
     373: goto          320
     376: aload         12
     378: checkcast     #29                 // class java/util/List
     381: nop
     382: checkcast     #179                // class java/lang/Iterable
     385: invokestatic  #208                // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;
     388: invokeinterface #39,  1           // InterfaceMethod java/util/List.size:()I
     393: iconst_1
     394: if_icmpne     519
     397: aload         4
     399: checkcast     #179                // class java/lang/Iterable
     402: astore        9
     404: iconst_0
     405: istore        10
     407: aload         9
     409: astore        11
     411: new           #146                // class java/util/ArrayList
     414: dup
     415: aload         9
     417: bipush        10
     419: invokestatic  #185                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     422: invokespecial #188                // Method java/util/ArrayList."<init>":(I)V
     425: checkcast     #190                // class java/util/Collection
     428: astore        12
     430: iconst_0
     431: istore        13
     433: aload         11
     435: invokeinterface #191,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     440: astore        14
     442: aload         14
     444: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     449: ifeq          493
     452: aload         14
     454: invokeinterface #166,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     459: astore        15
     461: aload         12
     463: aload         15
     465: checkcast     #35                 // class java/lang/String
     468: astore        16
     470: astore        18
     472: iconst_0
     473: istore        17
     475: aload         16
     477: iconst_1
     478: invokestatic  #101                // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;
     481: aload         18
     483: swap
     484: invokeinterface #204,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     489: pop
     490: goto          442
     493: aload         12
     495: checkcast     #29                 // class java/util/List
     498: nop
     499: checkcast     #179                // class java/lang/Iterable
     502: invokestatic  #208                // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;
     505: iconst_0
     506: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     511: ldc           #103                // String Z
     513: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     516: ifne          633
     519: aload_3
     520: lload         5
     522: lload         7
     524: lrem
     525: l2i
     526: invokevirtual #84                 // Method java/lang/String.charAt:(I)C
     529: istore        9
     531: iconst_0
     532: istore        10
     534: aload         4
     536: invokeinterface #39,  1           // InterfaceMethod java/util/List.size:()I
     541: istore        11
     543: iload         10
     545: iload         11
     547: if_icmpge     624
     550: iload         9
     552: bipush        82
     554: if_icmpne     589
     557: aload         4
     559: iload         10
     561: aload_2
     562: aload         4
     564: iload         10
     566: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     571: invokestatic  #90                 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     574: checkcast     #49                 // class kotlin/Pair
     577: invokevirtual #94                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     580: invokeinterface #212,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     585: pop
     586: goto          618
     589: aload         4
     591: iload         10
     593: aload_2
     594: aload         4
     596: iload         10
     598: invokeinterface #33,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     603: invokestatic  #90                 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;
     606: checkcast     #49                 // class kotlin/Pair
     609: invokevirtual #97                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     612: invokeinterface #212,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     617: pop
     618: iinc          10, 1
     621: goto          543
     624: lload         5
     626: lconst_1
     627: ladd
     628: lstore        5
     630: goto          275
     633: lload         5
     635: lreturn

  public static final void main();
    Code:
       0: invokestatic  #236                // Method java/lang/System.currentTimeMillis:()J
       3: lstore_0
       4: iconst_1
       5: invokestatic  #238                // Method wasteland:(I)I
       8: istore_2
       9: iconst_2
      10: invokestatic  #240                // Method wasteland2:(I)J
      13: lstore_3
      14: ldc           #242                // String *******************************
      16: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
      19: swap
      20: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      23: ldc           #244                // String --- Day 8: Haunted Wasteland ---
      25: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
      28: swap
      29: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      32: ldc           #242                // String *******************************
      34: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
      37: swap
      38: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      41: ldc           #246                // String Solution for part1
      43: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
      46: swap
      47: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      50: new           #105                // class java/lang/StringBuilder
      53: dup
      54: invokespecial #106                // Method java/lang/StringBuilder."<init>":()V
      57: ldc           #248                // String
      59: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      62: iload_2
      63: invokevirtual #113                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      66: ldc           #250                // String  steps are required to reach ZZZ
      68: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      71: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      74: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
      77: swap
      78: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      81: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
      84: invokevirtual #252                // Method java/io/PrintStream.println:()V
      87: ldc           #242                // String *******************************
      89: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
      92: swap
      93: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      96: ldc           #254                // String Solution for part2
      98: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
     101: swap
     102: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     105: new           #105                // class java/lang/StringBuilder
     108: dup
     109: invokespecial #106                // Method java/lang/StringBuilder."<init>":()V
     112: ldc           #248                // String
     114: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     117: lload_3
     118: invokevirtual #257                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     121: ldc_w         #259                // String  steps does it take before you\'re only on nodes that end with Z
     124: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     127: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     130: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
     133: swap
     134: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     137: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
     140: invokevirtual #252                // Method java/io/PrintStream.println:()V
     143: invokestatic  #236                // Method java/lang/System.currentTimeMillis:()J
     146: lload_0
     147: lsub
     148: lstore_0
     149: new           #105                // class java/lang/StringBuilder
     152: dup
     153: invokespecial #106                // Method java/lang/StringBuilder."<init>":()V
     156: ldc_w         #261                // String puzzle solved in
     159: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     162: lload_0
     163: invokevirtual #257                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     166: ldc_w         #263                // String  ms
     169: invokevirtual #110                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     172: invokevirtual #117                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     175: getstatic     #123                // Field java/lang/System.out:Ljava/io/PrintStream;
     178: swap
     179: invokevirtual #129                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     182: return

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


import java.io.File
import kotlin.math.*

fun day09(in1: Int): Long {
	var result = 0L
	var lines = File("day2309_puzzle_input.txt").readLines()

	lines.forEach {

		var line = it.split(" ").map { it.toLong() }.toList()
		var interpolationValues = mutableListOf<Long>()
		var diffList = mutableListOf<Long>()

		if (in1 == 1) {
			diffList = line.windowed(2).map { it[1] - it[0] }.toMutableList()
			interpolationValues.add(line.last())
			interpolationValues.add(diffList.last())
		} else {
			diffList = line.windowed(2).map { it[0] - it[1] }.toMutableList()
			interpolationValues.add(line.first())
			interpolationValues.add(diffList.first())
		}
		while (diffList.distinct().size > 1 || diffList[0] != 0L) {
			if (in1 == 1) {
				diffList = diffList.windowed(2).map { it[1] - it[0] }.toMutableList()
				interpolationValues.add(diffList.last())
			} else {
				diffList = diffList.windowed(2).map { it[0] - it[1] }.toMutableList()
				interpolationValues.add(diffList.first())
			}
		}
		result += interpolationValues.sum()
	}
	return result
}

fun main() {
	var t1 = System.currentTimeMillis()

	var solution1 = day09(1)
	var solution2 = day09(2)

// print solution for part 1
	println("*******************************")
	println("--- Day 9: Mirage Maintenance ---")
	println("*******************************")
	println("Solution for part1")
	println("   $solution1 ")
	println()
// print solution for part 2
	println("*******************************")
	println("Solution for part2")
	println("   $solution2 ")
	println()

	t1 = System.currentTimeMillis() - t1
	println("puzzle solved in ${t1} ms")
}

Compiled from "day2309_1_2.kt"
public final class Day2309_1_2Kt {
  public static final long day09(int);
    Code:
       0: lconst_0
       1: lstore        21
       3: new           #8                  // class java/io/File
       6: dup
       7: ldc           #10                 // String day2309_puzzle_input.txt
       9: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      12: aconst_null
      13: iconst_1
      14: aconst_null
      15: invokestatic  #20                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      18: astore_1
      19: aload_1
      20: checkcast     #22                 // class java/lang/Iterable
      23: astore_2
      24: iconst_0
      25: istore_3
      26: aload_2
      27: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      32: astore        4
      34: aload         4
      36: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      41: ifeq          966
      44: aload         4
      46: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      51: astore        5
      53: aload         5
      55: checkcast     #38                 // class java/lang/String
      58: astore        6
      60: iconst_0
      61: istore        7
      63: aload         6
      65: checkcast     #40                 // class java/lang/CharSequence
      68: iconst_1
      69: anewarray     #38                 // class java/lang/String
      72: astore        8
      74: aload         8
      76: iconst_0
      77: ldc           #42                 // String
      79: aastore
      80: aload         8
      82: iconst_0
      83: iconst_0
      84: bipush        6
      86: aconst_null
      87: invokestatic  #48                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      90: checkcast     #22                 // class java/lang/Iterable
      93: astore        8
      95: iconst_0
      96: istore        9
      98: aload         8
     100: astore        10
     102: new           #50                 // class java/util/ArrayList
     105: dup
     106: aload         8
     108: bipush        10
     110: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     113: invokespecial #59                 // Method java/util/ArrayList."<init>":(I)V
     116: checkcast     #61                 // class java/util/Collection
     119: astore        11
     121: iconst_0
     122: istore        12
     124: aload         10
     126: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     131: astore        13
     133: aload         13
     135: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     140: ifeq          187
     143: aload         13
     145: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     150: astore        14
     152: aload         11
     154: aload         14
     156: checkcast     #38                 // class java/lang/String
     159: astore        15
     161: astore        16
     163: iconst_0
     164: istore        17
     166: aload         15
     168: invokestatic  #67                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     171: nop
     172: invokestatic  #71                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     175: aload         16
     177: swap
     178: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     183: pop
     184: goto          133
     187: aload         11
     189: checkcast     #77                 // class java/util/List
     192: nop
     193: checkcast     #22                 // class java/lang/Iterable
     196: invokestatic  #81                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     199: astore        18
     201: new           #50                 // class java/util/ArrayList
     204: dup
     205: invokespecial #84                 // Method java/util/ArrayList."<init>":()V
     208: checkcast     #77                 // class java/util/List
     211: astore        8
     213: new           #50                 // class java/util/ArrayList
     216: dup
     217: invokespecial #84                 // Method java/util/ArrayList."<init>":()V
     220: checkcast     #77                 // class java/util/List
     223: astore        9
     225: iload_0
     226: iconst_1
     227: if_icmpne     406
     230: aload         18
     232: checkcast     #22                 // class java/lang/Iterable
     235: iconst_2
     236: iconst_0
     237: iconst_0
     238: bipush        6
     240: aconst_null
     241: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
     244: checkcast     #22                 // class java/lang/Iterable
     247: astore        10
     249: iconst_0
     250: istore        11
     252: aload         10
     254: astore        12
     256: new           #50                 // class java/util/ArrayList
     259: dup
     260: aload         10
     262: bipush        10
     264: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     267: invokespecial #59                 // Method java/util/ArrayList."<init>":(I)V
     270: checkcast     #61                 // class java/util/Collection
     273: astore        13
     275: iconst_0
     276: istore        14
     278: aload         12
     280: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     285: astore        15
     287: aload         15
     289: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     294: ifeq          364
     297: aload         15
     299: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     304: astore        17
     306: aload         13
     308: aload         17
     310: checkcast     #77                 // class java/util/List
     313: astore        19
     315: astore        16
     317: iconst_0
     318: istore        20
     320: aload         19
     322: iconst_1
     323: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     328: checkcast     #94                 // class java/lang/Number
     331: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     334: aload         19
     336: iconst_0
     337: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     342: checkcast     #94                 // class java/lang/Number
     345: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     348: lsub
     349: invokestatic  #71                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     352: aload         16
     354: swap
     355: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     360: pop
     361: goto          287
     364: aload         13
     366: checkcast     #77                 // class java/util/List
     369: nop
     370: checkcast     #61                 // class java/util/Collection
     373: invokestatic  #102                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     376: astore        9
     378: aload         8
     380: aload         18
     382: invokestatic  #106                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     385: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     390: pop
     391: aload         8
     393: aload         9
     395: invokestatic  #106                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     398: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     403: goto          579
     406: aload         18
     408: checkcast     #22                 // class java/lang/Iterable
     411: iconst_2
     412: iconst_0
     413: iconst_0
     414: bipush        6
     416: aconst_null
     417: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
     420: checkcast     #22                 // class java/lang/Iterable
     423: astore        10
     425: iconst_0
     426: istore        11
     428: aload         10
     430: astore        12
     432: new           #50                 // class java/util/ArrayList
     435: dup
     436: aload         10
     438: bipush        10
     440: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     443: invokespecial #59                 // Method java/util/ArrayList."<init>":(I)V
     446: checkcast     #61                 // class java/util/Collection
     449: astore        13
     451: iconst_0
     452: istore        14
     454: aload         12
     456: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     461: astore        15
     463: aload         15
     465: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     470: ifeq          540
     473: aload         15
     475: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     480: astore        17
     482: aload         13
     484: aload         17
     486: checkcast     #77                 // class java/util/List
     489: astore        19
     491: astore        16
     493: iconst_0
     494: istore        20
     496: aload         19
     498: iconst_0
     499: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     504: checkcast     #94                 // class java/lang/Number
     507: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     510: aload         19
     512: iconst_1
     513: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     518: checkcast     #94                 // class java/lang/Number
     521: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     524: lsub
     525: invokestatic  #71                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     528: aload         16
     530: swap
     531: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     536: pop
     537: goto          463
     540: aload         13
     542: checkcast     #77                 // class java/util/List
     545: nop
     546: checkcast     #61                 // class java/util/Collection
     549: invokestatic  #102                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     552: astore        9
     554: aload         8
     556: aload         18
     558: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     561: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     566: pop
     567: aload         8
     569: aload         9
     571: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     574: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     579: pop
     580: aload         9
     582: checkcast     #22                 // class java/lang/Iterable
     585: invokestatic  #113                // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;
     588: invokeinterface #117,  1          // InterfaceMethod java/util/List.size:()I
     593: iconst_1
     594: if_icmpgt     616
     597: aload         9
     599: iconst_0
     600: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     605: checkcast     #94                 // class java/lang/Number
     608: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     611: lconst_0
     612: lcmp
     613: ifeq          948
     616: iload_0
     617: iconst_1
     618: if_icmpne     784
     621: aload         9
     623: checkcast     #22                 // class java/lang/Iterable
     626: iconst_2
     627: iconst_0
     628: iconst_0
     629: bipush        6
     631: aconst_null
     632: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
     635: checkcast     #22                 // class java/lang/Iterable
     638: astore        10
     640: iconst_0
     641: istore        11
     643: aload         10
     645: astore        12
     647: new           #50                 // class java/util/ArrayList
     650: dup
     651: aload         10
     653: bipush        10
     655: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     658: invokespecial #59                 // Method java/util/ArrayList."<init>":(I)V
     661: checkcast     #61                 // class java/util/Collection
     664: astore        13
     666: iconst_0
     667: istore        14
     669: aload         12
     671: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     676: astore        15
     678: aload         15
     680: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     685: ifeq          755
     688: aload         15
     690: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     695: astore        17
     697: aload         13
     699: aload         17
     701: checkcast     #77                 // class java/util/List
     704: astore        19
     706: astore        16
     708: iconst_0
     709: istore        20
     711: aload         19
     713: iconst_1
     714: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     719: checkcast     #94                 // class java/lang/Number
     722: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     725: aload         19
     727: iconst_0
     728: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     733: checkcast     #94                 // class java/lang/Number
     736: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     739: lsub
     740: invokestatic  #71                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     743: aload         16
     745: swap
     746: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     751: pop
     752: goto          678
     755: aload         13
     757: checkcast     #77                 // class java/util/List
     760: nop
     761: checkcast     #61                 // class java/util/Collection
     764: invokestatic  #102                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     767: astore        9
     769: aload         8
     771: aload         9
     773: invokestatic  #106                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     776: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     781: goto          944
     784: aload         9
     786: checkcast     #22                 // class java/lang/Iterable
     789: iconst_2
     790: iconst_0
     791: iconst_0
     792: bipush        6
     794: aconst_null
     795: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
     798: checkcast     #22                 // class java/lang/Iterable
     801: astore        10
     803: iconst_0
     804: istore        11
     806: aload         10
     808: astore        12
     810: new           #50                 // class java/util/ArrayList
     813: dup
     814: aload         10
     816: bipush        10
     818: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     821: invokespecial #59                 // Method java/util/ArrayList."<init>":(I)V
     824: checkcast     #61                 // class java/util/Collection
     827: astore        13
     829: iconst_0
     830: istore        14
     832: aload         12
     834: invokeinterface #26,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     839: astore        15
     841: aload         15
     843: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     848: ifeq          918
     851: aload         15
     853: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     858: astore        17
     860: aload         13
     862: aload         17
     864: checkcast     #77                 // class java/util/List
     867: astore        19
     869: astore        16
     871: iconst_0
     872: istore        20
     874: aload         19
     876: iconst_0
     877: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     882: checkcast     #94                 // class java/lang/Number
     885: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     888: aload         19
     890: iconst_1
     891: invokeinterface #92,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     896: checkcast     #94                 // class java/lang/Number
     899: invokevirtual #98                 // Method java/lang/Number.longValue:()J
     902: lsub
     903: invokestatic  #71                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     906: aload         16
     908: swap
     909: invokeinterface #75,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     914: pop
     915: goto          841
     918: aload         13
     920: checkcast     #77                 // class java/util/List
     923: nop
     924: checkcast     #61                 // class java/util/Collection
     927: invokestatic  #102                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     930: astore        9
     932: aload         8
     934: aload         9
     936: invokestatic  #110                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     939: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     944: pop
     945: goto          580
     948: lload         21
     950: aload         8
     952: checkcast     #22                 // class java/lang/Iterable
     955: invokestatic  #121                // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     958: ladd
     959: lstore        21
     961: nop
     962: nop
     963: goto          34
     966: nop
     967: lload         21
     969: lreturn

  public static final void main();
    Code:
       0: invokestatic  #156                // Method java/lang/System.currentTimeMillis:()J
       3: lstore_0
       4: iconst_1
       5: invokestatic  #158                // Method day09:(I)J
       8: lstore_2
       9: iconst_2
      10: invokestatic  #158                // Method day09:(I)J
      13: lstore        4
      15: ldc           #160                // String *******************************
      17: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
      20: swap
      21: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      24: ldc           #172                // String --- Day 9: Mirage Maintenance ---
      26: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
      29: swap
      30: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      33: ldc           #160                // String *******************************
      35: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
      38: swap
      39: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      42: ldc           #174                // String Solution for part1
      44: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
      47: swap
      48: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      51: new           #176                // class java/lang/StringBuilder
      54: dup
      55: invokespecial #177                // Method java/lang/StringBuilder."<init>":()V
      58: ldc           #179                // String
      60: invokevirtual #183                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      63: lload_2
      64: invokevirtual #186                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      67: bipush        32
      69: invokevirtual #189                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      72: invokevirtual #193                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      75: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
      78: swap
      79: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      82: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
      85: invokevirtual #195                // Method java/io/PrintStream.println:()V
      88: ldc           #160                // String *******************************
      90: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
      93: swap
      94: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      97: ldc           #197                // String Solution for part2
      99: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
     102: swap
     103: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     106: new           #176                // class java/lang/StringBuilder
     109: dup
     110: invokespecial #177                // Method java/lang/StringBuilder."<init>":()V
     113: ldc           #179                // String
     115: invokevirtual #183                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     118: lload         4
     120: invokevirtual #186                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     123: bipush        32
     125: invokevirtual #189                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     128: invokevirtual #193                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     131: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
     134: swap
     135: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     138: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
     141: invokevirtual #195                // Method java/io/PrintStream.println:()V
     144: invokestatic  #156                // Method java/lang/System.currentTimeMillis:()J
     147: lload_0
     148: lsub
     149: lstore_0
     150: new           #176                // class java/lang/StringBuilder
     153: dup
     154: invokespecial #177                // Method java/lang/StringBuilder."<init>":()V
     157: ldc           #199                // String puzzle solved in
     159: invokevirtual #183                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     162: lload_0
     163: invokevirtual #186                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     166: ldc           #201                // String  ms
     168: invokevirtual #183                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     171: invokevirtual #193                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     174: getstatic     #164                // Field java/lang/System.out:Ljava/io/PrintStream;
     177: swap
     178: invokevirtual #170                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     181: return

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


import java.io.File
import kotlin.math.*

fun fertilizer(): Long {
	var locationList = mutableListOf<Long>()
	var newLocationList = mutableListOf<Long>()

	File("day2305_puzzle_input.txt").forEachLine {
		if (it.contains("seeds: ")) {
			locationList = it.substringAfter("seeds: ").split(" ").map { it.toLong() }.toMutableList()
			newLocationList = it.substringAfter("seeds: ").split(" ").map { it.toLong() }.toMutableList()
		}

		if (it.length != 0 && it.first().isDigit()) {
			var convertInstruction = it.split(" ")
			var range =
				LongRange(
					convertInstruction[1].toLong(),
					convertInstruction[1].toLong() + convertInstruction[2].toLong() - 1
				)
			for (i in 0..locationList.size - 1) {
				if (range.contains(locationList[i])) {
					newLocationList[i] =
						locationList[i] - convertInstruction[1].toLong() + convertInstruction[0].toLong()
				}
			}
		}
		if (it.length == 0) {
			locationList.clear()
			locationList.addAll(newLocationList)
			//println (newLocationList)
		}
	}

	return newLocationList.min()!!
}

fun main() {
	var t1 = System.currentTimeMillis()

	var solution1 = fertilizer()

	// part 2 brutal force - takes 2 days
	var solution2: Long = -1
	var instruction = File("day2305_puzzle_input.txt").readLines()
	var seeds = instruction[0]
	var seedRanges = seeds.substringAfter("seeds: ").split(" ").map { it.toLong() }.toList()

	seedRanges.chunked(2).forEach {
		var i: Long = 0
		while (i < it.last()) {

			var location: Long = it.first() + i
			var newLocation: Long = location
			instruction.forEach {

				if (it.length != 0 && it.first().isDigit()) {
					var convertInstruction = it.split(" ")
					var range =
						LongRange(
							convertInstruction[1].toLong(),
							convertInstruction[1].toLong() + convertInstruction[2].toLong() - 1
						)
					if (range.contains(location)) {
						newLocation = location - convertInstruction[1].toLong() + convertInstruction[0].toLong()
					}

				}
				if (it.length == 0) {
					location = newLocation
				}
			}

			var x = newLocation
			if (x < solution2 || solution2 < 0) solution2 = x
			i += 1
		}
	}

// print solution for part 1
	println("*******************************")
	println("--- Day 5: If You Give A Seed A Fertilizer ---")
	println("*******************************")
	println("Solution for part1")
	println("   $solution1 is the lowest location number that corresponds to any of the initial seed numbers")
	println()
// print solution for part 2
	println("*******************************")
	println("Solution for part2")
	println("   $solution2 is the lowest location number that corresponds to any of the initial seed numbers")
	println()

	t1 = System.currentTimeMillis() - t1
	println("puzzle solved in ${t1} ms")
}

Compiled from "day2305_1_2.kt"
public final class Day2305_1_2Kt {
  public static final long fertilizer();
    Code:
       0: new           #8                  // class kotlin/jvm/internal/Ref$ObjectRef
       3: dup
       4: invokespecial #12                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
       7: astore_0
       8: aload_0
       9: new           #14                 // class java/util/ArrayList
      12: dup
      13: invokespecial #15                 // Method java/util/ArrayList."<init>":()V
      16: checkcast     #17                 // class java/util/List
      19: putfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      22: new           #8                  // class kotlin/jvm/internal/Ref$ObjectRef
      25: dup
      26: invokespecial #12                 // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
      29: astore_1
      30: aload_1
      31: new           #14                 // class java/util/ArrayList
      34: dup
      35: invokespecial #15                 // Method java/util/ArrayList."<init>":()V
      38: checkcast     #17                 // class java/util/List
      41: putfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      44: new           #23                 // class java/io/File
      47: dup
      48: ldc           #25                 // String day2305_puzzle_input.txt
      50: invokespecial #28                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      53: aconst_null
      54: aload_0
      55: aload_1
      56: invokedynamic #48,  0             // InvokeDynamic #0:invoke:(Lkotlin/jvm/internal/Ref$ObjectRef;Lkotlin/jvm/internal/Ref$ObjectRef;)Lkotlin/jvm/functions/Function1;
      61: iconst_1
      62: aconst_null
      63: invokestatic  #54                 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
      66: aload_1
      67: getfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      70: checkcast     #56                 // class java/lang/Iterable
      73: invokestatic  #62                 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
      76: dup
      77: invokestatic  #68                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      80: checkcast     #70                 // class java/lang/Number
      83: invokevirtual #73                 // Method java/lang/Number.longValue:()J
      86: lreturn

  public static final void main();
    Code:
       0: invokestatic  #82                 // Method java/lang/System.currentTimeMillis:()J
       3: lstore_0
       4: invokestatic  #84                 // Method fertilizer:()J
       7: lstore_2
       8: lconst_0
       9: lstore        27
      11: ldc2_w        #85                 // long -1l
      14: lstore        27
      16: aconst_null
      17: astore        4
      19: new           #23                 // class java/io/File
      22: dup
      23: ldc           #25                 // String day2305_puzzle_input.txt
      25: invokespecial #28                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      28: aconst_null
      29: iconst_1
      30: aconst_null
      31: invokestatic  #90                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      34: astore        4
      36: aload         4
      38: iconst_0
      39: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      44: checkcast     #96                 // class java/lang/String
      47: astore        5
      49: aload         5
      51: ldc           #98                 // String seeds:
      53: aconst_null
      54: iconst_2
      55: aconst_null
      56: invokestatic  #104                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      59: checkcast     #106                // class java/lang/CharSequence
      62: iconst_1
      63: anewarray     #96                 // class java/lang/String
      66: astore        7
      68: aload         7
      70: iconst_0
      71: ldc           #108                // String
      73: aastore
      74: aload         7
      76: iconst_0
      77: iconst_0
      78: bipush        6
      80: aconst_null
      81: invokestatic  #112                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      84: checkcast     #56                 // class java/lang/Iterable
      87: astore        7
      89: iconst_0
      90: istore        8
      92: aload         7
      94: astore        9
      96: new           #14                 // class java/util/ArrayList
      99: dup
     100: aload         7
     102: bipush        10
     104: invokestatic  #116                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     107: invokespecial #119                // Method java/util/ArrayList."<init>":(I)V
     110: checkcast     #121                // class java/util/Collection
     113: astore        10
     115: iconst_0
     116: istore        11
     118: aload         9
     120: invokeinterface #125,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     125: astore        12
     127: aload         12
     129: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     134: ifeq          181
     137: aload         12
     139: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     144: astore        13
     146: aload         10
     148: aload         13
     150: checkcast     #96                 // class java/lang/String
     153: astore        14
     155: astore        26
     157: iconst_0
     158: istore        15
     160: aload         14
     162: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     165: nop
     166: invokestatic  #145                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     169: aload         26
     171: swap
     172: invokeinterface #149,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     177: pop
     178: goto          127
     181: aload         10
     183: checkcast     #17                 // class java/util/List
     186: nop
     187: checkcast     #56                 // class java/lang/Iterable
     190: invokestatic  #153                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     193: astore        6
     195: aload         6
     197: checkcast     #56                 // class java/lang/Iterable
     200: iconst_2
     201: invokestatic  #157                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
     204: checkcast     #56                 // class java/lang/Iterable
     207: astore        7
     209: iconst_0
     210: istore        8
     212: aload         7
     214: invokeinterface #125,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     219: astore        9
     221: aload         9
     223: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     228: ifeq          548
     231: aload         9
     233: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     238: astore        10
     240: aload         10
     242: checkcast     #17                 // class java/util/List
     245: astore        11
     247: iconst_0
     248: istore        12
     250: lconst_0
     251: lstore        13
     253: lload         13
     255: aload         11
     257: invokestatic  #161                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     260: checkcast     #70                 // class java/lang/Number
     263: invokevirtual #73                 // Method java/lang/Number.longValue:()J
     266: lcmp
     267: ifge          543
     270: lconst_0
     271: lstore        29
     273: aload         11
     275: invokestatic  #164                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     278: checkcast     #70                 // class java/lang/Number
     281: invokevirtual #73                 // Method java/lang/Number.longValue:()J
     284: lload         13
     286: ladd
     287: lstore        29
     289: lconst_0
     290: lstore        31
     292: lload         29
     294: lstore        31
     296: aload         4
     298: checkcast     #56                 // class java/lang/Iterable
     301: astore        16
     303: iconst_0
     304: istore        17
     306: aload         16
     308: invokeinterface #125,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     313: astore        18
     315: aload         18
     317: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     322: ifeq          510
     325: aload         18
     327: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     332: astore        19
     334: aload         19
     336: checkcast     #96                 // class java/lang/String
     339: astore        20
     341: iconst_0
     342: istore        21
     344: aload         20
     346: invokevirtual #168                // Method java/lang/String.length:()I
     349: ifeq          493
     352: aload         20
     354: checkcast     #106                // class java/lang/CharSequence
     357: invokestatic  #171                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     360: invokestatic  #177                // Method java/lang/Character.isDigit:(C)Z
     363: ifeq          493
     366: aload         20
     368: checkcast     #106                // class java/lang/CharSequence
     371: iconst_1
     372: anewarray     #96                 // class java/lang/String
     375: astore        22
     377: aload         22
     379: iconst_0
     380: ldc           #108                // String
     382: aastore
     383: aload         22
     385: iconst_0
     386: iconst_0
     387: bipush        6
     389: aconst_null
     390: invokestatic  #112                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     393: astore        23
     395: new           #179                // class kotlin/ranges/LongRange
     398: dup
     399: aload         23
     401: iconst_1
     402: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     407: checkcast     #96                 // class java/lang/String
     410: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     413: aload         23
     415: iconst_1
     416: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     421: checkcast     #96                 // class java/lang/String
     424: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     427: aload         23
     429: iconst_2
     430: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     435: checkcast     #96                 // class java/lang/String
     438: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     441: ladd
     442: lconst_1
     443: lsub
     444: invokespecial #182                // Method kotlin/ranges/LongRange."<init>":(JJ)V
     447: astore        22
     449: aload         22
     451: lload         29
     453: invokevirtual #186                // Method kotlin/ranges/LongRange.contains:(J)Z
     456: ifeq          493
     459: lload         29
     461: aload         23
     463: iconst_1
     464: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     469: checkcast     #96                 // class java/lang/String
     472: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     475: lsub
     476: aload         23
     478: iconst_0
     479: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     484: checkcast     #96                 // class java/lang/String
     487: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     490: ladd
     491: lstore        31
     493: aload         20
     495: invokevirtual #168                // Method java/lang/String.length:()I
     498: ifne          505
     501: lload         31
     503: lstore        29
     505: nop
     506: nop
     507: goto          315
     510: nop
     511: lload         31
     513: lstore        24
     515: lload         24
     517: lload         27
     519: lcmp
     520: iflt          530
     523: lload         27
     525: lconst_0
     526: lcmp
     527: ifge          534
     530: lload         24
     532: lstore        27
     534: lload         13
     536: lconst_1
     537: ladd
     538: lstore        13
     540: goto          253
     543: nop
     544: nop
     545: goto          221
     548: nop
     549: ldc           #188                // String *******************************
     551: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     554: swap
     555: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     558: ldc           #199                // String --- Day 5: If You Give A Seed A Fertilizer ---
     560: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     563: swap
     564: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     567: ldc           #188                // String *******************************
     569: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     572: swap
     573: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     576: ldc           #201                // String Solution for part1
     578: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     581: swap
     582: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     585: new           #203                // class java/lang/StringBuilder
     588: dup
     589: invokespecial #204                // Method java/lang/StringBuilder."<init>":()V
     592: ldc           #206                // String
     594: invokevirtual #210                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     597: lload_2
     598: invokevirtual #213                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     601: ldc           #215                // String  is the lowest location number that corresponds to any of the initial seed numbers
     603: invokevirtual #210                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     606: invokevirtual #219                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     609: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     612: swap
     613: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     616: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     619: invokevirtual #221                // Method java/io/PrintStream.println:()V
     622: ldc           #188                // String *******************************
     624: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     627: swap
     628: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     631: ldc           #223                // String Solution for part2
     633: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     636: swap
     637: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     640: new           #203                // class java/lang/StringBuilder
     643: dup
     644: invokespecial #204                // Method java/lang/StringBuilder."<init>":()V
     647: ldc           #206                // String
     649: invokevirtual #210                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     652: lload         27
     654: invokevirtual #213                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     657: ldc           #215                // String  is the lowest location number that corresponds to any of the initial seed numbers
     659: invokevirtual #210                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     662: invokevirtual #219                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     665: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     668: swap
     669: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     672: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     675: invokevirtual #221                // Method java/io/PrintStream.println:()V
     678: invokestatic  #82                 // Method java/lang/System.currentTimeMillis:()J
     681: lload_0
     682: lsub
     683: lstore_0
     684: new           #203                // class java/lang/StringBuilder
     687: dup
     688: invokespecial #204                // Method java/lang/StringBuilder."<init>":()V
     691: ldc           #225                // String puzzle solved in
     693: invokevirtual #210                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     696: lload_0
     697: invokevirtual #213                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     700: ldc           #227                // String  ms
     702: invokevirtual #210                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     705: invokevirtual #219                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     708: getstatic     #192                // Field java/lang/System.out:Ljava/io/PrintStream;
     711: swap
     712: invokevirtual #197                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     715: return

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

  private static final kotlin.Unit fertilizer$lambda$2(kotlin.jvm.internal.Ref$ObjectRef, kotlin.jvm.internal.Ref$ObjectRef, java.lang.String);
    Code:
       0: aload_2
       1: ldc_w         #265                // String it
       4: invokestatic  #269                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_2
       8: checkcast     #106                // class java/lang/CharSequence
      11: ldc           #98                 // String seeds:
      13: checkcast     #106                // class java/lang/CharSequence
      16: iconst_0
      17: iconst_2
      18: aconst_null
      19: invokestatic  #273                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
      22: ifeq          317
      25: aload_0
      26: aload_2
      27: ldc           #98                 // String seeds:
      29: aconst_null
      30: iconst_2
      31: aconst_null
      32: invokestatic  #104                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      35: checkcast     #106                // class java/lang/CharSequence
      38: iconst_1
      39: anewarray     #96                 // class java/lang/String
      42: astore_3
      43: aload_3
      44: iconst_0
      45: ldc           #108                // String
      47: aastore
      48: aload_3
      49: iconst_0
      50: iconst_0
      51: bipush        6
      53: aconst_null
      54: invokestatic  #112                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      57: checkcast     #56                 // class java/lang/Iterable
      60: astore_3
      61: astore        12
      63: iconst_0
      64: istore        4
      66: aload_3
      67: astore        5
      69: new           #14                 // class java/util/ArrayList
      72: dup
      73: aload_3
      74: bipush        10
      76: invokestatic  #116                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      79: invokespecial #119                // Method java/util/ArrayList."<init>":(I)V
      82: checkcast     #121                // class java/util/Collection
      85: astore        6
      87: iconst_0
      88: istore        7
      90: aload         5
      92: invokeinterface #125,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      97: astore        8
      99: aload         8
     101: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     106: ifeq          153
     109: aload         8
     111: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     116: astore        9
     118: aload         6
     120: aload         9
     122: checkcast     #96                 // class java/lang/String
     125: astore        10
     127: astore        13
     129: iconst_0
     130: istore        11
     132: aload         10
     134: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     137: nop
     138: invokestatic  #145                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     141: aload         13
     143: swap
     144: invokeinterface #149,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     149: pop
     150: goto          99
     153: aload         6
     155: checkcast     #17                 // class java/util/List
     158: nop
     159: aload         12
     161: swap
     162: checkcast     #121                // class java/util/Collection
     165: invokestatic  #277                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     168: putfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     171: aload_1
     172: aload_2
     173: ldc           #98                 // String seeds:
     175: aconst_null
     176: iconst_2
     177: aconst_null
     178: invokestatic  #104                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     181: checkcast     #106                // class java/lang/CharSequence
     184: iconst_1
     185: anewarray     #96                 // class java/lang/String
     188: astore_3
     189: aload_3
     190: iconst_0
     191: ldc           #108                // String
     193: aastore
     194: aload_3
     195: iconst_0
     196: iconst_0
     197: bipush        6
     199: aconst_null
     200: invokestatic  #112                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     203: checkcast     #56                 // class java/lang/Iterable
     206: astore_3
     207: astore        12
     209: iconst_0
     210: istore        4
     212: aload_3
     213: astore        5
     215: new           #14                 // class java/util/ArrayList
     218: dup
     219: aload_3
     220: bipush        10
     222: invokestatic  #116                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     225: invokespecial #119                // Method java/util/ArrayList."<init>":(I)V
     228: checkcast     #121                // class java/util/Collection
     231: astore        6
     233: iconst_0
     234: istore        7
     236: aload         5
     238: invokeinterface #125,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     243: astore        8
     245: aload         8
     247: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     252: ifeq          299
     255: aload         8
     257: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     262: astore        9
     264: aload         6
     266: aload         9
     268: checkcast     #96                 // class java/lang/String
     271: astore        10
     273: astore        13
     275: iconst_0
     276: istore        11
     278: aload         10
     280: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     283: nop
     284: invokestatic  #145                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     287: aload         13
     289: swap
     290: invokeinterface #149,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     295: pop
     296: goto          245
     299: aload         6
     301: checkcast     #17                 // class java/util/List
     304: nop
     305: aload         12
     307: swap
     308: checkcast     #121                // class java/util/Collection
     311: invokestatic  #277                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     314: putfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     317: aload_2
     318: invokevirtual #168                // Method java/lang/String.length:()I
     321: ifeq          539
     324: aload_2
     325: checkcast     #106                // class java/lang/CharSequence
     328: invokestatic  #171                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     331: invokestatic  #177                // Method java/lang/Character.isDigit:(C)Z
     334: ifeq          539
     337: aload_2
     338: checkcast     #106                // class java/lang/CharSequence
     341: iconst_1
     342: anewarray     #96                 // class java/lang/String
     345: astore        4
     347: aload         4
     349: iconst_0
     350: ldc           #108                // String
     352: aastore
     353: aload         4
     355: iconst_0
     356: iconst_0
     357: bipush        6
     359: aconst_null
     360: invokestatic  #112                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     363: astore_3
     364: new           #179                // class kotlin/ranges/LongRange
     367: dup
     368: aload_3
     369: iconst_1
     370: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     375: checkcast     #96                 // class java/lang/String
     378: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     381: aload_3
     382: iconst_1
     383: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     388: checkcast     #96                 // class java/lang/String
     391: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     394: aload_3
     395: iconst_2
     396: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     401: checkcast     #96                 // class java/lang/String
     404: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     407: ladd
     408: lconst_1
     409: lsub
     410: invokespecial #182                // Method kotlin/ranges/LongRange."<init>":(JJ)V
     413: astore        4
     415: iconst_0
     416: istore        5
     418: aload_0
     419: getfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     422: checkcast     #17                 // class java/util/List
     425: invokeinterface #280,  1          // InterfaceMethod java/util/List.size:()I
     430: istore        6
     432: iload         5
     434: iload         6
     436: if_icmpge     539
     439: aload         4
     441: aload_0
     442: getfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     445: checkcast     #17                 // class java/util/List
     448: iload         5
     450: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     455: checkcast     #70                 // class java/lang/Number
     458: invokevirtual #73                 // Method java/lang/Number.longValue:()J
     461: invokevirtual #186                // Method kotlin/ranges/LongRange.contains:(J)Z
     464: ifeq          533
     467: aload_1
     468: getfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     471: checkcast     #17                 // class java/util/List
     474: iload         5
     476: aload_0
     477: getfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     480: checkcast     #17                 // class java/util/List
     483: iload         5
     485: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     490: checkcast     #70                 // class java/lang/Number
     493: invokevirtual #73                 // Method java/lang/Number.longValue:()J
     496: aload_3
     497: iconst_1
     498: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     503: checkcast     #96                 // class java/lang/String
     506: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     509: lsub
     510: aload_3
     511: iconst_0
     512: invokeinterface #94,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     517: checkcast     #96                 // class java/lang/String
     520: invokestatic  #141                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     523: ladd
     524: invokestatic  #145                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     527: invokeinterface #284,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     532: pop
     533: iinc          5, 1
     536: goto          432
     539: aload_2
     540: invokevirtual #168                // Method java/lang/String.length:()I
     543: ifne          578
     546: aload_0
     547: getfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     550: checkcast     #17                 // class java/util/List
     553: invokeinterface #287,  1          // InterfaceMethod java/util/List.clear:()V
     558: aload_0
     559: getfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     562: checkcast     #17                 // class java/util/List
     565: aload_1
     566: getfield      #21                 // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     569: checkcast     #121                // class java/util/Collection
     572: invokeinterface #291,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     577: pop
     578: getstatic     #297                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     581: areturn
}