import kotlin.String
import kotlin.collections.List

object Day13 {
    private const val NORMAL_MULTIPLIER = 100
    private const val TRANSPOSED_MULTIPLIER = 1

    fun part1(input: List<String>): String {
        val grids = parseGrids(input)

        return grids.sumOf { grid ->
            // Transposed is actually columns
            val transposedGrid = transpose(grid)
            scoreExact(grid, NORMAL_MULTIPLIER) + scoreExact(transposedGrid, TRANSPOSED_MULTIPLIER)
        }.toString()

    }

    private fun scoreExact(grid: List<String>, multiplier: Int): Int {
        return findLinesOfExactness(grid).find { isMirror(it, grid) }?.let {
            // Normal is rows, so rows above
            val rowsAbove = it.first + 1
            return rowsAbove * multiplier
        } ?: 0
    }

    private fun isMirror(it: Pair<Int, Int>, grid: List<String>): Boolean {
        val (a, b) = it
        if (a < 0 || b >= grid.size) {
            return true
        }
        return grid[a] == grid[b] && isMirror(a - 1 to b + 1, grid)
    }

    /**
     * Return the rows in which there is a line of exactness
     */
    private fun findLinesOfExactness(grid: List<String>): List<Pair<Int, Int>> {
        return grid.withIndex().zipWithNext().filter { (a, b) -> a.value == b.value }
            .map { (a, b) -> a.index to b.index }
    }

    fun transpose(grid: List<String>): List<String> {
        val transposedGrid = List(grid[0].length) { CharArray(grid.size) }
        for (i in grid.indices) {
            for (j in grid[0].indices) {
                transposedGrid[j][i] = grid[i][j]
            }
        }
        return transposedGrid.map { it.joinToString("") }
    }

    private fun parseGrids(input: List<String>): List<List<String>> {
        val emptyIndexes =
            listOf(-1) + input.withIndex().filter { (_, b) -> b.isBlank() }.map { (i, _) -> i } + listOf(input.size)
        return emptyIndexes.zipWithNext().map { (a, b) -> input.subList(a + 1, b) }
    }

    fun part2(input: List<String>): String {
        val grids = parseGrids(input)
        return grids.sumOf { grid ->
            // Transposed is actually columns
            val transposedGrid = transpose(grid)
            scoreSmudged(grid, NORMAL_MULTIPLIER) + scoreSmudged(transposedGrid, TRANSPOSED_MULTIPLIER)
        }.toString()
    }

    private fun scoreSmudged(grid: List<String>, multiplier: Int): Int {
        val rowsOfMaybeExactness = findLinesOfExactness(grid) + findLinesOffByOne(grid)
        return rowsOfMaybeExactness.find { isAlmostMirror(it, grid, 0) }?.let {
            // Normal is rows, so rows above
            val rowsAbove = it.first + 1
            rowsAbove * multiplier
        } ?: 0
    }

    private fun findLinesOffByOne(grid: List<String>): List<Pair<Int, Int>> {
        return grid.withIndex().zipWithNext().filter { (a, b) -> isOffByOne(a.value, b.value) }
            .map { (a, b) -> a.index to b.index }
    }

    private fun isAlmostMirror(it: Pair<Int, Int>, grid: List<String>, offByOneCount: Int): Boolean {
        if (offByOneCount > 1) {
            return false
        }
        val (a, b) = it
        if (a < 0 || b >= grid.size) {
            return offByOneCount == 1
        }
        val offByOne = isOffByOne(grid[a], grid[b])
        val offByMoreThanOne = !offByOne && grid[a] != grid[b]
        if (offByMoreThanOne) {
            return false
        }
        val newCount = if (offByOne) {
            offByOneCount + 1
        } else {
            offByOneCount
        }
        return isAlmostMirror(a - 1 to b + 1, grid, newCount)
    }

