object Puzzle22 {

    @JvmStatic
    fun main(args: Array<String>) {
        val input = Puzzle22::class.java.getResource("puzzle22.txt").readText()
        val decksNormalPlay = Decks(input)
        println(decksNormalPlay.calculateWinnerScoreNormalPlay())
        val decksRecursivePlay = Decks(input)
        println(decksRecursivePlay.calculateWinnerScoreRecursivePlay())
    }

    class Decks(input: String) {
        private val deck1: MutableList<Int>
        private val deck2: MutableList<Int>

        init {
            val decks = input.split("\n\n")
            deck1 = decks.first().split("\n").drop(1).map { it.toInt() }.toMutableList()
            deck2 = decks.last().split("\n").drop(1).map { it.toInt() }.toMutableList()
        }

        fun calculateWinnerScoreNormalPlay(): Int {
            playDecksNormal()
            val winnerDeck = if (deck1.isEmpty()) deck2 else deck1
            return winnerDeck.reversed().mapIndexed { index, i -> i * (index+1) }.sum()
        }

        private fun playDecksNormal() {
            while (noEmptyDeck()){
                val card1 = deck1.first()
                deck1.removeAt(0)
                val card2 = deck2.first()
                deck2.removeAt(0)
                if (card1 > card2){
                    deck1.add(card1)
                    deck1.add(card2)
                }else{
                    deck2.add(card2)
                    deck2.add(card1)
                }
            }
        }

        fun calculateWinnerScoreRecursivePlay(): Int {
            val previousConfigs = mutableSetOf<String>()
            while (noEmptyDeck()){
                val key = deck1.joinToString(", ") + " | " + deck2.joinToString(", ")
                if (previousConfigs.contains(key)){
                    deck2.clear()
                } else {
                    previousConfigs.add(key)
                    playOneRound(deck1, deck2)
                }
            }
            val winnerDeck = if (deck1.isEmpty()) deck2 else deck1
            return winnerDeck.reversed().mapIndexed { index, i -> i * (index+1) }.sum()
        }

        private fun getWinnerRecursive(subDeck1: MutableList<Int>, subDeck2: MutableList<Int>): Int {
            val previousConfigs = mutableSetOf<String>()
            while (subDeck1.isNotEmpty() && subDeck2.isNotEmpty()) {
                val key = subDeck1.joinToString(", ") + " | " + subDeck2.joinToString(", ")
                if (previousConfigs.contains(key)) {
                    return 1
                } else {
                    previousConfigs.add(key)
                    playOneRound(subDeck1, subDeck2)
                }
            }
            return if (subDeck1.isEmpty()) 2 else 1

        }

        private fun playOneRound(subDeck1: MutableList<Int>,
                                 subDeck2: MutableList<Int>
        ) {
            val card1 = subDeck1.first()
            subDeck1.removeAt(0)
            val card2 = subDeck2.first()
            subDeck2.removeAt(0)

            val winner: Int = if (subDeck1.size >= card1 && subDeck2.size >= card2) {
                getWinnerRecursive(subDeck1.take(card1).toMutableList(), subDeck2.take(card2).toMutableList())
            } else {
                if (card1 > card2) 1 else 2
            }
            if (winner == 1) {
                subDeck1.add(card1)
                subDeck1.add(card2)
            } else {
                subDeck2.add(card2)
                subDeck2.add(card1)
            }
        }

        private fun noEmptyDeck() = deck1.isNotEmpty() && deck2.isNotEmpty()
    }
}

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

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

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #16                 // String args
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #2                  // class Puzzle22
       8: ldc           #24                 // String puzzle22.txt
      10: invokevirtual #30                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      13: dup
      14: ldc           #32                 // String getResource(...)
      16: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      19: astore_2
      20: getstatic     #41                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      23: astore_3
      24: aload_2
      25: invokestatic  #47                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      28: astore        4
      30: new           #49                 // class java/lang/String
      33: dup
      34: aload         4
      36: aload_3
      37: invokespecial #52                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      40: astore_1
      41: new           #54                 // class Puzzle22$Decks
      44: dup
      45: aload_1
      46: invokespecial #57                 // Method Puzzle22$Decks."<init>":(Ljava/lang/String;)V
      49: astore_2
      50: aload_2
      51: invokevirtual #61                 // Method Puzzle22$Decks.calculateWinnerScoreNormalPlay:()I
      54: istore_3
      55: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      58: iload_3
      59: invokevirtual #73                 // Method java/io/PrintStream.println:(I)V
      62: new           #54                 // class Puzzle22$Decks
      65: dup
      66: aload_1
      67: invokespecial #57                 // Method Puzzle22$Decks."<init>":(Ljava/lang/String;)V
      70: astore_3
      71: aload_3
      72: invokevirtual #76                 // Method Puzzle22$Decks.calculateWinnerScoreRecursivePlay:()I
      75: istore        4
      77: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      80: iload         4
      82: invokevirtual #73                 // Method java/io/PrintStream.println:(I)V
      85: return

  static {};
    Code:
       0: new           #2                  // class Puzzle22
       3: dup
       4: invokespecial #84                 // Method "<init>":()V
       7: putstatic     #87                 // Field INSTANCE:LPuzzle22;
      10: return
}

Compiled from "Puzzle22.kt"
public final class Puzzle22$Decks {
  private final java.util.List<java.lang.Integer> deck1;

  private final java.util.List<java.lang.Integer> deck2;

