import java.io.File
import kotlin.collections.*

class Position(var X:Int, var Y:Int)

fun moveTail(head:Position, tail:Position){
    if (head.X > tail.X + 1){
        tail.X++
        if (head.Y > tail.Y){
            tail.Y++
        }
        else if (head.Y < tail.Y){
            tail.Y--
        }
    }
    else if (head.X < tail.X - 1){
        tail.X--
        if (head.Y > tail.Y){
            tail.Y++
        }
        else if (head.Y < tail.Y){
            tail.Y--
        }
    }
    else if (head.Y > tail.Y + 1){
        tail.Y++
        if (head.X > tail.X){
            tail.X++
        }
        else if (head.X < tail.X){
            tail.X--
        }
    }
    else if (head.Y < tail.Y - 1 ){
        tail.Y--
        if (head.X > tail.X){
            tail.X++
        }
        else if (head.X < tail.X){
            tail.X--
        }
    }
}

fun Day09() {
    val input = File("src/input/day09.txt").readLines()

    var head = Position(500,500)
    var tailTask1 = Position(500,500)

    var tailsTask2 = ArrayList<Position>()
    tailsTask2.add(Position(500, 500))
    tailsTask2.add(Position(500, 500))
    tailsTask2.add(Position(500, 500))
    tailsTask2.add(Position(500, 500))
    tailsTask2.add(Position(500, 500))
    tailsTask2.add(Position(500, 500))
    tailsTask2.add(Position(500, 500))
    tailsTask2.add(Position(500, 500))
    tailsTask2.add(Position(500, 500))

    var visitedPositionsTask1 = ArrayList<String>()
    var visitedPositionsTask2 = ArrayList<String>()

    for(line in input){
        var instruction = line.split(" ")
        var direction = instruction[0]
        var times = instruction[1].toInt()

        for(i in 0..times-1 step 1){
            if (direction == "R"){
                head.X++
            }
            else if (direction == "L"){
                head.X--
            }
            else if (direction == "U"){
                head.Y++
            }
            else { // "D"
                head.Y--
            }

            moveTail(head, tailTask1)
            visitedPositionsTask1.add(tailTask1.X.toString() + tailTask1.Y.toString())

            var prevTail = head
            for(tailTask2 in tailsTask2){
                moveTail(prevTail, tailTask2)
                prevTail = tailTask2
            }

            visitedPositionsTask2.add(tailsTask2.last().X.toString() + tailsTask2.last().Y.toString())
       }
    }

    var task1 = visitedPositionsTask1.distinct().count()
    var task2 = visitedPositionsTask2.distinct().count()

    println("Day 9 Task 1: $task1") // 6563
    println("Day 9 Task 2: $task2") // 2653
}

Compiled from "Day09.kt"
public final class Day09Kt {
  public static final void moveTail(Position, Position);
    Code:
       0: aload_0
       1: ldc           #9                  // String head
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String tail
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokevirtual #23                 // Method Position.getX:()I
      16: aload_1
      17: invokevirtual #23                 // Method Position.getX:()I
      20: iconst_1
      21: iadd
      22: if_icmple     89
      25: aload_1
      26: invokevirtual #23                 // Method Position.getX:()I
      29: istore_2
      30: aload_1
      31: iload_2
      32: iconst_1
      33: iadd
      34: invokevirtual #27                 // Method Position.setX:(I)V
      37: aload_0
      38: invokevirtual #30                 // Method Position.getY:()I
      41: aload_1
      42: invokevirtual #30                 // Method Position.getY:()I
      45: if_icmple     63
      48: aload_1
      49: invokevirtual #30                 // Method Position.getY:()I
      52: istore_2
      53: aload_1
      54: iload_2
      55: iconst_1
      56: iadd
      57: invokevirtual #33                 // Method Position.setY:(I)V
      60: goto          317
      63: aload_0
      64: invokevirtual #30                 // Method Position.getY:()I
      67: aload_1
      68: invokevirtual #30                 // Method Position.getY:()I
      71: if_icmpge     317
      74: aload_1
      75: invokevirtual #30                 // Method Position.getY:()I
      78: istore_2
      79: aload_1
      80: iload_2
      81: iconst_m1
      82: iadd
      83: invokevirtual #33                 // Method Position.setY:(I)V
      86: goto          317
      89: aload_0
      90: invokevirtual #23                 // Method Position.getX:()I
      93: aload_1
      94: invokevirtual #23                 // Method Position.getX:()I
      97: iconst_1
      98: isub
      99: if_icmpge     166
     102: aload_1
     103: invokevirtual #23                 // Method Position.getX:()I
     106: istore_2
     107: aload_1
     108: iload_2
     109: iconst_m1
     110: iadd
     111: invokevirtual #27                 // Method Position.setX:(I)V
     114: aload_0
     115: invokevirtual #30                 // Method Position.getY:()I
     118: aload_1
     119: invokevirtual #30                 // Method Position.getY:()I
     122: if_icmple     140
     125: aload_1
     126: invokevirtual #30                 // Method Position.getY:()I
     129: istore_2
     130: aload_1
     131: iload_2
     132: iconst_1
     133: iadd
     134: invokevirtual #33                 // Method Position.setY:(I)V
     137: goto          317
     140: aload_0
     141: invokevirtual #30                 // Method Position.getY:()I
     144: aload_1
     145: invokevirtual #30                 // Method Position.getY:()I
     148: if_icmpge     317
     151: aload_1
     152: invokevirtual #30                 // Method Position.getY:()I
     155: istore_2
     156: aload_1
     157: iload_2
     158: iconst_m1
     159: iadd
     160: invokevirtual #33                 // Method Position.setY:(I)V
     163: goto          317
     166: aload_0
     167: invokevirtual #30                 // Method Position.getY:()I
     170: aload_1
     171: invokevirtual #30                 // Method Position.getY:()I
     174: iconst_1
     175: iadd
     176: if_icmple     243
     179: aload_1
     180: invokevirtual #30                 // Method Position.getY:()I
     183: istore_2
     184: aload_1
     185: iload_2
     186: iconst_1
     187: iadd
     188: invokevirtual #33                 // Method Position.setY:(I)V
     191: aload_0
     192: invokevirtual #23                 // Method Position.getX:()I
     195: aload_1
     196: invokevirtual #23                 // Method Position.getX:()I
     199: if_icmple     217
     202: aload_1
     203: invokevirtual #23                 // Method Position.getX:()I
     206: istore_2
     207: aload_1
     208: iload_2
     209: iconst_1
     210: iadd
     211: invokevirtual #27                 // Method Position.setX:(I)V
     214: goto          317
     217: aload_0
     218: invokevirtual #23                 // Method Position.getX:()I
     221: aload_1
     222: invokevirtual #23                 // Method Position.getX:()I
     225: if_icmpge     317
     228: aload_1
     229: invokevirtual #23                 // Method Position.getX:()I
     232: istore_2
     233: aload_1
     234: iload_2
     235: iconst_m1
     236: iadd
     237: invokevirtual #27                 // Method Position.setX:(I)V
     240: goto          317
     243: aload_0
     244: invokevirtual #30                 // Method Position.getY:()I
     247: aload_1
     248: invokevirtual #30                 // Method Position.getY:()I
     251: iconst_1
     252: isub
     253: if_icmpge     317
     256: aload_1
     257: invokevirtual #30                 // Method Position.getY:()I
     260: istore_2
     261: aload_1
     262: iload_2
     263: iconst_m1
     264: iadd
     265: invokevirtual #33                 // Method Position.setY:(I)V
     268: aload_0
     269: invokevirtual #23                 // Method Position.getX:()I
     272: aload_1
     273: invokevirtual #23                 // Method Position.getX:()I
     276: if_icmple     294
     279: aload_1
     280: invokevirtual #23                 // Method Position.getX:()I
     283: istore_2
     284: aload_1
     285: iload_2
     286: iconst_1
     287: iadd
     288: invokevirtual #27                 // Method Position.setX:(I)V
     291: goto          317
     294: aload_0
     295: invokevirtual #23                 // Method Position.getX:()I
     298: aload_1
     299: invokevirtual #23                 // Method Position.getX:()I
     302: if_icmpge     317
     305: aload_1
     306: invokevirtual #23                 // Method Position.getX:()I
     309: istore_2
     310: aload_1
     311: iload_2
     312: iconst_m1
     313: iadd
     314: invokevirtual #27                 // Method Position.setX:(I)V
     317: return

