import java.io.*
fun print_day_11() {
    val yellow = "\u001B[33m"
    val reset = "\u001b[0m"
    val green = "\u001B[32m"
    println(yellow + "-".repeat(25) + "Advent of Code - Day 11" + "-".repeat(25) + reset)
    println(green)
    val process = Runtime.getRuntime().exec("figlet Dumbo Octopus -c -f small")
    val reader = BufferedReader(InputStreamReader(process.inputStream))
    reader.forEachLine { println(it) }
    println(reset)
    println(yellow + "-".repeat(33) + "Output" + "-".repeat(33) + reset + "\n")
}
fun main() {
    print_day_11()
    Day11().part_1()
    Day11().part_2()
    println("\n" + "\u001B[33m" + "=".repeat(72) + "\u001b[0m" + "\n")
}

class Day11 {
    private val octogrid = File("../Input/day11.txt").readLines().map { it.toCharArray().map { c -> c.digitToInt() }.toMutableList() }.toMutableList()
    data class GridPoint(val x:Int, val y:Int) {
        fun neighbours(xBoundary: Int, yBoundary: Int): List<GridPoint> =
            (-1 .. 1).map { yOffset ->  (-1 .. 1).map { xOffset -> GridPoint(x+xOffset, y+yOffset)  } }.flatten()
                .filter {
                    it.x in 0 until xBoundary && it.y  in 0 until yBoundary && !(it.x == x && it.y == y)
                }
    }
    fun part_1() {
        var totalFlashes = 0
        for(step in 1..100) {
            val flashed = mutableListOf<GridPoint>()
            for (y in octogrid.indices) {
                for (x in octogrid[y].indices) {
                    octogrid[y][x]++
                }
            }
            do {
                val newFlashes = mutableListOf<GridPoint>()
                for (y in octogrid.indices) {
                    for (x in octogrid[y].indices) {
                        val gp = GridPoint(x, y)
                        if (octogrid[y][x] > 9 && gp !in flashed) {
                            newFlashes.add(gp)
                            gp.neighbours(octogrid[y].size, octogrid.size).forEach {
                                octogrid[it.y][it.x]++
                            }
                        }
                    }
                }
                flashed.addAll(newFlashes)
            } while(newFlashes.isNotEmpty())
            totalFlashes += flashed.size
            flashed.forEach { octogrid[it.y][it.x] = 0 }
        }
        println("Puzzle 1: " + totalFlashes)
    }
    fun part_2() {
        val totalOctos = octogrid.flatten().size
        var step = 0
        do {
            step++
            val flashed = mutableListOf<GridPoint>()
            for (y in octogrid.indices) {
                for (x in octogrid[y].indices) {
                    octogrid[y][x]++
                }
            }
            do {
                val newFlashes = mutableListOf<GridPoint>()
                for (y in octogrid.indices) {
                    for (x in octogrid[y].indices) {
                        val gp = GridPoint(x, y)
                        if (octogrid[y][x] > 9 && gp !in flashed) {
                            newFlashes.add(gp)
                            gp.neighbours(octogrid[y].size, octogrid.size).forEach {
                                octogrid[it.y][it.x]++
                            }
                        }
                    }
                }
                flashed.addAll(newFlashes)
            } while(newFlashes.isNotEmpty())
            flashed.forEach { octogrid[it.y][it.x] = 0 }
        } while(flashed.size != totalOctos)

        println("Puzzle 2: " + step)
    }
}

Compiled from "day11.kt"
public final class Day11 {
  private final java.util.List<java.util.List<java.lang.Integer>> octogrid;