  public Puzzle22$Decks(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #9                  // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: nop
      11: aload_1
      12: checkcast     #20                 // class java/lang/CharSequence
      15: iconst_1
      16: anewarray     #22                 // class java/lang/String
      19: astore_3
      20: aload_3
      21: iconst_0
      22: ldc           #24                 // String \n\n
      24: aastore
      25: aload_3
      26: iconst_0
      27: iconst_0
      28: bipush        6
      30: aconst_null
      31: invokestatic  #30                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      34: astore_2
      35: aload_0
      36: aload_2
      37: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      40: checkcast     #20                 // class java/lang/CharSequence
      43: iconst_1
      44: anewarray     #22                 // class java/lang/String
      47: astore_3
      48: aload_3
      49: iconst_0
      50: ldc           #38                 // String \n
      52: aastore
      53: aload_3
      54: iconst_0
      55: iconst_0
      56: bipush        6
      58: aconst_null
      59: invokestatic  #30                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      62: checkcast     #40                 // class java/lang/Iterable
      65: iconst_1
      66: invokestatic  #44                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      69: checkcast     #40                 // class java/lang/Iterable
      72: astore_3
      73: astore        12
      75: iconst_0
      76: istore        4
      78: aload_3
      79: astore        5
      81: new           #46                 // class java/util/ArrayList
      84: dup
      85: aload_3
      86: bipush        10
      88: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      91: invokespecial #53                 // Method java/util/ArrayList."<init>":(I)V
      94: checkcast     #55                 // class java/util/Collection
      97: astore        6
      99: iconst_0
     100: istore        7
     102: aload         5
     104: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     109: astore        8
     111: aload         8
     113: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     118: ifeq          165
     121: aload         8
     123: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     128: astore        9
     130: aload         6
     132: aload         9
     134: checkcast     #22                 // class java/lang/String
     137: astore        10
     139: astore        13
     141: iconst_0
     142: istore        11
     144: aload         10
     146: invokestatic  #75                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     149: nop
     150: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     153: aload         13
     155: swap
     156: invokeinterface #83,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     161: pop
     162: goto          111
     165: aload         6
     167: checkcast     #85                 // class java/util/List
     170: nop
     171: aload         12
     173: swap
     174: checkcast     #55                 // class java/util/Collection
     177: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     180: putfield      #93                 // Field deck1:Ljava/util/List;
     183: aload_0
     184: aload_2
     185: invokestatic  #96                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     188: checkcast     #20                 // class java/lang/CharSequence
     191: iconst_1
     192: anewarray     #22                 // class java/lang/String
     195: astore_3
     196: aload_3
     197: iconst_0
     198: ldc           #38                 // String \n
     200: aastore
     201: aload_3
     202: iconst_0
     203: iconst_0
     204: bipush        6
     206: aconst_null
     207: invokestatic  #30                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     210: checkcast     #40                 // class java/lang/Iterable
     213: iconst_1
     214: invokestatic  #44                 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     217: checkcast     #40                 // class java/lang/Iterable
     220: astore_3
     221: astore        12
     223: iconst_0
     224: istore        4
     226: aload_3
     227: astore        5
     229: new           #46                 // class java/util/ArrayList
     232: dup
     233: aload_3
     234: bipush        10
     236: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     239: invokespecial #53                 // Method java/util/ArrayList."<init>":(I)V
     242: checkcast     #55                 // class java/util/Collection
     245: astore        6
     247: iconst_0
     248: istore        7
     250: aload         5
     252: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     257: astore        8
     259: aload         8
     261: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     266: ifeq          313
     269: aload         8
     271: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     276: astore        9
     278: aload         6
     280: aload         9
     282: checkcast     #22                 // class java/lang/String
     285: astore        10
     287: astore        13
     289: iconst_0
     290: istore        11
     292: aload         10
     294: invokestatic  #75                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     297: nop
     298: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     301: aload         13
     303: swap
     304: invokeinterface #83,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     309: pop
     310: goto          259
     313: aload         6
     315: checkcast     #85                 // class java/util/List
     318: nop
     319: aload         12
     321: swap
     322: checkcast     #55                 // class java/util/Collection
     325: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     328: putfield      #99                 // Field deck2:Ljava/util/List;
     331: nop
     332: return

  public final int calculateWinnerScoreNormalPlay();
    Code:
       0: aload_0
       1: invokespecial #121                // Method playDecksNormal:()V
       4: aload_0
       5: getfield      #93                 // Field deck1:Ljava/util/List;
       8: invokeinterface #124,  1          // InterfaceMethod java/util/List.isEmpty:()Z
      13: ifeq          23
      16: aload_0
      17: getfield      #99                 // Field deck2:Ljava/util/List;
      20: goto          27
      23: aload_0
      24: getfield      #93                 // Field deck1:Ljava/util/List;
      27: astore_1
      28: aload_1
      29: checkcast     #40                 // class java/lang/Iterable
      32: invokestatic  #128                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
      35: checkcast     #40                 // class java/lang/Iterable
      38: astore_2
      39: iconst_0
      40: istore_3
      41: aload_2
      42: astore        4
      44: new           #46                 // class java/util/ArrayList
      47: dup
      48: aload_2
      49: bipush        10
      51: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      54: invokespecial #53                 // Method java/util/ArrayList."<init>":(I)V
      57: checkcast     #55                 // class java/util/Collection
      60: astore        5
      62: iconst_0
      63: istore        6
      65: iconst_0
      66: istore        7
      68: aload         4
      70: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      75: astore        8
      77: aload         8
      79: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      84: ifeq          154
      87: aload         8
      89: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      94: astore        9
      96: aload         5
      98: iload         7
     100: iinc          7, 1
     103: istore        10
     105: iload         10
     107: ifge          113
     110: invokestatic  #131                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     113: iload         10
     115: aload         9
     117: checkcast     #133                // class java/lang/Number
     120: invokevirtual #136                // Method java/lang/Number.intValue:()I
     123: istore        11
     125: istore        12
     127: astore        14
     129: iconst_0
     130: istore        13
     132: iload         11
     134: iload         12
     136: iconst_1
     137: iadd
     138: imul
     139: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     142: aload         14
     144: swap
     145: invokeinterface #83,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     150: pop
     151: goto          77
     154: aload         5
     156: checkcast     #85                 // class java/util/List
     159: nop
     160: checkcast     #40                 // class java/lang/Iterable
     163: invokestatic  #140                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     166: ireturn

  private final void playDecksNormal();
    Code:
       0: aload_0
       1: invokespecial #152                // Method noEmptyDeck:()Z
       4: ifeq          123
       7: aload_0
       8: getfield      #93                 // Field deck1:Ljava/util/List;
      11: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      14: checkcast     #133                // class java/lang/Number
      17: invokevirtual #136                // Method java/lang/Number.intValue:()I
      20: istore_1
      21: aload_0
      22: getfield      #93                 // Field deck1:Ljava/util/List;
      25: iconst_0
      26: invokeinterface #156,  2          // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
      31: pop
      32: aload_0
      33: getfield      #99                 // Field deck2:Ljava/util/List;
      36: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      39: checkcast     #133                // class java/lang/Number
      42: invokevirtual #136                // Method java/lang/Number.intValue:()I
      45: istore_2
      46: aload_0
      47: getfield      #99                 // Field deck2:Ljava/util/List;
      50: iconst_0
      51: invokeinterface #156,  2          // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
      56: pop
      57: iload_1
      58: iload_2
      59: if_icmple     92
      62: aload_0
      63: getfield      #93                 // Field deck1:Ljava/util/List;
      66: iload_1
      67: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      70: invokeinterface #157,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      75: pop
      76: aload_0
      77: getfield      #93                 // Field deck1:Ljava/util/List;
      80: iload_2
      81: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      84: invokeinterface #157,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      89: goto          119
      92: aload_0
      93: getfield      #99                 // Field deck2:Ljava/util/List;
      96: iload_2
      97: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     100: invokeinterface #157,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     105: pop
     106: aload_0
     107: getfield      #99                 // Field deck2:Ljava/util/List;
     110: iload_1
     111: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     114: invokeinterface #157,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     119: pop
     120: goto          0
     123: return

  public final int calculateWinnerScoreRecursivePlay();
    Code:
       0: new           #162                // class java/util/LinkedHashSet
       3: dup
       4: invokespecial #163                // Method java/util/LinkedHashSet."<init>":()V
       7: checkcast     #165                // class java/util/Set
      10: astore_1
      11: aload_0
      12: invokespecial #152                // Method noEmptyDeck:()Z
      15: ifeq          131
      18: new           #167                // class java/lang/StringBuilder
      21: dup
      22: invokespecial #168                // Method java/lang/StringBuilder."<init>":()V
      25: aload_0
      26: getfield      #93                 // Field deck1:Ljava/util/List;
      29: checkcast     #40                 // class java/lang/Iterable
      32: ldc           #170                // String ,
      34: checkcast     #20                 // class java/lang/CharSequence
      37: aconst_null
      38: aconst_null
      39: iconst_0
      40: aconst_null
      41: aconst_null
      42: bipush        62
      44: aconst_null
      45: invokestatic  #174                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      48: invokevirtual #178                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      51: ldc           #180                // String  |
      53: invokevirtual #178                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      56: aload_0
      57: getfield      #99                 // Field deck2:Ljava/util/List;
      60: checkcast     #40                 // class java/lang/Iterable
      63: ldc           #170                // String ,
      65: checkcast     #20                 // class java/lang/CharSequence
      68: aconst_null
      69: aconst_null
      70: iconst_0
      71: aconst_null
      72: aconst_null
      73: bipush        62
      75: aconst_null
      76: invokestatic  #174                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      79: invokevirtual #178                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      82: invokevirtual #184                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      85: astore_2
      86: aload_1
      87: aload_2
      88: invokeinterface #187,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      93: ifeq          108
      96: aload_0
      97: getfield      #99                 // Field deck2:Ljava/util/List;
     100: invokeinterface #190,  1          // InterfaceMethod java/util/List.clear:()V
     105: goto          11
     108: aload_1
     109: aload_2
     110: invokeinterface #191,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     115: pop
     116: aload_0
     117: aload_0
     118: getfield      #93                 // Field deck1:Ljava/util/List;
     121: aload_0
     122: getfield      #99                 // Field deck2:Ljava/util/List;
     125: invokespecial #195                // Method playOneRound:(Ljava/util/List;Ljava/util/List;)V
     128: goto          11
     131: aload_0
     132: getfield      #93                 // Field deck1:Ljava/util/List;
     135: invokeinterface #124,  1          // InterfaceMethod java/util/List.isEmpty:()Z
     140: ifeq          150
     143: aload_0
     144: getfield      #99                 // Field deck2:Ljava/util/List;
     147: goto          154
     150: aload_0
     151: getfield      #93                 // Field deck1:Ljava/util/List;
     154: astore_2
     155: aload_2
     156: checkcast     #40                 // class java/lang/Iterable
     159: invokestatic  #128                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     162: checkcast     #40                 // class java/lang/Iterable
     165: astore_3
     166: iconst_0
     167: istore        4
     169: aload_3
     170: astore        5
     172: new           #46                 // class java/util/ArrayList
     175: dup
     176: aload_3
     177: bipush        10
     179: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     182: invokespecial #53                 // Method java/util/ArrayList."<init>":(I)V
     185: checkcast     #55                 // class java/util/Collection
     188: astore        6
     190: iconst_0
     191: istore        7
     193: iconst_0
     194: istore        8
     196: aload         5
     198: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     203: astore        9
     205: aload         9
     207: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     212: ifeq          282
     215: aload         9
     217: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     222: astore        10
     224: aload         6
     226: iload         8
     228: iinc          8, 1
     231: istore        11
     233: iload         11
     235: ifge          241
     238: invokestatic  #131                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     241: iload         11
     243: aload         10
     245: checkcast     #133                // class java/lang/Number
     248: invokevirtual #136                // Method java/lang/Number.intValue:()I
     251: istore        12
     253: istore        13
     255: astore        15
     257: iconst_0
     258: istore        14
     260: iload         12
     262: iload         13
     264: iconst_1
     265: iadd
     266: imul
     267: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     270: aload         15
     272: swap
     273: invokeinterface #83,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     278: pop
     279: goto          205
     282: aload         6
     284: checkcast     #85                 // class java/util/List
     287: nop
     288: checkcast     #40                 // class java/lang/Iterable
     291: invokestatic  #140                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     294: ireturn

  private final int getWinnerRecursive(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);
    Code:
       0: new           #162                // class java/util/LinkedHashSet
       3: dup
       4: invokespecial #163                // Method java/util/LinkedHashSet."<init>":()V
       7: checkcast     #165                // class java/util/Set
      10: astore_3
      11: aload_1
      12: checkcast     #55                 // class java/util/Collection
      15: invokeinterface #203,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      20: ifne          27
      23: iconst_1
      24: goto          28
      27: iconst_0
      28: ifeq          145
      31: aload_2
      32: checkcast     #55                 // class java/util/Collection
      35: invokeinterface #203,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      40: ifne          47
      43: iconst_1
      44: goto          48
      47: iconst_0
      48: ifeq          145
      51: new           #167                // class java/lang/StringBuilder
      54: dup
      55: invokespecial #168                // Method java/lang/StringBuilder."<init>":()V
      58: aload_1
      59: checkcast     #40                 // class java/lang/Iterable
      62: ldc           #170                // String ,
      64: checkcast     #20                 // class java/lang/CharSequence
      67: aconst_null
      68: aconst_null
      69: iconst_0
      70: aconst_null
      71: aconst_null
      72: bipush        62
      74: aconst_null
      75: invokestatic  #174                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      78: invokevirtual #178                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      81: ldc           #180                // String  |
      83: invokevirtual #178                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      86: aload_2
      87: checkcast     #40                 // class java/lang/Iterable
      90: ldc           #170                // String ,
      92: checkcast     #20                 // class java/lang/CharSequence
      95: aconst_null
      96: aconst_null
      97: iconst_0
      98: aconst_null
      99: aconst_null
     100: bipush        62
     102: aconst_null
     103: invokestatic  #174                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     106: invokevirtual #178                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     109: invokevirtual #184                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     112: astore        4
     114: aload_3
     115: aload         4
     117: invokeinterface #187,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     122: ifeq          127
     125: iconst_1
     126: ireturn
     127: aload_3
     128: aload         4
     130: invokeinterface #191,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     135: pop
     136: aload_0
     137: aload_1
     138: aload_2
     139: invokespecial #195                // Method playOneRound:(Ljava/util/List;Ljava/util/List;)V
     142: goto          11
     145: aload_1
     146: invokeinterface #124,  1          // InterfaceMethod java/util/List.isEmpty:()Z
     151: ifeq          158
     154: iconst_2
     155: goto          159
     158: iconst_1
     159: ireturn

  private final void playOneRound(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);
    Code:
       0: aload_1
       1: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
       4: checkcast     #133                // class java/lang/Number
       7: invokevirtual #136                // Method java/lang/Number.intValue:()I
      10: istore_3
      11: aload_1
      12: iconst_0
      13: invokeinterface #156,  2          // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
      18: pop
      19: aload_2
      20: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      23: checkcast     #133                // class java/lang/Number
      26: invokevirtual #136                // Method java/lang/Number.intValue:()I
      29: istore        4
      31: aload_2
      32: iconst_0
      33: invokeinterface #156,  2          // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;
      38: pop
      39: aload_1
      40: invokeinterface #209,  1          // InterfaceMethod java/util/List.size:()I
      45: iload_3
      46: if_icmplt     96
      49: aload_2
      50: invokeinterface #209,  1          // InterfaceMethod java/util/List.size:()I
      55: iload         4
      57: if_icmplt     96
      60: aload_0
      61: aload_1
      62: checkcast     #40                 // class java/lang/Iterable
      65: iload_3
      66: invokestatic  #212                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
      69: checkcast     #55                 // class java/util/Collection
      72: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      75: aload_2
      76: checkcast     #40                 // class java/lang/Iterable
      79: iload         4
      81: invokestatic  #212                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
      84: checkcast     #55                 // class java/util/Collection
      87: invokestatic  #89                 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      90: invokespecial #214                // Method getWinnerRecursive:(Ljava/util/List;Ljava/util/List;)I
      93: goto          107
      96: iload_3
      97: iload         4
      99: if_icmple     106
     102: iconst_1
     103: goto          107
     106: iconst_2
     107: istore        5
     109: iload         5
     111: iconst_1
     112: if_icmpne     140
     115: aload_1
     116: iload_3
     117: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     120: invokeinterface #157,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     125: pop
     126: aload_1
     127: iload         4
     129: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     132: invokeinterface #157,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     137: goto          162
     140: aload_2
     141: iload         4
     143: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     146: invokeinterface #157,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     151: pop
     152: aload_2
     153: iload_3
     154: invokestatic  #79                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     157: invokeinterface #157,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     162: pop
     163: return

  private final boolean noEmptyDeck();
    Code:
       0: aload_0
       1: getfield      #93                 // Field deck1:Ljava/util/List;
       4: checkcast     #55                 // class java/util/Collection
       7: invokeinterface #203,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      12: ifne          19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifeq          50
      23: aload_0
      24: getfield      #99                 // Field deck2:Ljava/util/List;
      27: checkcast     #55                 // class java/util/Collection
      30: invokeinterface #203,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      35: ifne          42
      38: iconst_1
      39: goto          43
      42: iconst_0
      43: ifeq          50
      46: iconst_1
      47: goto          51
      50: iconst_0
      51: ireturn
}


import kotlin.math.absoluteValue

object Puzzle12 {