  public static final void Day09();
    Code:
       0: new           #38                 // class java/io/File
       3: dup
       4: ldc           #40                 // String src/input/day09.txt
       6: invokespecial #44                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #50                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_0
      16: new           #19                 // class Position
      19: dup
      20: sipush        500
      23: sipush        500
      26: invokespecial #53                 // Method Position."<init>":(II)V
      29: astore_1
      30: new           #19                 // class Position
      33: dup
      34: sipush        500
      37: sipush        500
      40: invokespecial #53                 // Method Position."<init>":(II)V
      43: astore_2
      44: new           #55                 // class java/util/ArrayList
      47: dup
      48: invokespecial #57                 // Method java/util/ArrayList."<init>":()V
      51: astore_3
      52: aload_3
      53: new           #19                 // class Position
      56: dup
      57: sipush        500
      60: sipush        500
      63: invokespecial #53                 // Method Position."<init>":(II)V
      66: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      69: pop
      70: aload_3
      71: new           #19                 // class Position
      74: dup
      75: sipush        500
      78: sipush        500
      81: invokespecial #53                 // Method Position."<init>":(II)V
      84: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      87: pop
      88: aload_3
      89: new           #19                 // class Position
      92: dup
      93: sipush        500
      96: sipush        500
      99: invokespecial #53                 // Method Position."<init>":(II)V
     102: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     105: pop
     106: aload_3
     107: new           #19                 // class Position
     110: dup
     111: sipush        500
     114: sipush        500
     117: invokespecial #53                 // Method Position."<init>":(II)V
     120: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     123: pop
     124: aload_3
     125: new           #19                 // class Position
     128: dup
     129: sipush        500
     132: sipush        500
     135: invokespecial #53                 // Method Position."<init>":(II)V
     138: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     141: pop
     142: aload_3
     143: new           #19                 // class Position
     146: dup
     147: sipush        500
     150: sipush        500
     153: invokespecial #53                 // Method Position."<init>":(II)V
     156: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     159: pop
     160: aload_3
     161: new           #19                 // class Position
     164: dup
     165: sipush        500
     168: sipush        500
     171: invokespecial #53                 // Method Position."<init>":(II)V
     174: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     177: pop
     178: aload_3
     179: new           #19                 // class Position
     182: dup
     183: sipush        500
     186: sipush        500
     189: invokespecial #53                 // Method Position."<init>":(II)V
     192: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     195: pop
     196: aload_3
     197: new           #19                 // class Position
     200: dup
     201: sipush        500
     204: sipush        500
     207: invokespecial #53                 // Method Position."<init>":(II)V
     210: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     213: pop
     214: new           #55                 // class java/util/ArrayList
     217: dup
     218: invokespecial #57                 // Method java/util/ArrayList."<init>":()V
     221: astore        4
     223: new           #55                 // class java/util/ArrayList
     226: dup
     227: invokespecial #57                 // Method java/util/ArrayList."<init>":()V
     230: astore        5
     232: aload_0
     233: invokeinterface #67,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     238: astore        6
     240: aload         6
     242: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     247: ifeq          653
     250: aload         6
     252: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     257: checkcast     #79                 // class java/lang/String
     260: astore        7
     262: aload         7
     264: checkcast     #81                 // class java/lang/CharSequence
     267: iconst_1
     268: anewarray     #79                 // class java/lang/String
     271: astore        9
     273: aload         9
     275: iconst_0
     276: ldc           #83                 // String
     278: aastore
     279: aload         9
     281: iconst_0
     282: iconst_0
     283: bipush        6
     285: aconst_null
     286: invokestatic  #89                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     289: astore        8
     291: aload         8
     293: iconst_0
     294: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     299: checkcast     #79                 // class java/lang/String
     302: astore        9
     304: aload         8
     306: iconst_1
     307: invokeinterface #93,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     312: checkcast     #79                 // class java/lang/String
     315: invokestatic  #99                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     318: istore        10
     320: iconst_0
     321: istore        11
     323: iload         10
     325: iconst_1
     326: isub
     327: istore        12
     329: iload         11
     331: iload         12
     333: if_icmpgt     240
     336: aload         9
     338: invokevirtual #102                // Method java/lang/String.hashCode:()I
     341: lookupswitch  { // 3
                    76: 402
                    82: 376
                    85: 389
               default: 481
          }
     376: aload         9
     378: ldc           #104                // String R
     380: invokevirtual #107                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     383: ifne          415
     386: goto          481
     389: aload         9
     391: ldc           #109                // String U
     393: invokevirtual #107                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     396: ifne          459
     399: goto          481
     402: aload         9
     404: ldc           #111                // String L
     406: invokevirtual #107                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     409: ifne          437
     412: goto          481
     415: aload_1
     416: astore        13
     418: aload         13
     420: invokevirtual #23                 // Method Position.getX:()I
     423: istore        14
     425: aload         13
     427: iload         14
     429: iconst_1
     430: iadd
     431: invokevirtual #27                 // Method Position.setX:(I)V
     434: goto          500
     437: aload_1
     438: astore        13
     440: aload         13
     442: invokevirtual #23                 // Method Position.getX:()I
     445: istore        14
     447: aload         13
     449: iload         14
     451: iconst_m1
     452: iadd
     453: invokevirtual #27                 // Method Position.setX:(I)V
     456: goto          500
     459: aload_1
     460: astore        13
     462: aload         13
     464: invokevirtual #30                 // Method Position.getY:()I
     467: istore        14
     469: aload         13
     471: iload         14
     473: iconst_1
     474: iadd
     475: invokevirtual #33                 // Method Position.setY:(I)V
     478: goto          500
     481: aload_1
     482: astore        13
     484: aload         13
     486: invokevirtual #30                 // Method Position.getY:()I
     489: istore        14
     491: aload         13
     493: iload         14
     495: iconst_m1
     496: iadd
     497: invokevirtual #33                 // Method Position.setY:(I)V
     500: aload_1
     501: aload_2
     502: invokestatic  #113                // Method moveTail:(LPosition;LPosition;)V
     505: aload         4
     507: new           #115                // class java/lang/StringBuilder
     510: dup
     511: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     514: aload_2
     515: invokevirtual #23                 // Method Position.getX:()I
     518: invokevirtual #120                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     521: aload_2
     522: invokevirtual #30                 // Method Position.getY:()I
     525: invokevirtual #120                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     528: invokevirtual #124                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     531: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     534: pop
     535: aload_1
     536: astore        13
     538: aload_3
     539: invokevirtual #125                // Method java/util/ArrayList.iterator:()Ljava/util/Iterator;
     542: dup
     543: ldc           #127                // String iterator(...)
     545: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     548: astore        14
     550: aload         14
     552: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     557: ifeq          592
     560: aload         14
     562: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     567: dup
     568: ldc           #132                // String next(...)
     570: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     573: checkcast     #19                 // class Position
     576: astore        15
     578: aload         13
     580: aload         15
     582: invokestatic  #113                // Method moveTail:(LPosition;LPosition;)V
     585: aload         15
     587: astore        13
     589: goto          550
     592: aload         5
     594: new           #115                // class java/lang/StringBuilder
     597: dup
     598: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     601: aload_3
     602: checkcast     #63                 // class java/util/List
     605: invokestatic  #138                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     608: checkcast     #19                 // class Position
     611: invokevirtual #23                 // Method Position.getX:()I
     614: invokevirtual #120                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     617: aload_3
     618: checkcast     #63                 // class java/util/List
     621: invokestatic  #138                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     624: checkcast     #19                 // class Position
     627: invokevirtual #30                 // Method Position.getY:()I
     630: invokevirtual #120                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     633: invokevirtual #124                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     636: invokevirtual #61                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     639: pop
     640: iload         11
     642: iload         12
     644: if_icmpeq     240
     647: iinc          11, 1
     650: goto          336
     653: aload         4
     655: checkcast     #140                // class java/lang/Iterable
     658: invokestatic  #144                // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;
     661: checkcast     #146                // class java/util/Collection
     664: invokeinterface #149,  1          // InterfaceMethod java/util/Collection.size:()I
     669: istore        6
     671: aload         5
     673: checkcast     #140                // class java/lang/Iterable
     676: invokestatic  #144                // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;
     679: checkcast     #146                // class java/util/Collection
     682: invokeinterface #149,  1          // InterfaceMethod java/util/Collection.size:()I
     687: istore        7
     689: new           #115                // class java/lang/StringBuilder
     692: dup
     693: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     696: ldc           #151                // String Day 9 Task 1:
     698: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     701: iload         6
     703: invokevirtual #120                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     706: invokevirtual #124                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     709: getstatic     #160                // Field java/lang/System.out:Ljava/io/PrintStream;
     712: swap
     713: invokevirtual #166                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     716: new           #115                // class java/lang/StringBuilder
     719: dup
     720: invokespecial #116                // Method java/lang/StringBuilder."<init>":()V
     723: ldc           #168                // String Day 9 Task 2:
     725: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     728: iload         7
     730: invokevirtual #120                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     733: invokevirtual #124                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     736: getstatic     #160                // Field java/lang/System.out:Ljava/io/PrintStream;
     739: swap
     740: invokevirtual #166                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     743: return
}