  public Day11();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: new           #10                 // class java/io/File
       8: dup
       9: ldc           #12                 // String ../Input/day11.txt
      11: invokespecial #15                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      14: aconst_null
      15: iconst_1
      16: aconst_null
      17: invokestatic  #21                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      20: checkcast     #23                 // class java/lang/Iterable
      23: astore_1
      24: astore        21
      26: iconst_0
      27: istore_2
      28: aload_1
      29: astore_3
      30: new           #25                 // class java/util/ArrayList
      33: dup
      34: aload_1
      35: bipush        10
      37: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      40: invokespecial #34                 // Method java/util/ArrayList."<init>":(I)V
      43: checkcast     #36                 // class java/util/Collection
      46: astore        4
      48: iconst_0
      49: istore        5
      51: aload_3
      52: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      57: astore        6
      59: aload         6
      61: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      66: ifeq          211
      69: aload         6
      71: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      76: astore        7
      78: aload         4
      80: aload         7
      82: checkcast     #52                 // class java/lang/String
      85: astore        8
      87: astore        22
      89: iconst_0
      90: istore        9
      92: aload         8
      94: invokevirtual #56                 // Method java/lang/String.toCharArray:()[C
      97: dup
      98: ldc           #58                 // String toCharArray(...)
     100: invokestatic  #64                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     103: astore        10
     105: nop
     106: iconst_0
     107: istore        11
     109: aload         10
     111: astore        12
     113: new           #25                 // class java/util/ArrayList
     116: dup
     117: aload         10
     119: arraylength
     120: invokespecial #34                 // Method java/util/ArrayList."<init>":(I)V
     123: checkcast     #36                 // class java/util/Collection
     126: astore        13
     128: iconst_0
     129: istore        14
     131: iconst_0
     132: istore        15
     134: aload         12
     136: arraylength
     137: istore        16
     139: iload         15
     141: iload         16
     143: if_icmpge     187
     146: aload         12
     148: iload         15
     150: caload
     151: istore        17
     153: aload         13
     155: iload         17
     157: istore        18
     159: astore        19
     161: iconst_0
     162: istore        20
     164: iload         18
     166: invokestatic  #70                 // Method kotlin/text/CharsKt.digitToInt:(C)I
     169: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     172: aload         19
     174: swap
     175: invokeinterface #80,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     180: pop
     181: iinc          15, 1
     184: goto          139
     187: aload         13
     189: checkcast     #82                 // class java/util/List
     192: nop
     193: checkcast     #36                 // class java/util/Collection
     196: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     199: aload         22
     201: swap
     202: invokeinterface #80,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     207: pop
     208: goto          59
     211: aload         4
     213: checkcast     #82                 // class java/util/List
     216: nop
     217: aload         21
     219: swap
     220: checkcast     #36                 // class java/util/Collection
     223: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     226: putfield      #90                 // Field octogrid:Ljava/util/List;
     229: return