    @JvmStatic
    fun main(args: Array<String>) {
        val input = Puzzle12::class.java.getResource("puzzle12.txt").readText()
        val calculatedDistance = calculateDistance(input)
        println(calculatedDistance)
        val calculateDistanceWithWaypoint = calculateDistanceWithWaypoint(input)
        println(calculateDistanceWithWaypoint)
    }

    enum class Command {
        N, S, E, W, L, R, F
    }
    enum class Direction {
        N {
            override fun toCommand() = Command.N
        },
        S {
            override fun toCommand() = Command.S
        },
        E {
            override fun toCommand() = Command.E
        },
        W {
            override fun toCommand() = Command.W
        };

        abstract fun toCommand() : Command
    }

    class ShipData(
        private var headTo: Direction,
        private var posEast: Int,
        private var posNorth: Int,
        private var waypointPosEast: Int = 0,
        private var waypointPosNorth: Int = 0){

        fun getDistance() = posEast.absoluteValue + posNorth.absoluteValue

        fun move(command: Command, i: Int){
            when (command) {
                Command.N -> { posNorth += i }
                Command.S -> { posNorth -= i }
                Command.E -> { posEast += i }
                Command.W -> { posEast -= i }
                Command.L -> {
                    val cnt = (i / 90)
                    val newHeadTo = (headTo.ordinal + cnt ) % 4
                    headTo = Direction.values()[newHeadTo]
                }
                Command.R -> {
                    val cnt = (i / 90)
                    val newHeadTo = (headTo.ordinal - cnt + 4 * cnt ) % 4
                    headTo = Direction.values()[newHeadTo]
                }
                Command.F -> {
                    move(headTo.toCommand(), i)
                }
            }
        }

        fun moveWithWaypoint(command: Command, i: Int){
            when (command) {
                Command.N -> { waypointPosNorth += i }
                Command.S -> { waypointPosNorth -= i }
                Command.E -> { waypointPosEast += i }
                Command.W -> { waypointPosEast -= i }
                Command.L -> {
                    moveWithWaypoint(Command.R, -i)
                }
                Command.R -> {
                    var num = i
                    if (i < 0) num = i + 360
                    when ((num / 90)){
                        1 -> {
                            val oldWaypointPosNorth = waypointPosNorth
                            val oldWaypointPosEast = waypointPosEast
                            waypointPosNorth = -oldWaypointPosEast
                            waypointPosEast = oldWaypointPosNorth
                        }
                        2 -> {
                            val oldWaypointPosNorth = waypointPosNorth
                            val oldWaypointPosEast = waypointPosEast
                            waypointPosNorth = -oldWaypointPosNorth
                            waypointPosEast = -oldWaypointPosEast
                        }
                        3 -> {
                            val oldWaypointPosNorth = waypointPosNorth
                            val oldWaypointPosEast = waypointPosEast
                            waypointPosNorth = oldWaypointPosEast
                            waypointPosEast = -oldWaypointPosNorth
                        }
                    }
                }
                Command.F -> {
                    posNorth += i * waypointPosNorth
                    posEast += i * waypointPosEast
                }
            }
        }
    }