import java.io.File
import kotlin.collections.*

fun getViewingScore(height:Int, trees:List<Int>):Int{
    var viewingScore = 0
    for (tree in trees){
        viewingScore++
        if (tree >= height){
            break;
        }
    }

    return viewingScore;
}

fun Day08() {
    val input = File("src/input/day08.txt").readLines()
    var forest = input.map { treeLine -> treeLine.map { tree -> Integer.parseInt("" + tree) }}

    var task1 = 0
    var task2 = 0
    for (i in 0..forest.size-1 step 1){
        var treeLine = forest[i]
        for (j in 0..treeLine.size-1 step 1){
            val treeHeight = treeLine[j]

            // Check right
            var treesToRight = treeLine.subList(j+1, treeLine.size)
            var viewingscoreRight = getViewingScore(treeHeight, treesToRight)

            // Check left
            var treesToLeft = treeLine.subList(0, j).reversed()
            var viewingscoreLeft = getViewingScore(treeHeight, treesToLeft)

            // Check down
            var treesToDown = forest.subList(i+1, forest.size).map { it -> it.get(j) }
            var viewingscoreDown = getViewingScore(treeHeight, treesToDown)

            // Check up
            var treesToUp = forest.subList(0, i).map { it -> it.get(j) }.reversed()
            var viewingscoreUp = getViewingScore(treeHeight, treesToUp)

            val visible = !treesToRight.any { it -> it >= treeHeight }
            || !treesToLeft.any { it -> it >= treeHeight }
            || !treesToUp.any { it -> it >= treeHeight }
            || !treesToDown.any { it -> it >= treeHeight }
            if (visible){
                task1++
            }

            var totalViewingScore = viewingscoreRight * viewingscoreLeft * viewingscoreDown * viewingscoreUp
            if (totalViewingScore > task2){
                task2 = totalViewingScore
            }
        }
    }

    println("Day 8 Task 1: $task1") //1794
    println("Day 8 Task 2: $task2") // 199272
}

Compiled from "Day08.kt"
public final class Day08Kt {
  public static final int getViewingScore(int, java.util.List<java.lang.Integer>);
    Code:
       0: aload_1
       1: ldc           #10                 // String trees
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_1
       9: invokeinterface #22,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      14: astore_3
      15: aload_3
      16: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      21: ifeq          50
      24: aload_3
      25: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      30: checkcast     #34                 // class java/lang/Number
      33: invokevirtual #38                 // Method java/lang/Number.intValue:()I
      36: istore        4
      38: iinc          2, 1
      41: iload         4
      43: iload_0
      44: if_icmplt     15
      47: goto          50
      50: iload_2
      51: ireturn