  public final void part_1();
    Code:
       0: iconst_0
       1: istore_1
       2: iconst_1
       3: istore_2
       4: iload_2
       5: bipush        101
       7: if_icmpge     564
      10: new           #25                 // class java/util/ArrayList
      13: dup
      14: invokespecial #112                // Method java/util/ArrayList."<init>":()V
      17: checkcast     #82                 // class java/util/List
      20: astore_3
      21: iconst_0
      22: istore        4
      24: aload_0
      25: getfield      #90                 // Field octogrid:Ljava/util/List;
      28: checkcast     #36                 // class java/util/Collection
      31: invokeinterface #116,  1          // InterfaceMethod java/util/Collection.size:()I
      36: istore        5
      38: iload         4
      40: iload         5
      42: if_icmpge     142
      45: iconst_0
      46: istore        6
      48: aload_0
      49: getfield      #90                 // Field octogrid:Ljava/util/List;
      52: iload         4
      54: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      59: checkcast     #36                 // class java/util/Collection
      62: invokeinterface #116,  1          // InterfaceMethod java/util/Collection.size:()I
      67: istore        7
      69: iload         6
      71: iload         7
      73: if_icmpge     136
      76: aload_0
      77: getfield      #90                 // Field octogrid:Ljava/util/List;
      80: iload         4
      82: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      87: checkcast     #82                 // class java/util/List
      90: astore        8
      92: iload         6
      94: istore        9
      96: aload         8
      98: iload         9
     100: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     105: checkcast     #122                // class java/lang/Number
     108: invokevirtual #125                // Method java/lang/Number.intValue:()I
     111: istore        10
     113: aload         8
     115: iload         9
     117: iload         10
     119: iconst_1
     120: iadd
     121: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     124: invokeinterface #129,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     129: pop
     130: iinc          6, 1
     133: goto          69
     136: iinc          4, 1
     139: goto          38
     142: new           #25                 // class java/util/ArrayList
     145: dup
     146: invokespecial #112                // Method java/util/ArrayList."<init>":()V
     149: checkcast     #82                 // class java/util/List
     152: astore        4
     154: iconst_0
     155: istore        5
     157: aload_0
     158: getfield      #90                 // Field octogrid:Ljava/util/List;
     161: checkcast     #36                 // class java/util/Collection
     164: invokeinterface #116,  1          // InterfaceMethod java/util/Collection.size:()I
     169: istore        6
     171: iload         5
     173: iload         6
     175: if_icmpge     432
     178: iconst_0
     179: istore        7
     181: aload_0
     182: getfield      #90                 // Field octogrid:Ljava/util/List;
     185: iload         5
     187: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     192: checkcast     #36                 // class java/util/Collection
     195: invokeinterface #116,  1          // InterfaceMethod java/util/Collection.size:()I
     200: istore        8
     202: iload         7
     204: iload         8
     206: if_icmpge     426
     209: new           #131                // class Day11$GridPoint
     212: dup
     213: iload         7
     215: iload         5
     217: invokespecial #134                // Method Day11$GridPoint."<init>":(II)V
     220: astore        9
     222: aload_0
     223: getfield      #90                 // Field octogrid:Ljava/util/List;
     226: iload         5
     228: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     233: checkcast     #82                 // class java/util/List
     236: iload         7
     238: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     243: checkcast     #122                // class java/lang/Number
     246: invokevirtual #125                // Method java/lang/Number.intValue:()I
     249: bipush        9
     251: if_icmple     420
     254: aload_3
     255: aload         9
     257: invokeinterface #137,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     262: ifne          420
     265: aload         4
     267: aload         9
     269: invokeinterface #138,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     274: pop
     275: aload         9
     277: aload_0
     278: getfield      #90                 // Field octogrid:Ljava/util/List;
     281: iload         5
     283: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     288: checkcast     #82                 // class java/util/List
     291: invokeinterface #139,  1          // InterfaceMethod java/util/List.size:()I
     296: aload_0
     297: getfield      #90                 // Field octogrid:Ljava/util/List;
     300: invokeinterface #139,  1          // InterfaceMethod java/util/List.size:()I
     305: invokevirtual #143                // Method Day11$GridPoint.neighbours:(II)Ljava/util/List;
     308: checkcast     #23                 // class java/lang/Iterable
     311: astore        10
     313: iconst_0
     314: istore        11
     316: aload         10
     318: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     323: astore        12
     325: aload         12
     327: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     332: ifeq          419
     335: aload         12
     337: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     342: astore        13
     344: aload         13
     346: checkcast     #131                // class Day11$GridPoint
     349: astore        14
     351: iconst_0
     352: istore        15
     354: aload_0
     355: getfield      #90                 // Field octogrid:Ljava/util/List;
     358: aload         14
     360: invokevirtual #146                // Method Day11$GridPoint.getY:()I
     363: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     368: checkcast     #82                 // class java/util/List
     371: astore        16
     373: aload         14
     375: invokevirtual #149                // Method Day11$GridPoint.getX:()I
     378: istore        17
     380: aload         16
     382: iload         17
     384: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     389: checkcast     #122                // class java/lang/Number
     392: invokevirtual #125                // Method java/lang/Number.intValue:()I
     395: istore        18
     397: aload         16
     399: iload         17
     401: iload         18
     403: iconst_1
     404: iadd
     405: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     408: invokeinterface #129,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     413: pop
     414: nop
     415: nop
     416: goto          325
     419: nop
     420: iinc          7, 1
     423: goto          202
     426: iinc          5, 1
     429: goto          171
     432: aload_3
     433: aload         4
     435: checkcast     #36                 // class java/util/Collection
     438: invokeinterface #153,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     443: pop
     444: aload         4
     446: checkcast     #36                 // class java/util/Collection
     449: invokeinterface #156,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     454: ifne          461
     457: iconst_1
     458: goto          462
     461: iconst_0
     462: ifne          142
     465: iload_1
     466: aload_3
     467: invokeinterface #139,  1          // InterfaceMethod java/util/List.size:()I
     472: iadd
     473: istore_1
     474: aload_3
     475: checkcast     #23                 // class java/lang/Iterable
     478: astore        4
     480: iconst_0
     481: istore        5
     483: aload         4
     485: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     490: astore        6
     492: aload         6
     494: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     499: ifeq          557
     502: aload         6
     504: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     509: astore        7
     511: aload         7
     513: checkcast     #131                // class Day11$GridPoint
     516: astore        8
     518: iconst_0
     519: istore        9
     521: aload_0
     522: getfield      #90                 // Field octogrid:Ljava/util/List;
     525: aload         8
     527: invokevirtual #146                // Method Day11$GridPoint.getY:()I
     530: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     535: checkcast     #82                 // class java/util/List
     538: aload         8
     540: invokevirtual #149                // Method Day11$GridPoint.getX:()I
     543: iconst_0
     544: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     547: invokeinterface #129,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     552: pop
     553: nop
     554: goto          492
     557: nop
     558: iinc          2, 1
     561: goto          4
     564: new           #158                // class java/lang/StringBuilder
     567: dup
     568: invokespecial #159                // Method java/lang/StringBuilder."<init>":()V
     571: ldc           #161                // String Puzzle 1:
     573: invokevirtual #165                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     576: iload_1
     577: invokevirtual #168                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     580: invokevirtual #172                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     583: getstatic     #178                // Field java/lang/System.out:Ljava/io/PrintStream;
     586: swap
     587: invokevirtual #184                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     590: return