    fun calculateDistance(input: String): Int {
        val commands = input.split("\n")
        val shipData = ShipData(Direction.E, 0, 0)
        commands.forEach { commandString ->
            val command = commandString.first().toString()
            val number = commandString.substring(1).toInt()
            shipData.move(Command.valueOf(command), number)
        }
        return shipData.getDistance()
    }

    fun calculateDistanceWithWaypoint(input: String): Int {
        val commands = input.split("\n")
        val shipData = ShipData(Direction.E, 0, 0, 10, 1)
        commands.forEach { commandString ->
            val command = commandString.first().toString()
            val number = commandString.substring(1).toInt()
            shipData.moveWithWaypoint(Command.valueOf(command), number)
        }
        return shipData.getDistance()
    }
}

Compiled from "Puzzle12.kt"
public final class Puzzle12$ShipData {
  private Puzzle12$Direction headTo;

  private int posEast;

  private int posNorth;

  private int waypointPosEast;

  private int waypointPosNorth;

  public Puzzle12$ShipData(Puzzle12$Direction, int, int, int, int);
    Code:
       0: aload_1
       1: ldc           #9                  // String headTo
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #21                 // Field headTo:LPuzzle12$Direction;
      15: aload_0
      16: iload_2
      17: putfield      #25                 // Field posEast:I
      20: aload_0
      21: iload_3
      22: putfield      #28                 // Field posNorth:I
      25: aload_0
      26: iload         4
      28: putfield      #31                 // Field waypointPosEast:I
      31: aload_0
      32: iload         5
      34: putfield      #34                 // Field waypointPosNorth:I
      37: return