  public static final void Day08();
    Code:
       0: new           #47                 // class java/io/File
       3: dup
       4: ldc           #49                 // String src/input/day08.txt
       6: invokespecial #53                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #59                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_0
      16: aload_0
      17: checkcast     #61                 // class java/lang/Iterable
      20: astore_2
      21: iconst_0
      22: istore_3
      23: aload_2
      24: astore        4
      26: new           #63                 // class java/util/ArrayList
      29: dup
      30: aload_2
      31: bipush        10
      33: invokestatic  #69                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      36: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
      39: checkcast     #74                 // class java/util/Collection
      42: astore        5
      44: iconst_0
      45: istore        6
      47: aload         4
      49: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      54: astore        7
      56: aload         7
      58: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          222
      66: aload         7
      68: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      73: astore        8
      75: aload         5
      77: aload         8
      79: checkcast     #77                 // class java/lang/String
      82: astore        9
      84: astore        28
      86: iconst_0
      87: istore        10
      89: aload         9
      91: checkcast     #79                 // class java/lang/CharSequence
      94: astore        11
      96: iconst_0
      97: istore        12
      99: aload         11
     101: astore        13
     103: new           #63                 // class java/util/ArrayList
     106: dup
     107: aload         11
     109: invokeinterface #82,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     114: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
     117: checkcast     #74                 // class java/util/Collection
     120: astore        14
     122: iconst_0
     123: istore        15
     125: iconst_0
     126: istore        16
     128: iload         16
     130: aload         13
     132: invokeinterface #82,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     137: if_icmpge     203
     140: aload         13
     142: iload         16
     144: invokeinterface #86,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     149: istore        17
     151: aload         14
     153: iload         17
     155: istore        18
     157: astore        19
     159: iconst_0
     160: istore        20
     162: new           #88                 // class java/lang/StringBuilder
     165: dup
     166: invokespecial #90                 // Method java/lang/StringBuilder."<init>":()V
     169: ldc           #92                 // String
     171: invokevirtual #96                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     174: iload         18
     176: invokevirtual #99                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     179: invokevirtual #103                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     182: invokestatic  #109                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     185: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     188: aload         19
     190: swap
     191: invokeinterface #117,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     196: pop
     197: iinc          16, 1
     200: goto          128
     203: aload         14
     205: checkcast     #18                 // class java/util/List
     208: nop
     209: nop
     210: aload         28
     212: swap
     213: invokeinterface #117,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     218: pop
     219: goto          56
     222: aload         5
     224: checkcast     #18                 // class java/util/List
     227: nop
     228: astore_1
     229: iconst_0
     230: istore_2
     231: iconst_0
     232: istore_3
     233: iconst_0
     234: istore        4
     236: aload_1
     237: invokeinterface #120,  1          // InterfaceMethod java/util/List.size:()I
     242: iconst_1
     243: isub
     244: istore        5
     246: iload         4
     248: iload         5
     250: if_icmpgt     1098
     253: iload         4
     255: istore        6
     257: iinc          4, 1
     260: aload_1
     261: iload         6
     263: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     268: checkcast     #18                 // class java/util/List
     271: astore        7
     273: iconst_0
     274: istore        8
     276: aload         7
     278: invokeinterface #120,  1          // InterfaceMethod java/util/List.size:()I
     283: iconst_1
     284: isub
     285: istore        9
     287: iload         8
     289: iload         9
     291: if_icmpgt     1091
     294: iload         8
     296: istore        10
     298: iinc          8, 1
     301: aload         7
     303: iload         10
     305: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     310: checkcast     #34                 // class java/lang/Number
     313: invokevirtual #38                 // Method java/lang/Number.intValue:()I
     316: istore        11
     318: aload         7
     320: iload         10
     322: iconst_1
     323: iadd
     324: aload         7
     326: invokeinterface #120,  1          // InterfaceMethod java/util/List.size:()I
     331: invokeinterface #128,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     336: astore        12
     338: iload         11
     340: aload         12
     342: invokestatic  #130                // Method getViewingScore:(ILjava/util/List;)I
     345: istore        13
     347: aload         7
     349: iconst_0
     350: iload         10
     352: invokeinterface #128,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     357: checkcast     #61                 // class java/lang/Iterable
     360: invokestatic  #134                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     363: astore        14
     365: iload         11
     367: aload         14
     369: invokestatic  #130                // Method getViewingScore:(ILjava/util/List;)I
     372: istore        15
     374: aload_1
     375: iload         6
     377: iconst_1
     378: iadd
     379: aload_1
     380: invokeinterface #120,  1          // InterfaceMethod java/util/List.size:()I
     385: invokeinterface #128,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     390: checkcast     #61                 // class java/lang/Iterable
     393: astore        17
     395: iconst_0
     396: istore        18
     398: aload         17
     400: astore        19
     402: new           #63                 // class java/util/ArrayList
     405: dup
     406: aload         17
     408: bipush        10
     410: invokestatic  #69                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     413: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
     416: checkcast     #74                 // class java/util/Collection
     419: astore        20
     421: iconst_0
     422: istore        21
     424: aload         19
     426: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     431: astore        22
     433: aload         22
     435: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     440: ifeq          496
     443: aload         22
     445: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     450: astore        23
     452: aload         20
     454: aload         23
     456: checkcast     #18                 // class java/util/List
     459: astore        24
     461: astore        28
     463: iconst_0
     464: istore        25
     466: aload         24
     468: iload         10
     470: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     475: checkcast     #34                 // class java/lang/Number
     478: invokevirtual #38                 // Method java/lang/Number.intValue:()I
     481: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     484: aload         28
     486: swap
     487: invokeinterface #117,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     492: pop
     493: goto          433
     496: aload         20
     498: checkcast     #18                 // class java/util/List
     501: nop
     502: astore        16
     504: iload         11
     506: aload         16
     508: invokestatic  #130                // Method getViewingScore:(ILjava/util/List;)I
     511: istore        17
     513: aload_1
     514: iconst_0
     515: iload         6
     517: invokeinterface #128,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     522: checkcast     #61                 // class java/lang/Iterable
     525: astore        19
     527: iconst_0
     528: istore        20
     530: aload         19
     532: astore        21
     534: new           #63                 // class java/util/ArrayList
     537: dup
     538: aload         19
     540: bipush        10
     542: invokestatic  #69                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     545: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
     548: checkcast     #74                 // class java/util/Collection
     551: astore        22
     553: iconst_0
     554: istore        23
     556: aload         21
     558: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     563: astore        24
     565: aload         24
     567: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     572: ifeq          628
     575: aload         24
     577: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     582: astore        25
     584: aload         22
     586: aload         25
     588: checkcast     #18                 // class java/util/List
     591: astore        26
     593: astore        28
     595: iconst_0
     596: istore        27
     598: aload         26
     600: iload         10
     602: invokeinterface #124,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     607: checkcast     #34                 // class java/lang/Number
     610: invokevirtual #38                 // Method java/lang/Number.intValue:()I
     613: invokestatic  #113                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     616: aload         28
     618: swap
     619: invokeinterface #117,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     624: pop
     625: goto          565
     628: aload         22
     630: checkcast     #18                 // class java/util/List
     633: nop
     634: checkcast     #61                 // class java/lang/Iterable
     637: invokestatic  #134                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     640: astore        18
     642: iload         11
     644: aload         18
     646: invokestatic  #130                // Method getViewingScore:(ILjava/util/List;)I
     649: istore        19
     651: aload         12
     653: checkcast     #61                 // class java/lang/Iterable
     656: astore        21
     658: iconst_0
     659: istore        22
     661: aload         21
     663: instanceof    #74                 // class java/util/Collection
     666: ifeq          686
     669: aload         21
     671: checkcast     #74                 // class java/util/Collection
     674: invokeinterface #137,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     679: ifeq          686
     682: iconst_0
     683: goto          747
     686: aload         21
     688: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     693: astore        23
     695: aload         23
     697: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     702: ifeq          746
     705: aload         23
     707: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     712: astore        24
     714: aload         24
     716: checkcast     #34                 // class java/lang/Number
     719: invokevirtual #38                 // Method java/lang/Number.intValue:()I
     722: istore        25
     724: iconst_0
     725: istore        26
     727: iload         25
     729: iload         11
     731: if_icmplt     738
     734: iconst_1
     735: goto          739
     738: iconst_0
     739: ifeq          695
     742: iconst_1
     743: goto          747
     746: iconst_0
     747: ifeq          1047
     750: aload         14
     752: checkcast     #61                 // class java/lang/Iterable
     755: astore        21
     757: iconst_0
     758: istore        22
     760: aload         21
     762: instanceof    #74                 // class java/util/Collection
     765: ifeq          785
     768: aload         21
     770: checkcast     #74                 // class java/util/Collection
     773: invokeinterface #137,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     778: ifeq          785
     781: iconst_0
     782: goto          846
     785: aload         21
     787: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     792: astore        23
     794: aload         23
     796: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     801: ifeq          845
     804: aload         23
     806: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     811: astore        24
     813: aload         24
     815: checkcast     #34                 // class java/lang/Number
     818: invokevirtual #38                 // Method java/lang/Number.intValue:()I
     821: istore        25
     823: iconst_0
     824: istore        26
     826: iload         25
     828: iload         11
     830: if_icmplt     837
     833: iconst_1
     834: goto          838
     837: iconst_0
     838: ifeq          794
     841: iconst_1
     842: goto          846
     845: iconst_0
     846: ifeq          1047
     849: aload         18
     851: checkcast     #61                 // class java/lang/Iterable
     854: astore        21
     856: iconst_0
     857: istore        22
     859: aload         21
     861: instanceof    #74                 // class java/util/Collection
     864: ifeq          884
     867: aload         21
     869: checkcast     #74                 // class java/util/Collection
     872: invokeinterface #137,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     877: ifeq          884
     880: iconst_0
     881: goto          945
     884: aload         21
     886: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     891: astore        23
     893: aload         23
     895: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     900: ifeq          944
     903: aload         23
     905: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     910: astore        24
     912: aload         24
     914: checkcast     #34                 // class java/lang/Number
     917: invokevirtual #38                 // Method java/lang/Number.intValue:()I
     920: istore        25
     922: iconst_0
     923: istore        26
     925: iload         25
     927: iload         11
     929: if_icmplt     936
     932: iconst_1
     933: goto          937
     936: iconst_0
     937: ifeq          893
     940: iconst_1
     941: goto          945
     944: iconst_0
     945: ifeq          1047
     948: aload         16
     950: checkcast     #61                 // class java/lang/Iterable
     953: astore        21
     955: iconst_0
     956: istore        22
     958: aload         21
     960: instanceof    #74                 // class java/util/Collection
     963: ifeq          983
     966: aload         21
     968: checkcast     #74                 // class java/util/Collection
     971: invokeinterface #137,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     976: ifeq          983
     979: iconst_0
     980: goto          1044
     983: aload         21
     985: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     990: astore        23
     992: aload         23
     994: invokeinterface #28,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     999: ifeq          1043
    1002: aload         23
    1004: invokeinterface #32,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1009: astore        24
    1011: aload         24
    1013: checkcast     #34                 // class java/lang/Number
    1016: invokevirtual #38                 // Method java/lang/Number.intValue:()I
    1019: istore        25
    1021: iconst_0
    1022: istore        26
    1024: iload         25
    1026: iload         11
    1028: if_icmplt     1035
    1031: iconst_1
    1032: goto          1036
    1035: iconst_0
    1036: ifeq          992
    1039: iconst_1
    1040: goto          1044
    1043: iconst_0
    1044: ifne          1051
    1047: iconst_1
    1048: goto          1052
    1051: iconst_0
    1052: istore        20
    1054: iload         20
    1056: ifeq          1062
    1059: iinc          2, 1
    1062: iload         13
    1064: iload         15
    1066: imul
    1067: iload         17
    1069: imul
    1070: iload         19
    1072: imul
    1073: istore        21
    1075: iload         21
    1077: iload_3
    1078: if_icmple     1084
    1081: iload         21
    1083: istore_3
    1084: iload         8
    1086: iload         9
    1088: if_icmple     294
    1091: iload         4
    1093: iload         5
    1095: if_icmple     253
    1098: new           #88                 // class java/lang/StringBuilder
    1101: dup
    1102: invokespecial #90                 // Method java/lang/StringBuilder."<init>":()V
    1105: ldc           #139                // String Day 8 Task 1:
    1107: invokevirtual #96                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1110: iload_2
    1111: invokevirtual #142                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1114: invokevirtual #103                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1117: getstatic     #148                // Field java/lang/System.out:Ljava/io/PrintStream;
    1120: swap
    1121: invokevirtual #154                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1124: new           #88                 // class java/lang/StringBuilder
    1127: dup
    1128: invokespecial #90                 // Method java/lang/StringBuilder."<init>":()V
    1131: ldc           #156                // String Day 8 Task 2:
    1133: invokevirtual #96                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1136: iload_3
    1137: invokevirtual #142                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1140: invokevirtual #103                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1143: getstatic     #148                // Field java/lang/System.out:Ljava/io/PrintStream;
    1146: swap
    1147: invokevirtual #154                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1150: return
}


import java.io.File
import kotlin.collections.*

class Test(var divisibleBy:Int, var trueThrowsToMonkey:Int, var falseThrowsToMonkey:Int)

class Operation(var type:String, var rightValue:String, var leftValue:String)

class Monkey(var id:Int, var items:ArrayList<Long>, var op:Operation, var test:Test, var inspect:Long)

fun doOneRound(monkeys:ArrayList<Monkey>, divideWorryLevelBy3:Boolean, modWorryLevelWith:Int){
    for (monkey in monkeys){
        for (item in monkey.items){
            monkey.inspect++

            var left:Long
            var right:Long
            if (monkey.op.rightValue.all { it -> it.isDigit() }){
                right = monkey.op.rightValue.toLong()
            }
            else {
                right = item
            }

            if (monkey.op.leftValue.all { it -> it.isDigit() }){
                left = monkey.op.leftValue.toLong()
            }
            else {
                left = item
            }

            var worryLevel:Long
            if (monkey.op.type == "+"){
                worryLevel = (left + right)
            }
            else {
                worryLevel = (left * right)
            }

            if (divideWorryLevelBy3){
                worryLevel /= 3
            }
            else {
                worryLevel = worryLevel % modWorryLevelWith
            }

            if (worryLevel.mod(monkey.test.divisibleBy.toLong()) == 0.toLong()){
                var throwToMonkey = monkeys.filter { it -> it.id == monkey.test.trueThrowsToMonkey }.first()
                throwToMonkey.items.add(worryLevel)
            }
            else {
                var throwToMonkey = monkeys.filter { it -> it.id == monkey.test.falseThrowsToMonkey }.first()
                throwToMonkey.items.add(worryLevel)
            }
        }

        monkey.items = ArrayList<Long>()
    }
}