  public final void part_2();
    Code:
       0: aload_0
       1: getfield      #90                 // Field octogrid:Ljava/util/List;
       4: checkcast     #23                 // class java/lang/Iterable
       7: invokestatic  #202                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
      10: invokeinterface #139,  1          // InterfaceMethod java/util/List.size:()I
      15: istore_1
      16: iconst_0
      17: istore_2
      18: iinc          2, 1
      21: new           #25                 // class java/util/ArrayList
      24: dup
      25: invokespecial #112                // Method java/util/ArrayList."<init>":()V
      28: checkcast     #82                 // class java/util/List
      31: astore_3
      32: iconst_0
      33: istore        4
      35: aload_0
      36: getfield      #90                 // Field octogrid:Ljava/util/List;
      39: checkcast     #36                 // class java/util/Collection
      42: invokeinterface #116,  1          // InterfaceMethod java/util/Collection.size:()I
      47: istore        5
      49: iload         4
      51: iload         5
      53: if_icmpge     153
      56: iconst_0
      57: istore        6
      59: aload_0
      60: getfield      #90                 // Field octogrid:Ljava/util/List;
      63: iload         4
      65: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      70: checkcast     #36                 // class java/util/Collection
      73: invokeinterface #116,  1          // InterfaceMethod java/util/Collection.size:()I
      78: istore        7
      80: iload         6
      82: iload         7
      84: if_icmpge     147
      87: aload_0
      88: getfield      #90                 // Field octogrid:Ljava/util/List;
      91: iload         4
      93: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      98: checkcast     #82                 // class java/util/List
     101: astore        8
     103: iload         6
     105: istore        9
     107: aload         8
     109: iload         9
     111: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     116: checkcast     #122                // class java/lang/Number
     119: invokevirtual #125                // Method java/lang/Number.intValue:()I
     122: istore        10
     124: aload         8
     126: iload         9
     128: iload         10
     130: iconst_1
     131: iadd
     132: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     135: invokeinterface #129,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     140: pop
     141: iinc          6, 1
     144: goto          80
     147: iinc          4, 1
     150: goto          49
     153: new           #25                 // class java/util/ArrayList
     156: dup
     157: invokespecial #112                // Method java/util/ArrayList."<init>":()V
     160: checkcast     #82                 // class java/util/List
     163: astore        4
     165: iconst_0
     166: istore        5
     168: aload_0
     169: getfield      #90                 // Field octogrid:Ljava/util/List;
     172: checkcast     #36                 // class java/util/Collection
     175: invokeinterface #116,  1          // InterfaceMethod java/util/Collection.size:()I
     180: istore        6
     182: iload         5
     184: iload         6
     186: if_icmpge     443
     189: iconst_0
     190: istore        7
     192: aload_0
     193: getfield      #90                 // Field octogrid:Ljava/util/List;
     196: iload         5
     198: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     203: checkcast     #36                 // class java/util/Collection
     206: invokeinterface #116,  1          // InterfaceMethod java/util/Collection.size:()I
     211: istore        8
     213: iload         7
     215: iload         8
     217: if_icmpge     437
     220: new           #131                // class Day11$GridPoint
     223: dup
     224: iload         7
     226: iload         5
     228: invokespecial #134                // Method Day11$GridPoint."<init>":(II)V
     231: astore        9
     233: aload_0
     234: getfield      #90                 // Field octogrid:Ljava/util/List;
     237: iload         5
     239: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     244: checkcast     #82                 // class java/util/List
     247: iload         7
     249: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     254: checkcast     #122                // class java/lang/Number
     257: invokevirtual #125                // Method java/lang/Number.intValue:()I
     260: bipush        9
     262: if_icmple     431
     265: aload_3
     266: aload         9
     268: invokeinterface #137,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     273: ifne          431
     276: aload         4
     278: aload         9
     280: invokeinterface #138,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     285: pop
     286: aload         9
     288: aload_0
     289: getfield      #90                 // Field octogrid:Ljava/util/List;
     292: iload         5
     294: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     299: checkcast     #82                 // class java/util/List
     302: invokeinterface #139,  1          // InterfaceMethod java/util/List.size:()I
     307: aload_0
     308: getfield      #90                 // Field octogrid:Ljava/util/List;
     311: invokeinterface #139,  1          // InterfaceMethod java/util/List.size:()I
     316: invokevirtual #143                // Method Day11$GridPoint.neighbours:(II)Ljava/util/List;
     319: checkcast     #23                 // class java/lang/Iterable
     322: astore        10
     324: iconst_0
     325: istore        11
     327: aload         10
     329: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     334: astore        12
     336: aload         12
     338: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     343: ifeq          430
     346: aload         12
     348: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     353: astore        13
     355: aload         13
     357: checkcast     #131                // class Day11$GridPoint
     360: astore        14
     362: iconst_0
     363: istore        15
     365: aload_0
     366: getfield      #90                 // Field octogrid:Ljava/util/List;
     369: aload         14
     371: invokevirtual #146                // Method Day11$GridPoint.getY:()I
     374: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     379: checkcast     #82                 // class java/util/List
     382: astore        16
     384: aload         14
     386: invokevirtual #149                // Method Day11$GridPoint.getX:()I
     389: istore        17
     391: aload         16
     393: iload         17
     395: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     400: checkcast     #122                // class java/lang/Number
     403: invokevirtual #125                // Method java/lang/Number.intValue:()I
     406: istore        18
     408: aload         16
     410: iload         17
     412: iload         18
     414: iconst_1
     415: iadd
     416: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     419: invokeinterface #129,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     424: pop
     425: nop
     426: nop
     427: goto          336
     430: nop
     431: iinc          7, 1
     434: goto          213
     437: iinc          5, 1
     440: goto          182
     443: aload_3
     444: aload         4
     446: checkcast     #36                 // class java/util/Collection
     449: invokeinterface #153,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     454: pop
     455: aload         4
     457: checkcast     #36                 // class java/util/Collection
     460: invokeinterface #156,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     465: ifne          472
     468: iconst_1
     469: goto          473
     472: iconst_0
     473: ifne          153
     476: aload_3
     477: checkcast     #23                 // class java/lang/Iterable
     480: astore        4
     482: iconst_0
     483: istore        5
     485: aload         4
     487: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     492: astore        6
     494: aload         6
     496: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     501: ifeq          559
     504: aload         6
     506: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     511: astore        7
     513: aload         7
     515: checkcast     #131                // class Day11$GridPoint
     518: astore        8
     520: iconst_0
     521: istore        9
     523: aload_0
     524: getfield      #90                 // Field octogrid:Ljava/util/List;
     527: aload         8
     529: invokevirtual #146                // Method Day11$GridPoint.getY:()I
     532: invokeinterface #120,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     537: checkcast     #82                 // class java/util/List
     540: aload         8
     542: invokevirtual #149                // Method Day11$GridPoint.getX:()I
     545: iconst_0
     546: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     549: invokeinterface #129,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     554: pop
     555: nop
     556: goto          494
     559: nop
     560: aload_3
     561: invokeinterface #139,  1          // InterfaceMethod java/util/List.size:()I
     566: iload_1
     567: if_icmpne     18
     570: new           #158                // class java/lang/StringBuilder
     573: dup
     574: invokespecial #159                // Method java/lang/StringBuilder."<init>":()V
     577: ldc           #204                // String Puzzle 2:
     579: invokevirtual #165                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     582: iload_2
     583: invokevirtual #168                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     586: invokevirtual #172                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     589: getstatic     #178                // Field java/lang/System.out:Ljava/io/PrintStream;
     592: swap
     593: invokevirtual #184                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     596: return
}