  public Puzzle12$ShipData(Puzzle12$Direction, int, int, int, int, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         6
       2: bipush        8
       4: iand
       5: ifeq          11
       8: iconst_0
       9: istore        4
      11: iload         6
      13: bipush        16
      15: iand
      16: ifeq          22
      19: iconst_0
      20: istore        5
      22: aload_0
      23: aload_1
      24: iload_2
      25: iload_3
      26: iload         4
      28: iload         5
      30: invokespecial #39                 // Method "<init>":(LPuzzle12$Direction;IIII)V
      33: return

  public final int getDistance();
    Code:
       0: aload_0
       1: getfield      #25                 // Field posEast:I
       4: invokestatic  #47                 // Method java/lang/Math.abs:(I)I
       7: aload_0
       8: getfield      #28                 // Field posNorth:I
      11: invokestatic  #47                 // Method java/lang/Math.abs:(I)I
      14: iadd
      15: ireturn

  public final void move(Puzzle12$Command, int);
    Code:
       0: aload_1
       1: ldc           #51                 // String command
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: getstatic     #57                 // Field Puzzle12$ShipData$WhenMappings.$EnumSwitchMapping$0:[I
      10: swap
      11: invokevirtual #62                 // Method Puzzle12$Command.ordinal:()I
      14: iaload
      15: tableswitch   { // 1 to 7
                     1: 56
                     2: 69
                     3: 82
                     4: 95
                     5: 108
                     6: 139
                     7: 174
               default: 189
          }
      56: aload_0
      57: aload_0
      58: getfield      #28                 // Field posNorth:I
      61: iload_2
      62: iadd
      63: putfield      #28                 // Field posNorth:I
      66: goto          197
      69: aload_0
      70: aload_0
      71: getfield      #28                 // Field posNorth:I
      74: iload_2
      75: isub
      76: putfield      #28                 // Field posNorth:I
      79: goto          197
      82: aload_0
      83: aload_0
      84: getfield      #25                 // Field posEast:I
      87: iload_2
      88: iadd
      89: putfield      #25                 // Field posEast:I
      92: goto          197
      95: aload_0
      96: aload_0
      97: getfield      #25                 // Field posEast:I
     100: iload_2
     101: isub
     102: putfield      #25                 // Field posEast:I
     105: goto          197
     108: iload_2
     109: bipush        90
     111: idiv
     112: istore_3
     113: aload_0
     114: getfield      #21                 // Field headTo:LPuzzle12$Direction;
     117: invokevirtual #65                 // Method Puzzle12$Direction.ordinal:()I
     120: iload_3
     121: iadd
     122: iconst_4
     123: irem
     124: istore        4
     126: aload_0
     127: invokestatic  #69                 // Method Puzzle12$Direction.values:()[LPuzzle12$Direction;
     130: iload         4
     132: aaload
     133: putfield      #21                 // Field headTo:LPuzzle12$Direction;
     136: goto          197
     139: iload_2
     140: bipush        90
     142: idiv
     143: istore_3
     144: aload_0
     145: getfield      #21                 // Field headTo:LPuzzle12$Direction;
     148: invokevirtual #65                 // Method Puzzle12$Direction.ordinal:()I
     151: iload_3
     152: isub
     153: iconst_4
     154: iload_3
     155: imul
     156: iadd
     157: iconst_4
     158: irem
     159: istore        4
     161: aload_0
     162: invokestatic  #69                 // Method Puzzle12$Direction.values:()[LPuzzle12$Direction;
     165: iload         4
     167: aaload
     168: putfield      #21                 // Field headTo:LPuzzle12$Direction;
     171: goto          197
     174: aload_0
     175: aload_0
     176: getfield      #21                 // Field headTo:LPuzzle12$Direction;
     179: invokevirtual #73                 // Method Puzzle12$Direction.toCommand:()LPuzzle12$Command;
     182: iload_2
     183: invokevirtual #75                 // Method move:(LPuzzle12$Command;I)V
     186: goto          197
     189: new           #77                 // class kotlin/NoWhenBranchMatchedException
     192: dup
     193: invokespecial #78                 // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     196: athrow
     197: return

  public final void moveWithWaypoint(Puzzle12$Command, int);
    Code:
       0: aload_1
       1: ldc           #51                 // String command
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: getstatic     #57                 // Field Puzzle12$ShipData$WhenMappings.$EnumSwitchMapping$0:[I
      10: swap
      11: invokevirtual #62                 // Method Puzzle12$Command.ordinal:()I
      14: iaload
      15: tableswitch   { // 1 to 7
                     1: 56
                     2: 69
                     3: 82
                     4: 95
                     5: 108
                     6: 120
                     7: 249
               default: 282
          }
      56: aload_0
      57: aload_0
      58: getfield      #34                 // Field waypointPosNorth:I
      61: iload_2
      62: iadd
      63: putfield      #34                 // Field waypointPosNorth:I
      66: goto          290
      69: aload_0
      70: aload_0
      71: getfield      #34                 // Field waypointPosNorth:I
      74: iload_2
      75: isub
      76: putfield      #34                 // Field waypointPosNorth:I
      79: goto          290
      82: aload_0
      83: aload_0
      84: getfield      #31                 // Field waypointPosEast:I
      87: iload_2
      88: iadd
      89: putfield      #31                 // Field waypointPosEast:I
      92: goto          290
      95: aload_0
      96: aload_0
      97: getfield      #31                 // Field waypointPosEast:I
     100: iload_2
     101: isub
     102: putfield      #31                 // Field waypointPosEast:I
     105: goto          290
     108: aload_0
     109: getstatic     #86                 // Field Puzzle12$Command.R:LPuzzle12$Command;
     112: iload_2
     113: ineg
     114: invokevirtual #88                 // Method moveWithWaypoint:(LPuzzle12$Command;I)V
     117: goto          290
     120: iload_2
     121: istore_3
     122: iload_2
     123: ifge          132
     126: iload_2
     127: sipush        360
     130: iadd
     131: istore_3
     132: iload_3
     133: bipush        90
     135: idiv
     136: tableswitch   { // 1 to 3
                     1: 164
                     2: 192
                     3: 221
               default: 246
          }
     164: aload_0
     165: getfield      #34                 // Field waypointPosNorth:I
     168: istore        4
     170: aload_0
     171: getfield      #31                 // Field waypointPosEast:I
     174: istore        5
     176: aload_0
     177: iload         5
     179: ineg
     180: putfield      #34                 // Field waypointPosNorth:I
     183: aload_0
     184: iload         4
     186: putfield      #31                 // Field waypointPosEast:I
     189: goto          290
     192: aload_0
     193: getfield      #34                 // Field waypointPosNorth:I
     196: istore        4
     198: aload_0
     199: getfield      #31                 // Field waypointPosEast:I
     202: istore        5
     204: aload_0
     205: iload         4
     207: ineg
     208: putfield      #34                 // Field waypointPosNorth:I
     211: aload_0
     212: iload         5
     214: ineg
     215: putfield      #31                 // Field waypointPosEast:I
     218: goto          290
     221: aload_0
     222: getfield      #34                 // Field waypointPosNorth:I
     225: istore        4
     227: aload_0
     228: getfield      #31                 // Field waypointPosEast:I
     231: istore        5
     233: aload_0
     234: iload         5
     236: putfield      #34                 // Field waypointPosNorth:I
     239: aload_0
     240: iload         4
     242: ineg
     243: putfield      #31                 // Field waypointPosEast:I
     246: goto          290
     249: aload_0
     250: aload_0
     251: getfield      #28                 // Field posNorth:I
     254: iload_2
     255: aload_0
     256: getfield      #34                 // Field waypointPosNorth:I
     259: imul
     260: iadd
     261: putfield      #28                 // Field posNorth:I
     264: aload_0
     265: aload_0
     266: getfield      #25                 // Field posEast:I
     269: iload_2
     270: aload_0
     271: getfield      #31                 // Field waypointPosEast:I
     274: imul
     275: iadd
     276: putfield      #25                 // Field posEast:I
     279: goto          290
     282: new           #77                 // class kotlin/NoWhenBranchMatchedException
     285: dup
     286: invokespecial #78                 // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     289: athrow
     290: return
}

Compiled from "Puzzle12.kt"
final class Puzzle12$Direction$N extends Puzzle12$Direction {
  Puzzle12$Direction$N();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: aconst_null
       4: invokespecial #10                 // Method Puzzle12$Direction."<init>":(Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
       7: return