fun Day11() {
    val input = File("src/input/day11.txt").readLines()

    var monkeysTask1 = ArrayList<Monkey>()
    var monkeysTask2 = ArrayList<Monkey>()
    var modWorryLevelWith = 1

    for(i in 0..input.size-1 step 7){
        var monkeyId = input[i].filter { it.isDigit() }.toInt()

        var startingItems = input[i+1].split(":")[1].split(",").map { it.filter { it.isDigit() }.toLong() }

        var op = input[i+2].split("=")[1].split(" ")

        var divisibleBy = input[i+3].filter { it.isDigit() }.toInt()
        modWorryLevelWith = modWorryLevelWith * divisibleBy

        var ifTrueThrowToMonkey = input[i+4].filter { it.isDigit() }.toInt()
        var ifFalseThrowToMonkey = input[i+5].filter { it.isDigit() }.toInt()

        var monkeyTask1 = Monkey(
            monkeyId,
            ArrayList<Long>(startingItems),
            Operation(op[2], op[1], op[3]),
            Test(divisibleBy, ifTrueThrowToMonkey, ifFalseThrowToMonkey),
            0)

        var monkeyTask2 = Monkey(
            monkeyId,
            ArrayList<Long>(startingItems),
            Operation(op[2], op[1], op[3]),
            Test(divisibleBy, ifTrueThrowToMonkey, ifFalseThrowToMonkey),
            0)

        monkeysTask1.add(monkeyTask1)
        monkeysTask2.add(monkeyTask2)
    }

    for (i in 0..19 step 1){
        doOneRound(monkeysTask1, true, modWorryLevelWith)
    }

    for (i in 0..9999 step 1){
        doOneRound(monkeysTask2, false, modWorryLevelWith)
    }

    var inspectList = monkeysTask1.map { it -> it.inspect }.sortedDescending()
    var task1 = inspectList[0] * inspectList[1]

    var inspectListTask2 = monkeysTask2.map { it -> it.inspect }.sortedDescending()
    var task2:Long = inspectListTask2[0].toLong() * inspectListTask2[1].toLong()

    println("Day 11 Task 1: $task1") // 55216
    println("Day 11 Task 2: $task2") // 12848882750
}

Compiled from "Day11.kt"
public final class Day11Kt {
  public static final void doOneRound(java.util.ArrayList<Monkey>, boolean, int);
    Code:
       0: aload_0
       1: ldc           #10                 // String monkeys
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #22                 // Method java/util/ArrayList.iterator:()Ljava/util/Iterator;
      10: dup
      11: ldc           #24                 // String iterator(...)
      13: invokestatic  #27                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      16: astore_3
      17: aload_3
      18: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifeq          683
      26: aload_3
      27: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      32: dup
      33: ldc           #39                 // String next(...)
      35: invokestatic  #27                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      38: checkcast     #41                 // class Monkey
      41: astore        4
      43: aload         4
      45: invokevirtual #45                 // Method Monkey.getItems:()Ljava/util/ArrayList;
      48: invokevirtual #22                 // Method java/util/ArrayList.iterator:()Ljava/util/Iterator;
      51: dup
      52: ldc           #24                 // String iterator(...)
      54: invokestatic  #27                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      57: astore        5
      59: aload         5
      61: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      66: ifeq          668
      69: aload         5
      71: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      76: dup
      77: ldc           #39                 // String next(...)
      79: invokestatic  #27                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      82: checkcast     #47                 // class java/lang/Number
      85: invokevirtual #51                 // Method java/lang/Number.longValue:()J
      88: lstore        6
      90: aload         4
      92: invokevirtual #54                 // Method Monkey.getInspect:()J
      95: lstore        8
      97: aload         4
      99: lload         8
     101: lconst_1
     102: ladd
     103: invokevirtual #58                 // Method Monkey.setInspect:(J)V
     106: lconst_0
     107: lstore        8
     109: lconst_0
     110: lstore        10
     112: aload         4
     114: invokevirtual #62                 // Method Monkey.getOp:()LOperation;
     117: invokevirtual #68                 // Method Operation.getRightValue:()Ljava/lang/String;
     120: checkcast     #70                 // class java/lang/CharSequence
     123: astore        12
     125: iconst_0
     126: istore        13
     128: iconst_0
     129: istore        14
     131: iload         14
     133: aload         12
     135: invokeinterface #74,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     140: if_icmpge     180
     143: aload         12
     145: iload         14
     147: invokeinterface #78,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     152: istore        15
     154: iload         15
     156: istore        16
     158: iconst_0
     159: istore        17
     161: iload         16
     163: invokestatic  #84                 // Method java/lang/Character.isDigit:(C)Z
     166: nop
     167: ifne          174
     170: iconst_0
     171: goto          181
     174: iinc          14, 1
     177: goto          131
     180: iconst_1
     181: ifeq          200
     184: aload         4
     186: invokevirtual #62                 // Method Monkey.getOp:()LOperation;
     189: invokevirtual #68                 // Method Operation.getRightValue:()Ljava/lang/String;
     192: invokestatic  #90                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     195: lstore        10
     197: goto          204
     200: lload         6
     202: lstore        10
     204: aload         4
     206: invokevirtual #62                 // Method Monkey.getOp:()LOperation;
     209: invokevirtual #93                 // Method Operation.getLeftValue:()Ljava/lang/String;
     212: checkcast     #70                 // class java/lang/CharSequence
     215: astore        12
     217: iconst_0
     218: istore        13
     220: iconst_0
     221: istore        14
     223: iload         14
     225: aload         12
     227: invokeinterface #74,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     232: if_icmpge     272
     235: aload         12
     237: iload         14
     239: invokeinterface #78,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     244: istore        15
     246: iload         15
     248: istore        16
     250: iconst_0
     251: istore        17
     253: iload         16
     255: invokestatic  #84                 // Method java/lang/Character.isDigit:(C)Z
     258: nop
     259: ifne          266
     262: iconst_0
     263: goto          273
     266: iinc          14, 1
     269: goto          223
     272: iconst_1
     273: ifeq          292
     276: aload         4
     278: invokevirtual #62                 // Method Monkey.getOp:()LOperation;
     281: invokevirtual #93                 // Method Operation.getLeftValue:()Ljava/lang/String;
     284: invokestatic  #90                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     287: lstore        8
     289: goto          296
     292: lload         6
     294: lstore        8
     296: lconst_0
     297: lstore        12
     299: aload         4
     301: invokevirtual #62                 // Method Monkey.getOp:()LOperation;
     304: invokevirtual #96                 // Method Operation.getType:()Ljava/lang/String;
     307: ldc           #98                 // String +
     309: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     312: ifeq          325
     315: lload         8
     317: lload         10
     319: ladd
     320: lstore        12
     322: goto          332
     325: lload         8
     327: lload         10
     329: lmul
     330: lstore        12
     332: iload_1
     333: ifeq          346
     336: lload         12
     338: iconst_3
     339: i2l
     340: ldiv
     341: lstore        12
     343: goto          353
     346: lload         12
     348: iload_2
     349: i2l
     350: lrem
     351: lstore        12
     353: lload         12
     355: lstore        14
     357: aload         4
     359: invokevirtual #106                // Method Monkey.getTest:()LTest;
     362: invokevirtual #111                // Method Test.getDivisibleBy:()I
     365: i2l
     366: lstore        16
     368: lload         14
     370: lload         16
     372: lrem
     373: lstore        18
     375: lload         18
     377: lload         16
     379: lload         18
     381: lload         16
     383: lxor
     384: lload         18
     386: lload         18
     388: lneg
     389: lor
     390: land
     391: bipush        63
     393: lshr
     394: land
     395: ladd
     396: lconst_0
     397: lcmp
     398: ifne          534
     401: aload_0
     402: checkcast     #113                // class java/lang/Iterable
     405: astore        15
     407: iconst_0
     408: istore        16
     410: aload         15
     412: astore        17
     414: new           #18                 // class java/util/ArrayList
     417: dup
     418: invokespecial #117                // Method java/util/ArrayList."<init>":()V
     421: checkcast     #119                // class java/util/Collection
     424: astore        18
     426: iconst_0
     427: istore        19
     429: aload         17
     431: invokeinterface #120,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     436: astore        20
     438: aload         20
     440: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     445: ifeq          504
     448: aload         20
     450: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     455: astore        21
     457: aload         21
     459: checkcast     #41                 // class Monkey
     462: astore        22
     464: iconst_0
     465: istore        23
     467: aload         22
     469: invokevirtual #123                // Method Monkey.getId:()I
     472: aload         4
     474: invokevirtual #106                // Method Monkey.getTest:()LTest;
     477: invokevirtual #126                // Method Test.getTrueThrowsToMonkey:()I
     480: if_icmpne     487
     483: iconst_1
     484: goto          488
     487: iconst_0
     488: ifeq          438
     491: aload         18
     493: aload         21
     495: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     500: pop
     501: goto          438
     504: aload         18
     506: checkcast     #132                // class java/util/List
     509: nop
     510: invokestatic  #138                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     513: checkcast     #41                 // class Monkey
     516: astore        14
     518: aload         14
     520: invokevirtual #45                 // Method Monkey.getItems:()Ljava/util/ArrayList;
     523: lload         12
     525: invokestatic  #142                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     528: invokevirtual #143                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     531: goto          664
     534: aload_0
     535: checkcast     #113                // class java/lang/Iterable
     538: astore        15
     540: iconst_0
     541: istore        16
     543: aload         15
     545: astore        17
     547: new           #18                 // class java/util/ArrayList
     550: dup
     551: invokespecial #117                // Method java/util/ArrayList."<init>":()V
     554: checkcast     #119                // class java/util/Collection
     557: astore        18
     559: iconst_0
     560: istore        19
     562: aload         17
     564: invokeinterface #120,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     569: astore        20
     571: aload         20
     573: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     578: ifeq          637
     581: aload         20
     583: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     588: astore        21
     590: aload         21
     592: checkcast     #41                 // class Monkey
     595: astore        22
     597: iconst_0
     598: istore        23
     600: aload         22
     602: invokevirtual #123                // Method Monkey.getId:()I
     605: aload         4
     607: invokevirtual #106                // Method Monkey.getTest:()LTest;
     610: invokevirtual #146                // Method Test.getFalseThrowsToMonkey:()I
     613: if_icmpne     620
     616: iconst_1
     617: goto          621
     620: iconst_0
     621: ifeq          571
     624: aload         18
     626: aload         21
     628: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     633: pop
     634: goto          571
     637: aload         18
     639: checkcast     #132                // class java/util/List
     642: nop
     643: invokestatic  #138                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     646: checkcast     #41                 // class Monkey
     649: astore        14
     651: aload         14
     653: invokevirtual #45                 // Method Monkey.getItems:()Ljava/util/ArrayList;
     656: lload         12
     658: invokestatic  #142                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     661: invokevirtual #143                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     664: pop
     665: goto          59
     668: aload         4
     670: new           #18                 // class java/util/ArrayList
     673: dup
     674: invokespecial #117                // Method java/util/ArrayList."<init>":()V
     677: invokevirtual #150                // Method Monkey.setItems:(Ljava/util/ArrayList;)V
     680: goto          17
     683: return