Compiled from "day11.kt"
public final class Day11$GridPoint {
  private final int x;

  private final int y;

  public Day11$GridPoint(int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field x:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field y:I
      14: return

  public final int getX();
    Code:
       0: aload_0
       1: getfield      #13                 // Field x:I
       4: ireturn

  public final int getY();
    Code:
       0: aload_0
       1: getfield      #16                 // Field y:I
       4: ireturn

  public final java.util.List<Day11$GridPoint> neighbours(int, int);
    Code:
       0: new           #27                 // class kotlin/ranges/IntRange
       3: dup
       4: iconst_m1
       5: iconst_1
       6: invokespecial #29                 // Method kotlin/ranges/IntRange."<init>":(II)V
       9: checkcast     #31                 // class java/lang/Iterable
      12: astore_3
      13: iconst_0
      14: istore        4
      16: aload_3
      17: astore        5
      19: new           #33                 // class java/util/ArrayList
      22: dup
      23: aload_3
      24: bipush        10
      26: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      29: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
      32: checkcast     #44                 // class java/util/Collection
      35: astore        6
      37: iconst_0
      38: istore        7
      40: aload         5
      42: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      47: astore        8
      49: aload         8
      51: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      56: ifeq          215
      59: aload         8
      61: checkcast     #56                 // class kotlin/collections/IntIterator
      64: invokevirtual #59                 // Method kotlin/collections/IntIterator.nextInt:()I
      67: istore        9
      69: aload         6
      71: iload         9
      73: istore        10
      75: astore        22
      77: iconst_0
      78: istore        11
      80: new           #27                 // class kotlin/ranges/IntRange
      83: dup
      84: iconst_m1
      85: iconst_1
      86: invokespecial #29                 // Method kotlin/ranges/IntRange."<init>":(II)V
      89: checkcast     #31                 // class java/lang/Iterable
      92: astore        12
      94: iconst_0
      95: istore        13
      97: aload         12
      99: astore        14
     101: new           #33                 // class java/util/ArrayList
     104: dup
     105: aload         12
     107: bipush        10
     109: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     112: invokespecial #42                 // Method java/util/ArrayList."<init>":(I)V
     115: checkcast     #44                 // class java/util/Collection
     118: astore        15
     120: iconst_0
     121: istore        16
     123: aload         14
     125: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     130: astore        17
     132: aload         17
     134: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     139: ifeq          196
     142: aload         17
     144: checkcast     #56                 // class kotlin/collections/IntIterator
     147: invokevirtual #59                 // Method kotlin/collections/IntIterator.nextInt:()I
     150: istore        18
     152: aload         15
     154: iload         18
     156: istore        19
     158: astore        20
     160: iconst_0
     161: istore        21
     163: new           #2                  // class Day11$GridPoint
     166: dup
     167: aload_0
     168: getfield      #13                 // Field x:I
     171: iload         19
     173: iadd
     174: aload_0
     175: getfield      #16                 // Field y:I
     178: iload         10
     180: iadd
     181: invokespecial #60                 // Method "<init>":(II)V
     184: aload         20
     186: swap
     187: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     192: pop
     193: goto          132
     196: aload         15
     198: checkcast     #66                 // class java/util/List
     201: nop
     202: nop
     203: aload         22
     205: swap
     206: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     211: pop
     212: goto          49
     215: aload         6
     217: checkcast     #66                 // class java/util/List
     220: nop
     221: checkcast     #31                 // class java/lang/Iterable
     224: invokestatic  #70                 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     227: checkcast     #31                 // class java/lang/Iterable
     230: astore_3
     231: nop
     232: iconst_0
     233: istore        4
     235: aload_3
     236: astore        5
     238: new           #33                 // class java/util/ArrayList
     241: dup
     242: invokespecial #71                 // Method java/util/ArrayList."<init>":()V
     245: checkcast     #44                 // class java/util/Collection
     248: astore        6
     250: iconst_0
     251: istore        7
     253: aload         5
     255: invokeinterface #48,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     260: astore        8
     262: aload         8
     264: invokeinterface #54,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     269: ifeq          398
     272: aload         8
     274: invokeinterface #75,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     279: astore        9
     281: aload         9
     283: checkcast     #2                  // class Day11$GridPoint
     286: astore        10
     288: iconst_0
     289: istore        11
     291: aload         10
     293: getfield      #13                 // Field x:I
     296: istore        12
     298: iconst_0
     299: iload         12
     301: if_icmpgt     318
     304: iload         12
     306: iload_1
     307: if_icmpge     314
     310: iconst_1
     311: goto          319
     314: iconst_0
     315: goto          319
     318: iconst_0
     319: ifeq          381
     322: aload         10
     324: getfield      #16                 // Field y:I
     327: istore        12
     329: iconst_0
     330: iload         12
     332: if_icmpgt     349
     335: iload         12
     337: iload_2
     338: if_icmpge     345
     341: iconst_1
     342: goto          350
     345: iconst_0
     346: goto          350
     349: iconst_0
     350: ifeq          381
     353: aload         10
     355: getfield      #13                 // Field x:I
     358: aload_0
     359: getfield      #13                 // Field x:I
     362: if_icmpne     377
     365: aload         10
     367: getfield      #16                 // Field y:I
     370: aload_0
     371: getfield      #16                 // Field y:I
     374: if_icmpeq     381
     377: iconst_1
     378: goto          382
     381: iconst_0
     382: ifeq          262
     385: aload         6
     387: aload         9
     389: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     394: pop
     395: goto          262
     398: aload         6
     400: checkcast     #66                 // class java/util/List
     403: nop
     404: areturn

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #13                 // Field x:I
       4: ireturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #16                 // Field y:I
       4: ireturn

  public final Day11$GridPoint copy(int, int);
    Code:
       0: new           #2                  // class Day11$GridPoint
       3: dup
       4: iload_1
       5: iload_2
       6: invokespecial #60                 // Method "<init>":(II)V
       9: areturn

  public static Day11$GridPoint copy$default(Day11$GridPoint, int, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #13                 // Field x:I
      10: istore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #16                 // Field y:I
      21: istore_2
      22: aload_0
      23: iload_1
      24: iload_2
      25: invokevirtual #105                // Method copy:(II)LDay11$GridPoint;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #109                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #112                // String GridPoint(x=
       9: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field x:I
      16: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #121                // String , y=
      21: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field y:I
      28: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #124                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #126                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field x:I
       4: invokestatic  #132                // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #16                 // Field y:I
      16: invokestatic  #132                // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day11$GridPoint
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day11$GridPoint
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field x:I
      25: aload_2
      26: getfield      #13                 // Field x:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field y:I
      38: aload_2
      39: getfield      #16                 // Field y:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: iconst_1
      48: ireturn
}

Compiled from "day11.kt"
public final class Day11Kt {
  public static final void print_day_11();
    Code:
       0: ldc           #8                  // String \u001b[33m
       2: astore_0
       3: ldc           #10                 // String \u001b[0m
       5: astore_1
       6: ldc           #12                 // String \u001b[32m
       8: astore_2
       9: new           #14                 // class java/lang/StringBuilder
      12: dup
      13: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      16: aload_0
      17: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      20: ldc           #23                 // String -
      22: checkcast     #25                 // class java/lang/CharSequence
      25: bipush        25
      27: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      30: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      33: ldc           #33                 // String Advent of Code - Day 11
      35: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: ldc           #23                 // String -
      40: checkcast     #25                 // class java/lang/CharSequence
      43: bipush        25
      45: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      48: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      51: aload_1
      52: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      55: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      58: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      61: swap
      62: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      65: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      68: aload_2
      69: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      72: invokestatic  #55                 // Method java/lang/Runtime.getRuntime:()Ljava/lang/Runtime;
      75: ldc           #57                 // String figlet Dumbo Octopus -c -f small
      77: invokevirtual #61                 // Method java/lang/Runtime.exec:(Ljava/lang/String;)Ljava/lang/Process;
      80: astore_3
      81: new           #63                 // class java/io/BufferedReader
      84: dup
      85: new           #65                 // class java/io/InputStreamReader
      88: dup
      89: aload_3
      90: invokevirtual #71                 // Method java/lang/Process.getInputStream:()Ljava/io/InputStream;
      93: invokespecial #74                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;)V
      96: checkcast     #76                 // class java/io/Reader
      99: invokespecial #79                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;)V
     102: astore        4
     104: aload         4
     106: checkcast     #76                 // class java/io/Reader
     109: invokedynamic #98,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     114: invokestatic  #104                // Method kotlin/io/TextStreamsKt.forEachLine:(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)V
     117: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     120: aload_1
     121: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     124: new           #14                 // class java/lang/StringBuilder
     127: dup
     128: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
     131: aload_0
     132: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     135: ldc           #23                 // String -
     137: checkcast     #25                 // class java/lang/CharSequence
     140: bipush        33
     142: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
     145: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     148: ldc           #106                // String Output
     150: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     153: ldc           #23                 // String -
     155: checkcast     #25                 // class java/lang/CharSequence
     158: bipush        33
     160: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
     163: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     166: aload_1
     167: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     170: bipush        10
     172: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     175: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     178: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     181: swap
     182: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     185: return

  public static final void main();
    Code:
       0: invokestatic  #120                // Method print_day_11:()V
       3: new           #122                // class Day11
       6: dup
       7: invokespecial #123                // Method Day11."<init>":()V
      10: invokevirtual #126                // Method Day11.part_1:()V
      13: new           #122                // class Day11
      16: dup
      17: invokespecial #123                // Method Day11."<init>":()V
      20: invokevirtual #129                // Method Day11.part_2:()V
      23: new           #14                 // class java/lang/StringBuilder
      26: dup
      27: invokespecial #17                 // Method java/lang/StringBuilder."<init>":()V
      30: ldc           #131                // String \n\u001b[33m
      32: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      35: ldc           #133                // String =
      37: checkcast     #25                 // class java/lang/CharSequence
      40: bipush        72
      42: invokestatic  #31                 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;
      45: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: ldc           #135                // String \u001b[0m\n
      50: invokevirtual #21                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      53: invokevirtual #37                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      56: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      59: swap
      60: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      63: return

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

  private static final kotlin.Unit print_day_11$lambda$0(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #142                // String it
       3: invokestatic  #148                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
       9: aload_0
      10: invokevirtual #49                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      13: getstatic     #154                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      16: areturn
}