  public Puzzle12$Command toCommand();
    Code:
       0: getstatic     #25                 // Field Puzzle12$Command.N:LPuzzle12$Command;
       3: areturn
}

Compiled from "Puzzle12.kt"
final class Puzzle12$Direction$W extends Puzzle12$Direction {
  Puzzle12$Direction$W();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: aconst_null
       4: invokespecial #10                 // Method Puzzle12$Direction."<init>":(Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
       7: return

  public Puzzle12$Command toCommand();
    Code:
       0: getstatic     #25                 // Field Puzzle12$Command.W:LPuzzle12$Command;
       3: areturn
}

Compiled from "Puzzle12.kt"
final class Puzzle12$Direction$S extends Puzzle12$Direction {
  Puzzle12$Direction$S();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: aconst_null
       4: invokespecial #10                 // Method Puzzle12$Direction."<init>":(Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
       7: return

  public Puzzle12$Command toCommand();
    Code:
       0: getstatic     #25                 // Field Puzzle12$Command.S:LPuzzle12$Command;
       3: areturn
}

Compiled from "Puzzle12.kt"
public abstract class Puzzle12$Direction extends java.lang.Enum<Puzzle12$Direction> {
  public static final Puzzle12$Direction N;

  public static final Puzzle12$Direction S;

  public static final Puzzle12$Direction E;

  public static final Puzzle12$Direction W;

  private static final Puzzle12$Direction[] $VALUES;

  private static final kotlin.enums.EnumEntries $ENTRIES;

  private Puzzle12$Direction();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: invokespecial #10                 // Method java/lang/Enum."<init>":(Ljava/lang/String;I)V
       6: return

  public abstract Puzzle12$Command toCommand();

  public static Puzzle12$Direction[] values();
    Code:
       0: getstatic     #25                 // Field $VALUES:[LPuzzle12$Direction;
       3: invokevirtual #31                 // Method java/lang/Object.clone:()Ljava/lang/Object;
       6: checkcast     #32                 // class "[LPuzzle12$Direction;"
       9: areturn

  public static Puzzle12$Direction valueOf(java.lang.String);
    Code:
       0: ldc           #2                  // class Puzzle12$Direction
       2: aload_0
       3: invokestatic  #37                 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
       6: checkcast     #2                  // class Puzzle12$Direction
       9: areturn

  public static kotlin.enums.EnumEntries<Puzzle12$Direction> getEntries();
    Code:
       0: getstatic     #45                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
       3: areturn

  private static final Puzzle12$Direction[] $values();
    Code:
       0: iconst_4
       1: anewarray     #2                  // class Puzzle12$Direction
       4: astore_0
       5: aload_0
       6: iconst_0
       7: getstatic     #49                 // Field N:LPuzzle12$Direction;
      10: aastore
      11: aload_0
      12: iconst_1
      13: getstatic     #52                 // Field S:LPuzzle12$Direction;
      16: aastore
      17: aload_0
      18: iconst_2
      19: getstatic     #55                 // Field E:LPuzzle12$Direction;
      22: aastore
      23: aload_0
      24: iconst_3
      25: getstatic     #58                 // Field W:LPuzzle12$Direction;
      28: aastore
      29: aload_0
      30: areturn

  public Puzzle12$Direction(java.lang.String, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: invokespecial #60                 // Method "<init>":(Ljava/lang/String;I)V
       6: return

  static {};
    Code:
       0: new           #65                 // class Puzzle12$Direction$N
       3: dup
       4: ldc           #66                 // String N
       6: iconst_0
       7: invokespecial #67                 // Method Puzzle12$Direction$N."<init>":(Ljava/lang/String;I)V
      10: putstatic     #49                 // Field N:LPuzzle12$Direction;
      13: new           #69                 // class Puzzle12$Direction$S
      16: dup
      17: ldc           #70                 // String S
      19: iconst_1
      20: invokespecial #71                 // Method Puzzle12$Direction$S."<init>":(Ljava/lang/String;I)V
      23: putstatic     #52                 // Field S:LPuzzle12$Direction;
      26: new           #73                 // class Puzzle12$Direction$E
      29: dup
      30: ldc           #74                 // String E
      32: iconst_2
      33: invokespecial #75                 // Method Puzzle12$Direction$E."<init>":(Ljava/lang/String;I)V
      36: putstatic     #55                 // Field E:LPuzzle12$Direction;
      39: new           #77                 // class Puzzle12$Direction$W
      42: dup
      43: ldc           #78                 // String W
      45: iconst_3
      46: invokespecial #79                 // Method Puzzle12$Direction$W."<init>":(Ljava/lang/String;I)V
      49: putstatic     #58                 // Field W:LPuzzle12$Direction;
      52: invokestatic  #81                 // Method $values:()[LPuzzle12$Direction;
      55: putstatic     #25                 // Field $VALUES:[LPuzzle12$Direction;
      58: getstatic     #25                 // Field $VALUES:[LPuzzle12$Direction;
      61: checkcast     #83                 // class "[Ljava/lang/Enum;"
      64: invokestatic  #89                 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;
      67: putstatic     #45                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
      70: return
}

Compiled from "Puzzle12.kt"
public final class Puzzle12$Command extends java.lang.Enum<Puzzle12$Command> {
  public static final Puzzle12$Command N;

  public static final Puzzle12$Command S;

  public static final Puzzle12$Command E;

  public static final Puzzle12$Command W;

  public static final Puzzle12$Command L;

  public static final Puzzle12$Command R;

  public static final Puzzle12$Command F;