  public static final void Day11();
    Code:
       0: new           #185                // class java/io/File
       3: dup
       4: ldc           #187                // String src/input/day11.txt
       6: invokespecial #190                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #196                // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_0
      16: new           #18                 // class java/util/ArrayList
      19: dup
      20: invokespecial #117                // Method java/util/ArrayList."<init>":()V
      23: astore_1
      24: new           #18                 // class java/util/ArrayList
      27: dup
      28: invokespecial #117                // Method java/util/ArrayList."<init>":()V
      31: astore_2
      32: iconst_1
      33: istore_3
      34: aload_0
      35: invokeinterface #199,  1          // InterfaceMethod java/util/List.size:()I
      40: iconst_1
      41: isub
      42: istore        4
      44: iconst_0
      45: istore        5
      47: iconst_0
      48: iload         4
      50: bipush        7
      52: invokestatic  #205                // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(III)I
      55: istore        6
      57: iload         5
      59: iload         6
      61: if_icmpgt     1044
      64: aload_0
      65: iload         5
      67: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      72: checkcast     #211                // class java/lang/String
      75: astore        8
      77: iconst_0
      78: istore        9
      80: aload         8
      82: checkcast     #70                 // class java/lang/CharSequence
      85: astore        10
      87: new           #213                // class java/lang/StringBuilder
      90: dup
      91: invokespecial #214                // Method java/lang/StringBuilder."<init>":()V
      94: checkcast     #216                // class java/lang/Appendable
      97: astore        11
      99: iconst_0
     100: istore        12
     102: iconst_0
     103: istore        13
     105: aload         10
     107: invokeinterface #74,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     112: istore        14
     114: iload         13
     116: iload         14
     118: if_icmpge     164
     121: aload         10
     123: iload         13
     125: invokeinterface #78,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     130: istore        15
     132: iload         15
     134: istore        16
     136: iconst_0
     137: istore        17
     139: iload         16
     141: invokestatic  #84                 // Method java/lang/Character.isDigit:(C)Z
     144: nop
     145: ifeq          158
     148: aload         11
     150: iload         15
     152: invokeinterface #220,  2          // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;
     157: pop
     158: iinc          13, 1
     161: goto          114
     164: aload         11
     166: checkcast     #213                // class java/lang/StringBuilder
     169: invokevirtual #223                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     172: invokestatic  #229                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     175: istore        7
     177: aload_0
     178: iload         5
     180: iconst_1
     181: iadd
     182: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     187: checkcast     #70                 // class java/lang/CharSequence
     190: iconst_1
     191: anewarray     #211                // class java/lang/String
     194: astore        9
     196: aload         9
     198: iconst_0
     199: ldc           #231                // String :
     201: aastore
     202: aload         9
     204: iconst_0
     205: iconst_0
     206: bipush        6
     208: aconst_null
     209: invokestatic  #237                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     212: iconst_1
     213: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     218: checkcast     #70                 // class java/lang/CharSequence
     221: iconst_1
     222: anewarray     #211                // class java/lang/String
     225: astore        9
     227: aload         9
     229: iconst_0
     230: ldc           #239                // String ,
     232: aastore
     233: aload         9
     235: iconst_0
     236: iconst_0
     237: bipush        6
     239: aconst_null
     240: invokestatic  #237                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     243: checkcast     #113                // class java/lang/Iterable
     246: astore        9
     248: iconst_0
     249: istore        10
     251: aload         9
     253: astore        11
     255: new           #18                 // class java/util/ArrayList
     258: dup
     259: aload         9
     261: bipush        10
     263: invokestatic  #243                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     266: invokespecial #246                // Method java/util/ArrayList."<init>":(I)V
     269: checkcast     #119                // class java/util/Collection
     272: astore        12
     274: iconst_0
     275: istore        13
     277: aload         11
     279: invokeinterface #120,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     284: astore        14
     286: aload         14
     288: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     293: ifeq          437
     296: aload         14
     298: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     303: astore        15
     305: aload         12
     307: aload         15
     309: checkcast     #211                // class java/lang/String
     312: astore        16
     314: astore        28
     316: iconst_0
     317: istore        17
     319: aload         16
     321: astore        18
     323: iconst_0
     324: istore        19
     326: aload         18
     328: checkcast     #70                 // class java/lang/CharSequence
     331: astore        20
     333: new           #213                // class java/lang/StringBuilder
     336: dup
     337: invokespecial #214                // Method java/lang/StringBuilder."<init>":()V
     340: checkcast     #216                // class java/lang/Appendable
     343: astore        21
     345: iconst_0
     346: istore        22
     348: iconst_0
     349: istore        23
     351: aload         20
     353: invokeinterface #74,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     358: istore        24
     360: iload         23
     362: iload         24
     364: if_icmpge     410
     367: aload         20
     369: iload         23
     371: invokeinterface #78,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     376: istore        25
     378: iload         25
     380: istore        26
     382: iconst_0
     383: istore        27
     385: iload         26
     387: invokestatic  #84                 // Method java/lang/Character.isDigit:(C)Z
     390: nop
     391: ifeq          404
     394: aload         21
     396: iload         25
     398: invokeinterface #220,  2          // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;
     403: pop
     404: iinc          23, 1
     407: goto          360
     410: aload         21
     412: checkcast     #213                // class java/lang/StringBuilder
     415: invokevirtual #223                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     418: invokestatic  #90                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     421: nop
     422: invokestatic  #142                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     425: aload         28
     427: swap
     428: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     433: pop
     434: goto          286
     437: aload         12
     439: checkcast     #132                // class java/util/List
     442: nop
     443: astore        8
     445: aload_0
     446: iload         5
     448: iconst_2
     449: iadd
     450: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     455: checkcast     #70                 // class java/lang/CharSequence
     458: iconst_1
     459: anewarray     #211                // class java/lang/String
     462: astore        10
     464: aload         10
     466: iconst_0
     467: ldc           #248                // String =
     469: aastore
     470: aload         10
     472: iconst_0
     473: iconst_0
     474: bipush        6
     476: aconst_null
     477: invokestatic  #237                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     480: iconst_1
     481: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     486: checkcast     #70                 // class java/lang/CharSequence
     489: iconst_1
     490: anewarray     #211                // class java/lang/String
     493: astore        10
     495: aload         10
     497: iconst_0
     498: ldc           #250                // String
     500: aastore
     501: aload         10
     503: iconst_0
     504: iconst_0
     505: bipush        6
     507: aconst_null
     508: invokestatic  #237                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     511: astore        9
     513: aload_0
     514: iload         5
     516: iconst_3
     517: iadd
     518: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     523: checkcast     #211                // class java/lang/String
     526: astore        11
     528: iconst_0
     529: istore        12
     531: aload         11
     533: checkcast     #70                 // class java/lang/CharSequence
     536: astore        13
     538: new           #213                // class java/lang/StringBuilder
     541: dup
     542: invokespecial #214                // Method java/lang/StringBuilder."<init>":()V
     545: checkcast     #216                // class java/lang/Appendable
     548: astore        14
     550: iconst_0
     551: istore        15
     553: iconst_0
     554: istore        16
     556: aload         13
     558: invokeinterface #74,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     563: istore        17
     565: iload         16
     567: iload         17
     569: if_icmpge     615
     572: aload         13
     574: iload         16
     576: invokeinterface #78,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     581: istore        18
     583: iload         18
     585: istore        19
     587: iconst_0
     588: istore        20
     590: iload         19
     592: invokestatic  #84                 // Method java/lang/Character.isDigit:(C)Z
     595: nop
     596: ifeq          609
     599: aload         14
     601: iload         18
     603: invokeinterface #220,  2          // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;
     608: pop
     609: iinc          16, 1
     612: goto          565
     615: aload         14
     617: checkcast     #213                // class java/lang/StringBuilder
     620: invokevirtual #223                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     623: invokestatic  #229                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     626: istore        10
     628: iload_3
     629: iload         10
     631: imul
     632: istore_3
     633: aload_0
     634: iload         5
     636: iconst_4
     637: iadd
     638: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     643: checkcast     #211                // class java/lang/String
     646: astore        12
     648: iconst_0
     649: istore        13
     651: aload         12
     653: checkcast     #70                 // class java/lang/CharSequence
     656: astore        14
     658: new           #213                // class java/lang/StringBuilder
     661: dup
     662: invokespecial #214                // Method java/lang/StringBuilder."<init>":()V
     665: checkcast     #216                // class java/lang/Appendable
     668: astore        15
     670: iconst_0
     671: istore        16
     673: iconst_0
     674: istore        17
     676: aload         14
     678: invokeinterface #74,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     683: istore        18
     685: iload         17
     687: iload         18
     689: if_icmpge     735
     692: aload         14
     694: iload         17
     696: invokeinterface #78,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     701: istore        19
     703: iload         19
     705: istore        20
     707: iconst_0
     708: istore        21
     710: iload         20
     712: invokestatic  #84                 // Method java/lang/Character.isDigit:(C)Z
     715: nop
     716: ifeq          729
     719: aload         15
     721: iload         19
     723: invokeinterface #220,  2          // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;
     728: pop
     729: iinc          17, 1
     732: goto          685
     735: aload         15
     737: checkcast     #213                // class java/lang/StringBuilder
     740: invokevirtual #223                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     743: invokestatic  #229                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     746: istore        11
     748: aload_0
     749: iload         5
     751: iconst_5
     752: iadd
     753: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     758: checkcast     #211                // class java/lang/String
     761: astore        13
     763: iconst_0
     764: istore        14
     766: aload         13
     768: checkcast     #70                 // class java/lang/CharSequence
     771: astore        15
     773: new           #213                // class java/lang/StringBuilder
     776: dup
     777: invokespecial #214                // Method java/lang/StringBuilder."<init>":()V
     780: checkcast     #216                // class java/lang/Appendable
     783: astore        16
     785: iconst_0
     786: istore        17
     788: iconst_0
     789: istore        18
     791: aload         15
     793: invokeinterface #74,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     798: istore        19
     800: iload         18
     802: iload         19
     804: if_icmpge     850
     807: aload         15
     809: iload         18
     811: invokeinterface #78,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     816: istore        20
     818: iload         20
     820: istore        21
     822: iconst_0
     823: istore        22
     825: iload         21
     827: invokestatic  #84                 // Method java/lang/Character.isDigit:(C)Z
     830: nop
     831: ifeq          844
     834: aload         16
     836: iload         20
     838: invokeinterface #220,  2          // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;
     843: pop
     844: iinc          18, 1
     847: goto          800
     850: aload         16
     852: checkcast     #213                // class java/lang/StringBuilder
     855: invokevirtual #223                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     858: invokestatic  #229                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     861: istore        12
     863: new           #41                 // class Monkey
     866: dup
     867: iload         7
     869: new           #18                 // class java/util/ArrayList
     872: dup
     873: aload         8
     875: checkcast     #119                // class java/util/Collection
     878: invokespecial #253                // Method java/util/ArrayList."<init>":(Ljava/util/Collection;)V
     881: new           #64                 // class Operation
     884: dup
     885: aload         9
     887: iconst_2
     888: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     893: checkcast     #211                // class java/lang/String
     896: aload         9
     898: iconst_1
     899: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     904: checkcast     #211                // class java/lang/String
     907: aload         9
     909: iconst_3
     910: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     915: checkcast     #211                // class java/lang/String
     918: invokespecial #256                // Method Operation."<init>":(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
     921: new           #108                // class Test
     924: dup
     925: iload         10
     927: iload         11
     929: iload         12
     931: invokespecial #259                // Method Test."<init>":(III)V
     934: lconst_0
     935: invokespecial #262                // Method Monkey."<init>":(ILjava/util/ArrayList;LOperation;LTest;J)V
     938: astore        13
     940: new           #41                 // class Monkey
     943: dup
     944: iload         7
     946: new           #18                 // class java/util/ArrayList
     949: dup
     950: aload         8
     952: checkcast     #119                // class java/util/Collection
     955: invokespecial #253                // Method java/util/ArrayList."<init>":(Ljava/util/Collection;)V
     958: new           #64                 // class Operation
     961: dup
     962: aload         9
     964: iconst_2
     965: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     970: checkcast     #211                // class java/lang/String
     973: aload         9
     975: iconst_1
     976: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     981: checkcast     #211                // class java/lang/String
     984: aload         9
     986: iconst_3
     987: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     992: checkcast     #211                // class java/lang/String
     995: invokespecial #256                // Method Operation."<init>":(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
     998: new           #108                // class Test
    1001: dup
    1002: iload         10
    1004: iload         11
    1006: iload         12
    1008: invokespecial #259                // Method Test."<init>":(III)V
    1011: lconst_0
    1012: invokespecial #262                // Method Monkey."<init>":(ILjava/util/ArrayList;LOperation;LTest;J)V
    1015: astore        14
    1017: aload_1
    1018: aload         13
    1020: invokevirtual #143                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
    1023: pop
    1024: aload_2
    1025: aload         14
    1027: invokevirtual #143                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
    1030: pop
    1031: iload         5
    1033: iload         6
    1035: if_icmpeq     1044
    1038: iinc          5, 7
    1041: goto          64
    1044: iconst_0
    1045: istore        4
    1047: iload         4
    1049: istore        5
    1051: iinc          4, 1
    1054: aload_1
    1055: iconst_1
    1056: iload_3
    1057: invokestatic  #264                // Method doOneRound:(Ljava/util/ArrayList;ZI)V
    1060: iload         4
    1062: bipush        19
    1064: if_icmple     1047
    1067: iconst_0
    1068: istore        4
    1070: iload         4
    1072: istore        5
    1074: iinc          4, 1
    1077: aload_2
    1078: iconst_0
    1079: iload_3
    1080: invokestatic  #264                // Method doOneRound:(Ljava/util/ArrayList;ZI)V
    1083: iload         4
    1085: sipush        9999
    1088: if_icmple     1070
    1091: aload_1
    1092: checkcast     #113                // class java/lang/Iterable
    1095: astore        5
    1097: iconst_0
    1098: istore        6
    1100: aload         5
    1102: astore        7
    1104: new           #18                 // class java/util/ArrayList
    1107: dup
    1108: aload         5
    1110: bipush        10
    1112: invokestatic  #243                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
    1115: invokespecial #246                // Method java/util/ArrayList."<init>":(I)V
    1118: checkcast     #119                // class java/util/Collection
    1121: astore        8
    1123: iconst_0
    1124: istore        9
    1126: aload         7
    1128: invokeinterface #120,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1133: astore        10
    1135: aload         10
    1137: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1142: ifeq          1188
    1145: aload         10
    1147: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1152: astore        11
    1154: aload         8
    1156: aload         11
    1158: checkcast     #41                 // class Monkey
    1161: astore        12
    1163: astore        28
    1165: iconst_0
    1166: istore        13
    1168: aload         12
    1170: invokevirtual #54                 // Method Monkey.getInspect:()J
    1173: invokestatic  #142                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
    1176: aload         28
    1178: swap
    1179: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1184: pop
    1185: goto          1135
    1188: aload         8
    1190: checkcast     #132                // class java/util/List
    1193: nop
    1194: checkcast     #113                // class java/lang/Iterable
    1197: invokestatic  #268                // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;
    1200: astore        4
    1202: aload         4
    1204: iconst_0
    1205: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1210: checkcast     #47                 // class java/lang/Number
    1213: invokevirtual #51                 // Method java/lang/Number.longValue:()J
    1216: aload         4
    1218: iconst_1
    1219: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1224: checkcast     #47                 // class java/lang/Number
    1227: invokevirtual #51                 // Method java/lang/Number.longValue:()J
    1230: lmul
    1231: lstore        5
    1233: aload_2
    1234: checkcast     #113                // class java/lang/Iterable
    1237: astore        8
    1239: iconst_0
    1240: istore        9
    1242: aload         8
    1244: astore        10
    1246: new           #18                 // class java/util/ArrayList
    1249: dup
    1250: aload         8
    1252: bipush        10
    1254: invokestatic  #243                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
    1257: invokespecial #246                // Method java/util/ArrayList."<init>":(I)V
    1260: checkcast     #119                // class java/util/Collection
    1263: astore        11
    1265: iconst_0
    1266: istore        12
    1268: aload         10
    1270: invokeinterface #120,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1275: astore        13
    1277: aload         13
    1279: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
    1284: ifeq          1330
    1287: aload         13
    1289: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1294: astore        14
    1296: aload         11
    1298: aload         14
    1300: checkcast     #41                 // class Monkey
    1303: astore        15
    1305: astore        28
    1307: iconst_0
    1308: istore        16
    1310: aload         15
    1312: invokevirtual #54                 // Method Monkey.getInspect:()J
    1315: invokestatic  #142                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
    1318: aload         28
    1320: swap
    1321: invokeinterface #130,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1326: pop
    1327: goto          1277
    1330: aload         11
    1332: checkcast     #132                // class java/util/List
    1335: nop
    1336: checkcast     #113                // class java/lang/Iterable
    1339: invokestatic  #268                // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;
    1342: astore        7
    1344: aload         7
    1346: iconst_0
    1347: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1352: checkcast     #47                 // class java/lang/Number
    1355: invokevirtual #51                 // Method java/lang/Number.longValue:()J
    1358: aload         7
    1360: iconst_1
    1361: invokeinterface #209,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1366: checkcast     #47                 // class java/lang/Number
    1369: invokevirtual #51                 // Method java/lang/Number.longValue:()J
    1372: lmul
    1373: lstore        8
    1375: new           #213                // class java/lang/StringBuilder
    1378: dup
    1379: invokespecial #214                // Method java/lang/StringBuilder."<init>":()V
    1382: ldc_w         #270                // String Day 11 Task 1:
    1385: invokevirtual #273                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1388: lload         5
    1390: invokevirtual #276                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
    1393: invokevirtual #223                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1396: getstatic     #282                // Field java/lang/System.out:Ljava/io/PrintStream;
    1399: swap
    1400: invokevirtual #288                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1403: new           #213                // class java/lang/StringBuilder
    1406: dup
    1407: invokespecial #214                // Method java/lang/StringBuilder."<init>":()V
    1410: ldc_w         #290                // String Day 11 Task 2:
    1413: invokevirtual #273                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1416: lload         8
    1418: invokevirtual #276                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
    1421: invokevirtual #223                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1424: getstatic     #282                // Field java/lang/System.out:Ljava/io/PrintStream;
    1427: swap
    1428: invokevirtual #288                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1431: return
}