    private fun isOffByOne(a: String, b: String): Boolean {
        return a.toCharArray().zip(b.toCharArray())
            .count { (a, b) -> a != b } == 1
    }
}

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

  private static final int NORMAL_MULTIPLIER;

  private static final int TRANSPOSED_MULTIPLIER;

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

  public final java.lang.String part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #26                 // Method parseGrids:(Ljava/util/List;)Ljava/util/List;
      11: astore_2
      12: aload_2
      13: checkcast     #28                 // class java/lang/Iterable
      16: astore_3
      17: iconst_0
      18: istore        4
      20: aload_3
      21: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      26: astore        5
      28: aload         5
      30: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      35: ifeq          103
      38: aload         5
      40: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      45: astore        6
      47: iload         4
      49: aload         6
      51: checkcast     #44                 // class java/util/List
      54: astore        7
      56: istore        10
      58: iconst_0
      59: istore        8
      61: getstatic     #47                 // Field INSTANCE:LDay13;
      64: aload         7
      66: invokevirtual #50                 // Method transpose:(Ljava/util/List;)Ljava/util/List;
      69: astore        9
      71: getstatic     #47                 // Field INSTANCE:LDay13;
      74: aload         7
      76: bipush        100
      78: invokespecial #54                 // Method scoreExact:(Ljava/util/List;I)I
      81: getstatic     #47                 // Field INSTANCE:LDay13;
      84: aload         9
      86: iconst_1
      87: invokespecial #54                 // Method scoreExact:(Ljava/util/List;I)I
      90: iadd
      91: istore        11
      93: iload         10
      95: iload         11
      97: iadd
      98: istore        4
     100: goto          28
     103: iload         4
     105: invokestatic  #60                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     108: areturn

  private final int scoreExact(java.util.List<java.lang.String>, int);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #70                 // Method findLinesOfExactness:(Ljava/util/List;)Ljava/util/List;
       5: checkcast     #28                 // class java/lang/Iterable
       8: astore        4
      10: aload         4
      12: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      17: astore        5
      19: aload         5
      21: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      26: ifeq          65
      29: aload         5
      31: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: astore        6
      38: aload         6
      40: checkcast     #72                 // class kotlin/Pair
      43: astore        7
      45: iconst_0
      46: istore        8
      48: getstatic     #47                 // Field INSTANCE:LDay13;
      51: aload         7
      53: aload_1
      54: invokespecial #76                 // Method isMirror:(Lkotlin/Pair;Ljava/util/List;)Z
      57: ifeq          19
      60: aload         6
      62: goto          66
      65: aconst_null
      66: checkcast     #72                 // class kotlin/Pair
      69: astore_3
      70: aload_3
      71: ifnull        100
      74: aload_3
      75: astore        5
      77: iconst_0
      78: istore        6
      80: aload         5
      82: invokevirtual #79                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      85: checkcast     #81                 // class java/lang/Number
      88: invokevirtual #85                 // Method java/lang/Number.intValue:()I
      91: iconst_1
      92: iadd
      93: istore        7
      95: iload         7
      97: iload_2
      98: imul
      99: ireturn
     100: iconst_0
     101: ireturn

  private final boolean isMirror(kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
       4: checkcast     #81                 // class java/lang/Number
       7: invokevirtual #85                 // Method java/lang/Number.intValue:()I
      10: istore_3
      11: aload_1
      12: invokevirtual #98                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      15: checkcast     #81                 // class java/lang/Number
      18: invokevirtual #85                 // Method java/lang/Number.intValue:()I
      21: istore        4
      23: iload_3
      24: iflt          38
      27: iload         4
      29: aload_2
      30: invokeinterface #101,  1          // InterfaceMethod java/util/List.size:()I
      35: if_icmplt     40
      38: iconst_1
      39: ireturn
      40: aload_2
      41: iload_3
      42: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      47: aload_2
      48: iload         4
      50: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      55: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      58: ifeq          89
      61: aload_0
      62: iload_3
      63: iconst_1
      64: isub
      65: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      68: iload         4
      70: iconst_1
      71: iadd
      72: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      75: invokestatic  #120                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      78: aload_2
      79: invokespecial #76                 // Method isMirror:(Lkotlin/Pair;Ljava/util/List;)Z
      82: ifeq          89
      85: iconst_1
      86: goto          90
      89: iconst_0
      90: ireturn

  private final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findLinesOfExactness(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #28                 // class java/lang/Iterable
       4: invokestatic  #129                // Method kotlin/collections/CollectionsKt.withIndex:(Ljava/lang/Iterable;)Ljava/lang/Iterable;
       7: invokestatic  #133                // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
      10: checkcast     #28                 // class java/lang/Iterable
      13: astore_2
      14: iconst_0
      15: istore_3
      16: aload_2
      17: astore        4
      19: new           #135                // class java/util/ArrayList
      22: dup
      23: invokespecial #136                // Method java/util/ArrayList."<init>":()V
      26: checkcast     #138                // class java/util/Collection
      29: astore        5
      31: iconst_0
      32: istore        6
      34: aload         4
      36: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          121
      53: aload         7
      55: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        8
      62: aload         8
      64: checkcast     #72                 // class kotlin/Pair
      67: astore        9
      69: iconst_0
      70: istore        10
      72: aload         9
      74: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      77: checkcast     #140                // class kotlin/collections/IndexedValue
      80: astore        11
      82: aload         9
      84: invokevirtual #98                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      87: checkcast     #140                // class kotlin/collections/IndexedValue
      90: astore        12
      92: aload         11
      94: invokevirtual #143                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
      97: aload         12
      99: invokevirtual #143                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     102: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     105: ifeq          43
     108: aload         5
     110: aload         8
     112: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     117: pop
     118: goto          43
     121: aload         5
     123: checkcast     #44                 // class java/util/List
     126: nop
     127: checkcast     #28                 // class java/lang/Iterable
     130: astore_2
     131: nop
     132: iconst_0
     133: istore_3
     134: aload_2
     135: astore        4
     137: new           #135                // class java/util/ArrayList
     140: dup
     141: aload_2
     142: bipush        10
     144: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     147: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     150: checkcast     #138                // class java/util/Collection
     153: astore        5
     155: iconst_0
     156: istore        6
     158: aload         4
     160: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     165: astore        7
     167: aload         7
     169: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     174: ifeq          251
     177: aload         7
     179: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     184: astore        8
     186: aload         5
     188: aload         8
     190: checkcast     #72                 // class kotlin/Pair
     193: astore        9
     195: astore        13
     197: iconst_0
     198: istore        10
     200: aload         9
     202: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     205: checkcast     #140                // class kotlin/collections/IndexedValue
     208: astore        11
     210: aload         9
     212: invokevirtual #98                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     215: checkcast     #140                // class kotlin/collections/IndexedValue
     218: astore        12
     220: aload         11
     222: invokevirtual #157                // Method kotlin/collections/IndexedValue.getIndex:()I
     225: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     228: aload         12
     230: invokevirtual #157                // Method kotlin/collections/IndexedValue.getIndex:()I
     233: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     236: invokestatic  #120                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     239: aload         13
     241: swap
     242: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     247: pop
     248: goto          167
     251: aload         5
     253: checkcast     #44                 // class java/util/List
     256: nop
     257: areturn

  public final java.util.List<java.lang.String> transpose(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #176                // String grid
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: iconst_0
       8: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #56                 // class java/lang/String
      16: invokevirtual #179                // Method java/lang/String.length:()I
      19: istore_3
      20: new           #135                // class java/util/ArrayList
      23: dup
      24: iload_3
      25: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
      28: astore        4
      30: iconst_0
      31: istore        5
      33: iload         5
      35: iload_3
      36: if_icmpge     75
      39: iload         5
      41: istore        6
      43: aload         4
      45: iload         6
      47: istore        7
      49: astore        12
      51: iconst_0
      52: istore        8
      54: aload_1
      55: invokeinterface #101,  1          // InterfaceMethod java/util/List.size:()I
      60: newarray       char
      62: aload         12
      64: swap
      65: invokevirtual #180                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      68: pop
      69: iinc          5, 1
      72: goto          33
      75: aload         4
      77: checkcast     #44                 // class java/util/List
      80: astore_2
      81: iconst_0
      82: istore_3
      83: aload_1
      84: checkcast     #138                // class java/util/Collection
      87: invokeinterface #181,  1          // InterfaceMethod java/util/Collection.size:()I
      92: istore        4
      94: iload_3
      95: iload         4
      97: if_icmpge     167
     100: iconst_0
     101: istore        5
     103: aload_1
     104: iconst_0
     105: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     110: checkcast     #183                // class java/lang/CharSequence
     113: invokeinterface #184,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     118: istore        6
     120: iload         5
     122: iload         6
     124: if_icmpge     161
     127: aload_2
     128: iload         5
     130: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     135: checkcast     #186                // class "[C"
     138: iload_3
     139: aload_1
     140: iload_3
     141: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     146: checkcast     #56                 // class java/lang/String
     149: iload         5
     151: invokevirtual #190                // Method java/lang/String.charAt:(I)C
     154: castore
     155: iinc          5, 1
     158: goto          120
     161: iinc          3, 1
     164: goto          94
     167: aload_2
     168: checkcast     #28                 // class java/lang/Iterable
     171: astore_3
     172: iconst_0
     173: istore        4
     175: aload_3
     176: astore        5
     178: new           #135                // class java/util/ArrayList
     181: dup
     182: aload_3
     183: bipush        10
     185: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     188: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     191: checkcast     #138                // class java/util/Collection
     194: astore        6
     196: iconst_0
     197: istore        7
     199: aload         5
     201: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     206: astore        8
     208: aload         8
     210: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     215: ifeq          271
     218: aload         8
     220: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     225: astore        9
     227: aload         6
     229: aload         9
     231: checkcast     #186                // class "[C"
     234: astore        10
     236: astore        12
     238: iconst_0
     239: istore        11
     241: aload         10
     243: ldc           #192                // String
     245: checkcast     #183                // class java/lang/CharSequence
     248: aconst_null
     249: aconst_null
     250: iconst_0
     251: aconst_null
     252: aconst_null
     253: bipush        62
     255: aconst_null
     256: invokestatic  #198                // Method kotlin/collections/ArraysKt.joinToString$default:([CLjava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     259: aload         12
     261: swap
     262: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     267: pop
     268: goto          208
     271: aload         6
     273: checkcast     #44                 // class java/util/List
     276: nop
     277: areturn

  private final java.util.List<java.util.List<java.lang.String>> parseGrids(java.util.List<java.lang.String>);
    Code:
       0: iconst_m1
       1: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       4: invokestatic  #207                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
       7: checkcast     #138                // class java/util/Collection
      10: aload_1
      11: checkcast     #28                 // class java/lang/Iterable
      14: invokestatic  #129                // Method kotlin/collections/CollectionsKt.withIndex:(Ljava/lang/Iterable;)Ljava/lang/Iterable;
      17: astore_3
      18: astore        14
      20: iconst_0
      21: istore        4
      23: aload_3
      24: astore        5
      26: new           #135                // class java/util/ArrayList
      29: dup
      30: invokespecial #136                // Method java/util/ArrayList."<init>":()V
      33: checkcast     #138                // class java/util/Collection
      36: astore        6
      38: iconst_0
      39: istore        7
      41: aload         5
      43: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        8
      50: aload         8
      52: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          113
      60: aload         8
      62: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        9
      69: aload         9
      71: checkcast     #140                // class kotlin/collections/IndexedValue
      74: astore        10
      76: iconst_0
      77: istore        11
      79: aload         10
      81: invokevirtual #208                // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;
      84: checkcast     #56                 // class java/lang/String
      87: astore        12
      89: aload         12
      91: checkcast     #183                // class java/lang/CharSequence
      94: invokestatic  #214                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      97: ifeq          50
     100: aload         6
     102: aload         9
     104: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     109: pop
     110: goto          50
     113: aload         6
     115: checkcast     #44                 // class java/util/List
     118: nop
     119: aload         14
     121: swap
     122: checkcast     #28                 // class java/lang/Iterable
     125: astore_3
     126: astore        14
     128: iconst_0
     129: istore        4
     131: aload_3
     132: astore        5
     134: new           #135                // class java/util/ArrayList
     137: dup
     138: aload_3
     139: bipush        10
     141: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     144: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     147: checkcast     #138                // class java/util/Collection
     150: astore        6
     152: iconst_0
     153: istore        7
     155: aload         5
     157: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     162: astore        8
     164: aload         8
     166: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     171: ifeq          221
     174: aload         8
     176: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     181: astore        9
     183: aload         6
     185: aload         9
     187: checkcast     #140                // class kotlin/collections/IndexedValue
     190: astore        10
     192: astore        15
     194: iconst_0
     195: istore        11
     197: aload         10
     199: invokevirtual #216                // Method kotlin/collections/IndexedValue.component1:()I
     202: istore        12
     204: iload         12
     206: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     209: aload         15
     211: swap
     212: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     217: pop
     218: goto          164
     221: aload         6
     223: checkcast     #44                 // class java/util/List
     226: nop
     227: aload         14
     229: swap
     230: checkcast     #28                 // class java/lang/Iterable
     233: invokestatic  #220                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     236: checkcast     #138                // class java/util/Collection
     239: aload_1
     240: invokeinterface #101,  1          // InterfaceMethod java/util/List.size:()I
     245: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     248: invokestatic  #207                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     251: checkcast     #28                 // class java/lang/Iterable
     254: invokestatic  #220                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     257: astore_2
     258: aload_2
     259: checkcast     #28                 // class java/lang/Iterable
     262: invokestatic  #133                // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
     265: checkcast     #28                 // class java/lang/Iterable
     268: astore_3
     269: iconst_0
     270: istore        4
     272: aload_3
     273: astore        5
     275: new           #135                // class java/util/ArrayList
     278: dup
     279: aload_3
     280: bipush        10
     282: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     285: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     288: checkcast     #138                // class java/util/Collection
     291: astore        6
     293: iconst_0
     294: istore        7
     296: aload         5
     298: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     303: astore        8
     305: aload         8
     307: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     312: ifeq          388
     315: aload         8
     317: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     322: astore        9
     324: aload         6
     326: aload         9
     328: checkcast     #72                 // class kotlin/Pair
     331: astore        10
     333: astore        14
     335: iconst_0
     336: istore        11
     338: aload         10
     340: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     343: checkcast     #81                 // class java/lang/Number
     346: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     349: istore        12
     351: aload         10
     353: invokevirtual #98                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     356: checkcast     #81                 // class java/lang/Number
     359: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     362: istore        13
     364: aload_1
     365: iload         12
     367: iconst_1
     368: iadd
     369: iload         13
     371: invokeinterface #224,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     376: aload         14
     378: swap
     379: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     384: pop
     385: goto          305
     388: aload         6
     390: checkcast     #44                 // class java/util/List
     393: nop
     394: areturn

  public final java.lang.String part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #26                 // Method parseGrids:(Ljava/util/List;)Ljava/util/List;
      11: astore_2
      12: aload_2
      13: checkcast     #28                 // class java/lang/Iterable
      16: astore_3
      17: iconst_0
      18: istore        4
      20: aload_3
      21: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      26: astore        5
      28: aload         5
      30: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      35: ifeq          103
      38: aload         5
      40: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      45: astore        6
      47: iload         4
      49: aload         6
      51: checkcast     #44                 // class java/util/List
      54: astore        7
      56: istore        10
      58: iconst_0
      59: istore        8
      61: getstatic     #47                 // Field INSTANCE:LDay13;
      64: aload         7
      66: invokevirtual #50                 // Method transpose:(Ljava/util/List;)Ljava/util/List;
      69: astore        9
      71: getstatic     #47                 // Field INSTANCE:LDay13;
      74: aload         7
      76: bipush        100
      78: invokespecial #233                // Method scoreSmudged:(Ljava/util/List;I)I
      81: getstatic     #47                 // Field INSTANCE:LDay13;
      84: aload         9
      86: iconst_1
      87: invokespecial #233                // Method scoreSmudged:(Ljava/util/List;I)I
      90: iadd
      91: istore        11
      93: iload         10
      95: iload         11
      97: iadd
      98: istore        4
     100: goto          28
     103: iload         4
     105: invokestatic  #60                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     108: areturn

  private final int scoreSmudged(java.util.List<java.lang.String>, int);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #70                 // Method findLinesOfExactness:(Ljava/util/List;)Ljava/util/List;
       5: checkcast     #138                // class java/util/Collection
       8: aload_0
       9: aload_1
      10: invokespecial #237                // Method findLinesOffByOne:(Ljava/util/List;)Ljava/util/List;
      13: checkcast     #28                 // class java/lang/Iterable
      16: invokestatic  #220                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      19: astore_3
      20: aload_3
      21: checkcast     #28                 // class java/lang/Iterable
      24: astore        4
      26: aload         4
      28: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      33: astore        5
      35: aload         5
      37: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      42: ifeq          82
      45: aload         5
      47: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      52: astore        6
      54: aload         6
      56: checkcast     #72                 // class kotlin/Pair
      59: astore        7
      61: iconst_0
      62: istore        8
      64: getstatic     #47                 // Field INSTANCE:LDay13;
      67: aload         7
      69: aload_1
      70: iconst_0
      71: invokespecial #241                // Method isAlmostMirror:(Lkotlin/Pair;Ljava/util/List;I)Z
      74: ifeq          35
      77: aload         6
      79: goto          83
      82: aconst_null
      83: checkcast     #72                 // class kotlin/Pair
      86: dup
      87: ifnull        118
      90: astore        5
      92: iconst_0
      93: istore        6
      95: aload         5
      97: invokevirtual #79                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     100: checkcast     #81                 // class java/lang/Number
     103: invokevirtual #85                 // Method java/lang/Number.intValue:()I
     106: iconst_1
     107: iadd
     108: istore        7
     110: iload         7
     112: iload_2
     113: imul
     114: nop
     115: goto          120
     118: pop
     119: iconst_0
     120: ireturn

  private final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findLinesOffByOne(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #28                 // class java/lang/Iterable
       4: invokestatic  #129                // Method kotlin/collections/CollectionsKt.withIndex:(Ljava/lang/Iterable;)Ljava/lang/Iterable;
       7: invokestatic  #133                // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
      10: checkcast     #28                 // class java/lang/Iterable
      13: astore_2
      14: iconst_0
      15: istore_3
      16: aload_2
      17: astore        4
      19: new           #135                // class java/util/ArrayList
      22: dup
      23: invokespecial #136                // Method java/util/ArrayList."<init>":()V
      26: checkcast     #138                // class java/util/Collection
      29: astore        5
      31: iconst_0
      32: istore        6
      34: aload         4
      36: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          130
      53: aload         7
      55: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        8
      62: aload         8
      64: checkcast     #72                 // class kotlin/Pair
      67: astore        9
      69: iconst_0
      70: istore        10
      72: aload         9
      74: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      77: checkcast     #140                // class kotlin/collections/IndexedValue
      80: astore        11
      82: aload         9
      84: invokevirtual #98                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      87: checkcast     #140                // class kotlin/collections/IndexedValue
      90: astore        12
      92: getstatic     #47                 // Field INSTANCE:LDay13;
      95: aload         11
      97: invokevirtual #143                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     100: checkcast     #56                 // class java/lang/String
     103: aload         12
     105: invokevirtual #143                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     108: checkcast     #56                 // class java/lang/String
     111: invokespecial #248                // Method isOffByOne:(Ljava/lang/String;Ljava/lang/String;)Z
     114: ifeq          43
     117: aload         5
     119: aload         8
     121: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     126: pop
     127: goto          43
     130: aload         5
     132: checkcast     #44                 // class java/util/List
     135: nop
     136: checkcast     #28                 // class java/lang/Iterable
     139: astore_2
     140: nop
     141: iconst_0
     142: istore_3
     143: aload_2
     144: astore        4
     146: new           #135                // class java/util/ArrayList
     149: dup
     150: aload_2
     151: bipush        10
     153: invokestatic  #151                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     156: invokespecial #154                // Method java/util/ArrayList."<init>":(I)V
     159: checkcast     #138                // class java/util/Collection
     162: astore        5
     164: iconst_0
     165: istore        6
     167: aload         4
     169: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     174: astore        7
     176: aload         7
     178: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     183: ifeq          260
     186: aload         7
     188: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     193: astore        8
     195: aload         5
     197: aload         8
     199: checkcast     #72                 // class kotlin/Pair
     202: astore        9
     204: astore        13
     206: iconst_0
     207: istore        10
     209: aload         9
     211: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     214: checkcast     #140                // class kotlin/collections/IndexedValue
     217: astore        11
     219: aload         9
     221: invokevirtual #98                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     224: checkcast     #140                // class kotlin/collections/IndexedValue
     227: astore        12
     229: aload         11
     231: invokevirtual #157                // Method kotlin/collections/IndexedValue.getIndex:()I
     234: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     237: aload         12
     239: invokevirtual #157                // Method kotlin/collections/IndexedValue.getIndex:()I
     242: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     245: invokestatic  #120                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     248: aload         13
     250: swap
     251: invokeinterface #147,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     256: pop
     257: goto          176
     260: aload         5
     262: checkcast     #44                 // class java/util/List
     265: nop
     266: areturn

  private final boolean isAlmostMirror(kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.util.List<java.lang.String>, int);
    Code:
       0: iload_3
       1: iconst_1
       2: if_icmple     7
       5: iconst_0
       6: ireturn
       7: aload_1
       8: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      11: checkcast     #81                 // class java/lang/Number
      14: invokevirtual #85                 // Method java/lang/Number.intValue:()I
      17: istore        4
      19: aload_1
      20: invokevirtual #98                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      23: checkcast     #81                 // class java/lang/Number
      26: invokevirtual #85                 // Method java/lang/Number.intValue:()I
      29: istore        5
      31: iload         4
      33: iflt          47
      36: iload         5
      38: aload_2
      39: invokeinterface #101,  1          // InterfaceMethod java/util/List.size:()I
      44: if_icmplt     58
      47: iload_3
      48: iconst_1
      49: if_icmpne     56
      52: iconst_1
      53: goto          57
      56: iconst_0
      57: ireturn
      58: aload_0
      59: aload_2
      60: iload         4
      62: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      67: checkcast     #56                 // class java/lang/String
      70: aload_2
      71: iload         5
      73: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      78: checkcast     #56                 // class java/lang/String
      81: invokespecial #248                // Method isOffByOne:(Ljava/lang/String;Ljava/lang/String;)Z
      84: istore        6
      86: iload         6
      88: ifne          117
      91: aload_2
      92: iload         4
      94: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      99: aload_2
     100: iload         5
     102: invokeinterface #105,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     107: invokestatic  #109                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     110: ifne          117
     113: iconst_1
     114: goto          118
     117: iconst_0
     118: istore        7
     120: iload         7
     122: ifeq          127
     125: iconst_0
     126: ireturn
     127: iload         6
     129: ifeq          138
     132: iload_3
     133: iconst_1
     134: iadd
     135: goto          139
     138: iload_3
     139: istore        8
     141: aload_0
     142: iload         4
     144: iconst_1
     145: isub
     146: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     149: iload         5
     151: iconst_1
     152: iadd
     153: invokestatic  #114                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     156: invokestatic  #120                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     159: aload_2
     160: iload         8
     162: invokespecial #241                // Method isAlmostMirror:(Lkotlin/Pair;Ljava/util/List;I)Z
     165: ireturn

  private final boolean isOffByOne(java.lang.String, java.lang.String);
    Code:
       0: aload_1
       1: invokevirtual #260                // Method java/lang/String.toCharArray:()[C
       4: dup
       5: ldc_w         #262                // String toCharArray(...)
       8: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      11: aload_2
      12: invokevirtual #260                // Method java/lang/String.toCharArray:()[C
      15: dup
      16: ldc_w         #262                // String toCharArray(...)
      19: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      22: invokestatic  #269                // Method kotlin/collections/ArraysKt.zip:([C[C)Ljava/util/List;
      25: checkcast     #28                 // class java/lang/Iterable
      28: astore_3
      29: nop
      30: iconst_0
      31: istore        4
      33: aload_3
      34: instanceof    #138                // class java/util/Collection
      37: ifeq          56
      40: aload_3
      41: checkcast     #138                // class java/util/Collection
      44: invokeinterface #272,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      49: ifeq          56
      52: iconst_0
      53: goto          153
      56: iconst_0
      57: istore        5
      59: aload_3
      60: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      65: astore        6
      67: aload         6
      69: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      74: ifeq          151
      77: aload         6
      79: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      84: astore        7
      86: aload         7
      88: checkcast     #72                 // class kotlin/Pair
      91: astore        8
      93: iconst_0
      94: istore        9
      96: aload         8
      98: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     101: checkcast     #274                // class java/lang/Character
     104: invokevirtual #278                // Method java/lang/Character.charValue:()C
     107: istore        10
     109: aload         8
     111: invokevirtual #98                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     114: checkcast     #274                // class java/lang/Character
     117: invokevirtual #278                // Method java/lang/Character.charValue:()C
     120: istore        11
     122: iload         10
     124: iload         11
     126: if_icmpeq     133
     129: iconst_1
     130: goto          134
     133: iconst_0
     134: ifeq          67
     137: iinc          5, 1
     140: iload         5
     142: ifge          67
     145: invokestatic  #281                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     148: goto          67
     151: iload         5
     153: iconst_1
     154: if_icmpne     161
     157: iconst_1
     158: goto          162
     161: iconst_0
     162: ireturn

  static {};
    Code:
       0: new           #2                  // class Day13
       3: dup
       4: invokespecial #289                // Method "<init>":()V
       7: putstatic     #47                 // Field INSTANCE:LDay13;
      10: return
}