  private static final Puzzle12$Command[] $VALUES;

  private static final kotlin.enums.EnumEntries $ENTRIES;

  private Puzzle12$Command();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: invokespecial #10                 // Method java/lang/Enum."<init>":(Ljava/lang/String;I)V
       6: return

  public static Puzzle12$Command[] values();
    Code:
       0: getstatic     #22                 // Field $VALUES:[LPuzzle12$Command;
       3: invokevirtual #28                 // Method java/lang/Object.clone:()Ljava/lang/Object;
       6: checkcast     #29                 // class "[LPuzzle12$Command;"
       9: areturn

  public static Puzzle12$Command valueOf(java.lang.String);
    Code:
       0: ldc           #2                  // class Puzzle12$Command
       2: aload_0
       3: invokestatic  #34                 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
       6: checkcast     #2                  // class Puzzle12$Command
       9: areturn

  public static kotlin.enums.EnumEntries<Puzzle12$Command> getEntries();
    Code:
       0: getstatic     #43                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
       3: areturn

  private static final Puzzle12$Command[] $values();
    Code:
       0: bipush        7
       2: anewarray     #2                  // class Puzzle12$Command
       5: astore_0
       6: aload_0
       7: iconst_0
       8: getstatic     #47                 // Field N:LPuzzle12$Command;
      11: aastore
      12: aload_0
      13: iconst_1
      14: getstatic     #50                 // Field S:LPuzzle12$Command;
      17: aastore
      18: aload_0
      19: iconst_2
      20: getstatic     #53                 // Field E:LPuzzle12$Command;
      23: aastore
      24: aload_0
      25: iconst_3
      26: getstatic     #56                 // Field W:LPuzzle12$Command;
      29: aastore
      30: aload_0
      31: iconst_4
      32: getstatic     #59                 // Field L:LPuzzle12$Command;
      35: aastore
      36: aload_0
      37: iconst_5
      38: getstatic     #62                 // Field R:LPuzzle12$Command;
      41: aastore
      42: aload_0
      43: bipush        6
      45: getstatic     #65                 // Field F:LPuzzle12$Command;
      48: aastore
      49: aload_0
      50: areturn

  static {};
    Code:
       0: new           #2                  // class Puzzle12$Command
       3: dup
       4: ldc           #67                 // String N
       6: iconst_0
       7: invokespecial #68                 // Method "<init>":(Ljava/lang/String;I)V
      10: putstatic     #47                 // Field N:LPuzzle12$Command;
      13: new           #2                  // class Puzzle12$Command
      16: dup
      17: ldc           #69                 // String S
      19: iconst_1
      20: invokespecial #68                 // Method "<init>":(Ljava/lang/String;I)V
      23: putstatic     #50                 // Field S:LPuzzle12$Command;
      26: new           #2                  // class Puzzle12$Command
      29: dup
      30: ldc           #70                 // String E
      32: iconst_2
      33: invokespecial #68                 // Method "<init>":(Ljava/lang/String;I)V
      36: putstatic     #53                 // Field E:LPuzzle12$Command;
      39: new           #2                  // class Puzzle12$Command
      42: dup
      43: ldc           #71                 // String W
      45: iconst_3
      46: invokespecial #68                 // Method "<init>":(Ljava/lang/String;I)V
      49: putstatic     #56                 // Field W:LPuzzle12$Command;
      52: new           #2                  // class Puzzle12$Command
      55: dup
      56: ldc           #72                 // String L
      58: iconst_4
      59: invokespecial #68                 // Method "<init>":(Ljava/lang/String;I)V
      62: putstatic     #59                 // Field L:LPuzzle12$Command;
      65: new           #2                  // class Puzzle12$Command
      68: dup
      69: ldc           #73                 // String R
      71: iconst_5
      72: invokespecial #68                 // Method "<init>":(Ljava/lang/String;I)V
      75: putstatic     #62                 // Field R:LPuzzle12$Command;
      78: new           #2                  // class Puzzle12$Command
      81: dup
      82: ldc           #74                 // String F
      84: bipush        6
      86: invokespecial #68                 // Method "<init>":(Ljava/lang/String;I)V
      89: putstatic     #65                 // Field F:LPuzzle12$Command;
      92: invokestatic  #76                 // Method $values:()[LPuzzle12$Command;
      95: putstatic     #22                 // Field $VALUES:[LPuzzle12$Command;
      98: getstatic     #22                 // Field $VALUES:[LPuzzle12$Command;
     101: checkcast     #78                 // class "[Ljava/lang/Enum;"
     104: invokestatic  #84                 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;
     107: putstatic     #43                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
     110: return
}

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

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

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #16                 // String args
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #2                  // class Puzzle12
       8: ldc           #24                 // String puzzle12.txt
      10: invokevirtual #30                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      13: dup
      14: ldc           #32                 // String getResource(...)
      16: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      19: astore_2
      20: getstatic     #41                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      23: astore_3
      24: aload_2
      25: invokestatic  #47                 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B
      28: astore        4
      30: new           #49                 // class java/lang/String
      33: dup
      34: aload         4
      36: aload_3
      37: invokespecial #52                 // Method java/lang/String."<init>":([BLjava/nio/charset/Charset;)V
      40: astore_1
      41: getstatic     #55                 // Field INSTANCE:LPuzzle12;
      44: aload_1
      45: invokevirtual #59                 // Method calculateDistance:(Ljava/lang/String;)I
      48: istore_2
      49: getstatic     #65                 // Field java/lang/System.out:Ljava/io/PrintStream;
      52: iload_2
      53: invokevirtual #71                 // Method java/io/PrintStream.println:(I)V
      56: getstatic     #55                 // Field INSTANCE:LPuzzle12;
      59: aload_1
      60: invokevirtual #74                 // Method calculateDistanceWithWaypoint:(Ljava/lang/String;)I
      63: istore_3
      64: getstatic     #65                 // Field java/lang/System.out:Ljava/io/PrintStream;
      67: iload_3
      68: invokevirtual #71                 // Method java/io/PrintStream.println:(I)V
      71: return