/*
kotlin program to check happy numbers

A happy number is a number, if we reach to 1 after replacing the number by the squares of the digits of the number

Following examples will help to understand better:-

Input: n = 19
Output: True
19 is Happy Number,
1^2 + 9^2 = 82
8^2 + 2^2 = 68
6^2 + 8^2 = 100
1^2 + 0^2 + 0^2 = 1
As we reached to 1, 19 is a Happy Number.

Input: n = 20
Output: False
20 is not a happy number
2^2 + 0^2 = 4
4^2 = 16
As we cannot reach to 1, 20 is not a happy number
*/
import java.util.*

fun squaredSum(n: Int): Int{
    var sum_of_square:Int = 0
    var c:Int = n
    while(c!=0){
        sum_of_square += c%10 * (c % 10)
        c /= 10
    }
    return sum_of_square
}

//defining a boolean function to check whether the number is happy number or not
fun Happynumber(number: Int): Boolean {
    var slow: Int
    var fast: Int

    fast = number
    slow = fast
    do {

        slow = squaredSum(slow)

        fast = squaredSum(squaredSum(fast))
    } while (slow != fast)

    return slow == 1
}

//Testing code
fun main(){
    val input = Scanner(System.`in`)

    println("Enter the number which you want to check")
    val n = input.nextInt()
    if (Happynumber(n))
        println("$n is a Happy number")
    else
        println("$n is not a happy number")
}