  public final int calculateDistance(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #80                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #82                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #49                 // class java/lang/String
      14: astore_3
      15: aload_3
      16: iconst_0
      17: ldc           #84                 // String \n
      19: aastore
      20: aload_3
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: astore_2
      30: new           #92                 // class Puzzle12$ShipData
      33: dup
      34: getstatic     #98                 // Field Puzzle12$Direction.E:LPuzzle12$Direction;
      37: iconst_0
      38: iconst_0
      39: iconst_0
      40: iconst_0
      41: bipush        24
      43: aconst_null
      44: invokespecial #101                // Method Puzzle12$ShipData."<init>":(LPuzzle12$Direction;IIIIILkotlin/jvm/internal/DefaultConstructorMarker;)V
      47: astore_3
      48: aload_2
      49: checkcast     #103                // class java/lang/Iterable
      52: astore        4
      54: iconst_0
      55: istore        5
      57: aload         4
      59: invokeinterface #107,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      64: astore        6
      66: aload         6
      68: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      73: ifeq          142
      76: aload         6
      78: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      83: astore        7
      85: aload         7
      87: checkcast     #49                 // class java/lang/String
      90: astore        8
      92: iconst_0
      93: istore        9
      95: aload         8
      97: checkcast     #82                 // class java/lang/CharSequence
     100: invokestatic  #121                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     103: invokestatic  #125                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     106: astore        10
     108: nop
     109: aload         8
     111: iconst_1
     112: invokevirtual #129                // Method java/lang/String.substring:(I)Ljava/lang/String;
     115: dup
     116: ldc           #131                // String substring(...)
     118: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     121: invokestatic  #136                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     124: istore        11
     126: aload_3
     127: aload         10
     129: invokestatic  #141                // Method Puzzle12$Command.valueOf:(Ljava/lang/String;)LPuzzle12$Command;
     132: iload         11
     134: invokevirtual #145                // Method Puzzle12$ShipData.move:(LPuzzle12$Command;I)V
     137: nop
     138: nop
     139: goto          66
     142: nop
     143: aload_3
     144: invokevirtual #149                // Method Puzzle12$ShipData.getDistance:()I
     147: ireturn

  public final int calculateDistanceWithWaypoint(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #80                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #82                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #49                 // class java/lang/String
      14: astore_3
      15: aload_3
      16: iconst_0
      17: ldc           #84                 // String \n
      19: aastore
      20: aload_3
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #90                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: astore_2
      30: new           #92                 // class Puzzle12$ShipData
      33: dup
      34: getstatic     #98                 // Field Puzzle12$Direction.E:LPuzzle12$Direction;
      37: iconst_0
      38: iconst_0
      39: bipush        10
      41: iconst_1
      42: invokespecial #167                // Method Puzzle12$ShipData."<init>":(LPuzzle12$Direction;IIII)V
      45: astore_3
      46: aload_2
      47: checkcast     #103                // class java/lang/Iterable
      50: astore        4
      52: iconst_0
      53: istore        5
      55: aload         4
      57: invokeinterface #107,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      62: astore        6
      64: aload         6
      66: invokeinterface #113,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      71: ifeq          140
      74: aload         6
      76: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      81: astore        7
      83: aload         7
      85: checkcast     #49                 // class java/lang/String
      88: astore        8
      90: iconst_0
      91: istore        9
      93: aload         8
      95: checkcast     #82                 // class java/lang/CharSequence
      98: invokestatic  #121                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     101: invokestatic  #125                // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     104: astore        10
     106: nop
     107: aload         8
     109: iconst_1
     110: invokevirtual #129                // Method java/lang/String.substring:(I)Ljava/lang/String;
     113: dup
     114: ldc           #131                // String substring(...)
     116: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     119: invokestatic  #136                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     122: istore        11
     124: aload_3
     125: aload         10
     127: invokestatic  #141                // Method Puzzle12$Command.valueOf:(Ljava/lang/String;)LPuzzle12$Command;
     130: iload         11
     132: invokevirtual #170                // Method Puzzle12$ShipData.moveWithWaypoint:(LPuzzle12$Command;I)V
     135: nop
     136: nop
     137: goto          64
     140: nop
     141: aload_3
     142: invokevirtual #149                // Method Puzzle12$ShipData.getDistance:()I
     145: ireturn

  static {};
    Code:
       0: new           #2                  // class Puzzle12
       3: dup
       4: invokespecial #173                // Method "<init>":()V
       7: putstatic     #55                 // Field INSTANCE:LPuzzle12;
      10: return
}

Compiled from "Puzzle12.kt"
final class Puzzle12$Direction$E extends Puzzle12$Direction {
  Puzzle12$Direction$E();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: aconst_null
       4: invokespecial #10                 // Method Puzzle12$Direction."<init>":(Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
       7: return

  public Puzzle12$Command toCommand();
    Code:
       0: getstatic     #25                 // Field Puzzle12$Command.E:LPuzzle12$Command;
       3: areturn
}

Compiled from "Puzzle12.kt"
public final class Puzzle12$ShipData$WhenMappings {
  public static final int[] $EnumSwitchMapping$0;

  static {};
    Code:
       0: invokestatic  #14                 // Method Puzzle12$Command.values:()[LPuzzle12$Command;
       3: arraylength
       4: newarray       int
       6: astore_0
       7: nop
       8: aload_0
       9: getstatic     #18                 // Field Puzzle12$Command.N:LPuzzle12$Command;
      12: invokevirtual #22                 // Method Puzzle12$Command.ordinal:()I
      15: iconst_1
      16: iastore
      17: goto          21
      20: astore_1
      21: nop
      22: aload_0
      23: getstatic     #25                 // Field Puzzle12$Command.S:LPuzzle12$Command;
      26: invokevirtual #22                 // Method Puzzle12$Command.ordinal:()I
      29: iconst_2
      30: iastore
      31: goto          35
      34: astore_1
      35: nop
      36: aload_0
      37: getstatic     #28                 // Field Puzzle12$Command.E:LPuzzle12$Command;
      40: invokevirtual #22                 // Method Puzzle12$Command.ordinal:()I
      43: iconst_3
      44: iastore
      45: goto          49
      48: astore_1
      49: nop
      50: aload_0
      51: getstatic     #31                 // Field Puzzle12$Command.W:LPuzzle12$Command;
      54: invokevirtual #22                 // Method Puzzle12$Command.ordinal:()I
      57: iconst_4
      58: iastore
      59: goto          63
      62: astore_1
      63: nop
      64: aload_0
      65: getstatic     #34                 // Field Puzzle12$Command.L:LPuzzle12$Command;
      68: invokevirtual #22                 // Method Puzzle12$Command.ordinal:()I
      71: iconst_5
      72: iastore
      73: goto          77
      76: astore_1
      77: nop
      78: aload_0
      79: getstatic     #37                 // Field Puzzle12$Command.R:LPuzzle12$Command;
      82: invokevirtual #22                 // Method Puzzle12$Command.ordinal:()I
      85: bipush        6
      87: iastore
      88: goto          92
      91: astore_1
      92: nop
      93: aload_0
      94: getstatic     #40                 // Field Puzzle12$Command.F:LPuzzle12$Command;
      97: invokevirtual #22                 // Method Puzzle12$Command.ordinal:()I
     100: bipush        7
     102: iastore
     103: goto          107
     106: astore_1
     107: aload_0
     108: putstatic     #44                 // Field $EnumSwitchMapping$0:[I
     111: return
    Exception table:
       from    to  target type
           7    17    20   Class java/lang/NoSuchFieldError
          21    31    34   Class java/lang/NoSuchFieldError
          35    45    48   Class java/lang/NoSuchFieldError
          49    59    62   Class java/lang/NoSuchFieldError
          63    73    76   Class java/lang/NoSuchFieldError
          77    88    91   Class java/lang/NoSuchFieldError
          92   103   106   Class java/lang/NoSuchFieldError
}