/*
    Enter the number which you want to check
    19
    19 is a Happy number

    Enter the number which you want to check
    20
    20 is not a happy number
*/

/*
Time complexity :- O(N)
Space complexity :- O(1), which is constant
 */

Compiled from "happy_number.kt"
public final class Happy_numberKt {
  public static final int squaredSum(int);
    Code:
       0: iconst_0
       1: istore_1
       2: iload_0
       3: istore_2
       4: iload_2
       5: ifeq          28
       8: iload_1
       9: iload_2
      10: bipush        10
      12: irem
      13: iload_2
      14: bipush        10
      16: irem
      17: imul
      18: iadd
      19: istore_1
      20: iload_2
      21: bipush        10
      23: idiv
      24: istore_2
      25: goto          4
      28: iload_1
      29: ireturn

  public static final boolean Happynumber(int);
    Code:
       0: iconst_0
       1: istore_1
       2: iconst_0
       3: istore_2
       4: iload_0
       5: istore_2
       6: iload_2
       7: istore_1
       8: iload_1
       9: invokestatic  #14                 // Method squaredSum:(I)I
      12: istore_1
      13: iload_2
      14: invokestatic  #14                 // Method squaredSum:(I)I
      17: invokestatic  #14                 // Method squaredSum:(I)I
      20: istore_2
      21: iload_1
      22: iload_2
      23: if_icmpne     8
      26: iload_1
      27: iconst_1
      28: if_icmpne     35
      31: iconst_1
      32: goto          36
      35: iconst_0
      36: ireturn

  public static final void main();
    Code:
       0: new           #21                 // class java/util/Scanner
       3: dup
       4: getstatic     #27                 // Field java/lang/System.in:Ljava/io/InputStream;
       7: invokespecial #31                 // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
      10: astore_0
      11: ldc           #33                 // String Enter the number which you want to check
      13: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      16: swap
      17: invokevirtual #43                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      20: aload_0
      21: invokevirtual #47                 // Method java/util/Scanner.nextInt:()I
      24: istore_1
      25: iload_1
      26: invokestatic  #49                 // Method Happynumber:(I)Z
      29: ifeq          61
      32: new           #51                 // class java/lang/StringBuilder
      35: dup
      36: invokespecial #53                 // Method java/lang/StringBuilder."<init>":()V
      39: iload_1
      40: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      43: ldc           #59                 // String  is a Happy number
      45: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: invokevirtual #66                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      54: swap
      55: invokevirtual #43                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      58: goto          87
      61: new           #51                 // class java/lang/StringBuilder
      64: dup
      65: invokespecial #53                 // Method java/lang/StringBuilder."<init>":()V
      68: iload_1
      69: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      72: ldc           #68                 // String  is not a happy number
      74: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      77: invokevirtual #66                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      80: getstatic     #37                 // Field java/lang/System.out:Ljava/io/PrintStream;
      83: swap
      84: invokevirtual #43                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      87: return

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