package day04

import java.io.File

fun main() {

    fun String.asIntRange() =
        substringBefore('-').toInt()..substringAfter('-').toInt()

    infix fun IntRange.contains(other: IntRange) = first <= other.first && last >= other.last

    infix fun IntRange.overlaps(other: IntRange) = first <= other.last && last >= other.first

    fun part1(input: String): Int {
        val pairs = input.lines().map {
            it.substringBefore(",").asIntRange() to it.substringAfter(",").asIntRange()
        }
        return pairs.count {
            it.first contains it.second || it.second contains it.first
        }
    }

    fun part2(input: String): Int {
        val pairs = input.lines().map {
            it.substringBefore(",").asIntRange() to it.substringAfter(",").asIntRange()
        }
        return pairs.count {
            it.first overlaps it.second || it.second overlaps it.first
        }
    }

    val testInput = File("src/day04/Day04_test.txt").readText().trim()
    val part1Solution = part1(testInput)
    val part2Solution = part2(testInput)
    println(part1Solution)
    check(part1Solution == 2)
    check(part2Solution == 4)

    val input = File("src/day04/Day04.txt").readText().trim()
    println(part1(input))
    println(part2(input))
}

Compiled from "Day04.kt"
public final class day04.Day04Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String src/day04/Day04_test.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      15: checkcast     #22                 // class java/lang/CharSequence
      18: invokestatic  #28                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      21: invokevirtual #32                 // Method java/lang/Object.toString:()Ljava/lang/String;
      24: astore_0
      25: aload_0
      26: invokestatic  #36                 // Method main$part1:(Ljava/lang/String;)I
      29: istore_1
      30: aload_0
      31: invokestatic  #39                 // Method main$part2:(Ljava/lang/String;)I
      34: istore_2
      35: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      38: iload_1
      39: invokevirtual #51                 // Method java/io/PrintStream.println:(I)V
      42: iload_1
      43: iconst_2
      44: if_icmpne     51
      47: iconst_1
      48: goto          52
      51: iconst_0
      52: ifne          65
      55: new           #53                 // class java/lang/IllegalStateException
      58: dup
      59: ldc           #55                 // String Check failed.
      61: invokespecial #56                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      64: athrow
      65: iload_2
      66: iconst_4
      67: if_icmpne     74
      70: iconst_1
      71: goto          75
      74: iconst_0
      75: ifne          88
      78: new           #53                 // class java/lang/IllegalStateException
      81: dup
      82: ldc           #55                 // String Check failed.
      84: invokespecial #56                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      87: athrow
      88: new           #8                  // class java/io/File
      91: dup
      92: ldc           #58                 // String src/day04/Day04.txt
      94: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      97: aconst_null
      98: iconst_1
      99: aconst_null
     100: invokestatic  #20                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
     103: checkcast     #22                 // class java/lang/CharSequence
     106: invokestatic  #28                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     109: invokevirtual #32                 // Method java/lang/Object.toString:()Ljava/lang/String;
     112: astore_3
     113: aload_3
     114: invokestatic  #36                 // Method main$part1:(Ljava/lang/String;)I
     117: istore        4
     119: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     122: iload         4
     124: invokevirtual #51                 // Method java/io/PrintStream.println:(I)V
     127: aload_3
     128: invokestatic  #39                 // Method main$part2:(Ljava/lang/String;)I
     131: istore        4
     133: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     136: iload         4
     138: invokevirtual #51                 // Method java/io/PrintStream.println:(I)V
     141: return

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

  private static final kotlin.ranges.IntRange main$asIntRange(java.lang.String);
    Code:
       0: new           #75                 // class kotlin/ranges/IntRange
       3: dup
       4: aload_0
       5: bipush        45
       7: aconst_null
       8: iconst_2
       9: aconst_null
      10: invokestatic  #79                 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;CLjava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      13: invokestatic  #84                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      16: aload_0
      17: bipush        45
      19: aconst_null
      20: iconst_2
      21: aconst_null
      22: invokestatic  #87                 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;CLjava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      25: invokestatic  #84                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      28: invokespecial #90                 // Method kotlin/ranges/IntRange."<init>":(II)V
      31: areturn

  private static final boolean main$contains(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: invokevirtual #97                 // Method kotlin/ranges/IntRange.getFirst:()I
       4: aload_1
       5: invokevirtual #97                 // Method kotlin/ranges/IntRange.getFirst:()I
       8: if_icmpgt     26
      11: aload_0
      12: invokevirtual #100                // Method kotlin/ranges/IntRange.getLast:()I
      15: aload_1
      16: invokevirtual #100                // Method kotlin/ranges/IntRange.getLast:()I
      19: if_icmplt     26
      22: iconst_1
      23: goto          27
      26: iconst_0
      27: ireturn

  private static final boolean main$overlaps(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: invokevirtual #97                 // Method kotlin/ranges/IntRange.getFirst:()I
       4: aload_1
       5: invokevirtual #100                // Method kotlin/ranges/IntRange.getLast:()I
       8: if_icmpgt     26
      11: aload_0
      12: invokevirtual #100                // Method kotlin/ranges/IntRange.getLast:()I
      15: aload_1
      16: invokevirtual #97                 // Method kotlin/ranges/IntRange.getFirst:()I
      19: if_icmplt     26
      22: iconst_1
      23: goto          27
      26: iconst_0
      27: ireturn

  private static final int main$part1(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #22                 // class java/lang/CharSequence
       4: invokestatic  #109                // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
       7: checkcast     #111                // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: astore        4
      16: new           #113                // class java/util/ArrayList
      19: dup
      20: aload_2
      21: bipush        10
      23: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #123                // class java/util/Collection
      32: astore        5
      34: iconst_0
      35: istore        6
      37: aload         4
      39: invokeinterface #127,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        7
      46: aload         7
      48: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          120
      56: aload         7
      58: invokeinterface #137,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        8
      65: aload         5
      67: aload         8
      69: checkcast     #66                 // class java/lang/String
      72: astore        9
      74: astore        11
      76: iconst_0
      77: istore        10
      79: aload         9
      81: ldc           #139                // String ,
      83: aconst_null
      84: iconst_2
      85: aconst_null
      86: invokestatic  #142                // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      89: invokestatic  #144                // Method main$asIntRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;
      92: aload         9
      94: ldc           #139                // String ,
      96: aconst_null
      97: iconst_2
      98: aconst_null
      99: invokestatic  #146                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     102: invokestatic  #144                // Method main$asIntRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;
     105: invokestatic  #152                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     108: aload         11
     110: swap
     111: invokeinterface #156,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     116: pop
     117: goto          46
     120: aload         5
     122: checkcast     #158                // class java/util/List
     125: nop
     126: astore_1
     127: aload_1
     128: checkcast     #111                // class java/lang/Iterable
     131: astore_2
     132: iconst_0
     133: istore_3
     134: aload_2
     135: instanceof    #123                // class java/util/Collection
     138: ifeq          157
     141: aload_2
     142: checkcast     #123                // class java/util/Collection
     145: invokeinterface #161,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     150: ifeq          157
     153: iconst_0
     154: goto          265
     157: iconst_0
     158: istore        4
     160: aload_2
     161: invokeinterface #127,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     166: astore        5
     168: aload         5
     170: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     175: ifeq          263
     178: aload         5
     180: invokeinterface #137,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     185: astore        6
     187: aload         6
     189: checkcast     #163                // class kotlin/Pair
     192: astore        7
     194: iconst_0
     195: istore        8
     197: aload         7
     199: invokevirtual #165                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     202: checkcast     #75                 // class kotlin/ranges/IntRange
     205: aload         7
     207: invokevirtual #168                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     210: checkcast     #75                 // class kotlin/ranges/IntRange
     213: invokestatic  #170                // Method main$contains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     216: ifne          241
     219: aload         7
     221: invokevirtual #168                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     224: checkcast     #75                 // class kotlin/ranges/IntRange
     227: aload         7
     229: invokevirtual #165                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     232: checkcast     #75                 // class kotlin/ranges/IntRange
     235: invokestatic  #170                // Method main$contains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     238: ifeq          245
     241: iconst_1
     242: goto          246
     245: iconst_0
     246: ifeq          168
     249: iinc          4, 1
     252: iload         4
     254: ifge          168
     257: invokestatic  #173                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     260: goto          168
     263: iload         4
     265: ireturn

  private static final int main$part2(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #22                 // class java/lang/CharSequence
       4: invokestatic  #109                // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
       7: checkcast     #111                // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: astore        4
      16: new           #113                // class java/util/ArrayList
      19: dup
      20: aload_2
      21: bipush        10
      23: invokestatic  #119                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #121                // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #123                // class java/util/Collection
      32: astore        5
      34: iconst_0
      35: istore        6
      37: aload         4
      39: invokeinterface #127,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        7
      46: aload         7
      48: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          120
      56: aload         7
      58: invokeinterface #137,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        8
      65: aload         5
      67: aload         8
      69: checkcast     #66                 // class java/lang/String
      72: astore        9
      74: astore        11
      76: iconst_0
      77: istore        10
      79: aload         9
      81: ldc           #139                // String ,
      83: aconst_null
      84: iconst_2
      85: aconst_null
      86: invokestatic  #142                // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      89: invokestatic  #144                // Method main$asIntRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;
      92: aload         9
      94: ldc           #139                // String ,
      96: aconst_null
      97: iconst_2
      98: aconst_null
      99: invokestatic  #146                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     102: invokestatic  #144                // Method main$asIntRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;
     105: invokestatic  #152                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     108: aload         11
     110: swap
     111: invokeinterface #156,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     116: pop
     117: goto          46
     120: aload         5
     122: checkcast     #158                // class java/util/List
     125: nop
     126: astore_1
     127: aload_1
     128: checkcast     #111                // class java/lang/Iterable
     131: astore_2
     132: iconst_0
     133: istore_3
     134: aload_2
     135: instanceof    #123                // class java/util/Collection
     138: ifeq          157
     141: aload_2
     142: checkcast     #123                // class java/util/Collection
     145: invokeinterface #161,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     150: ifeq          157
     153: iconst_0
     154: goto          265
     157: iconst_0
     158: istore        4
     160: aload_2
     161: invokeinterface #127,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     166: astore        5
     168: aload         5
     170: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     175: ifeq          263
     178: aload         5
     180: invokeinterface #137,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     185: astore        6
     187: aload         6
     189: checkcast     #163                // class kotlin/Pair
     192: astore        7
     194: iconst_0
     195: istore        8
     197: aload         7
     199: invokevirtual #165                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     202: checkcast     #75                 // class kotlin/ranges/IntRange
     205: aload         7
     207: invokevirtual #168                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     210: checkcast     #75                 // class kotlin/ranges/IntRange
     213: invokestatic  #194                // Method main$overlaps:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     216: ifne          241
     219: aload         7
     221: invokevirtual #168                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     224: checkcast     #75                 // class kotlin/ranges/IntRange
     227: aload         7
     229: invokevirtual #165                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     232: checkcast     #75                 // class kotlin/ranges/IntRange
     235: invokestatic  #194                // Method main$overlaps:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     238: ifeq          245
     241: iconst_1
     242: goto          246
     245: iconst_0
     246: ifeq          168
     249: iinc          4, 1
     252: iload         4
     254: ifge          168
     257: invokestatic  #173                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     260: goto          168
     263: iload         4
     265: ireturn
}


package day03

import java.io.File

fun main() {

    fun prioritiseItem(it: Char) = if (it.isUpperCase())
        (it - 'A' + 27)
    else
        (it - 'a' + 1)

    fun part1(input: String): Int {
        val rucksacks = input.lines()
        val duplicateItems = rucksacks.flatMap {
            val (first, second) = it.chunked(it.length / 2) { it.toSet() }
            val intersect = first intersect second
            intersect
        }
        return duplicateItems.sumOf { prioritiseItem(it) }
    }

    fun part2(input: String): Int {
        val rucksacks = input.lines().map { it.toSet() }
        val compartments = rucksacks.chunked(3).flatMap {
            it.reduce(Set<Char>::intersect)
        }
        return compartments.sumOf { prioritiseItem(it) }
    }

    val testInput = File("src/day03/Day03_test.txt").readText().trim()
    val part1Solution = part1(testInput)
    val part2Solution = part2(testInput)
    println(part1Solution)
    check(part1Solution == 157)
    check(part2Solution == 70)

    val input = File("src/day03/Day03.txt").readText().trim()
    println(part1(input))
    println(part2(input))
}

Compiled from "Day03.kt"
public final class day03.Day03Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String src/day03/Day03_test.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      15: checkcast     #22                 // class java/lang/CharSequence
      18: invokestatic  #28                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      21: invokevirtual #32                 // Method java/lang/Object.toString:()Ljava/lang/String;
      24: astore_0
      25: aload_0
      26: invokestatic  #36                 // Method main$part1:(Ljava/lang/String;)I
      29: istore_1
      30: aload_0
      31: invokestatic  #39                 // Method main$part2:(Ljava/lang/String;)I
      34: istore_2
      35: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      38: iload_1
      39: invokevirtual #51                 // Method java/io/PrintStream.println:(I)V
      42: iload_1
      43: sipush        157
      46: if_icmpne     53
      49: iconst_1
      50: goto          54
      53: iconst_0
      54: ifne          67
      57: new           #53                 // class java/lang/IllegalStateException
      60: dup
      61: ldc           #55                 // String Check failed.
      63: invokespecial #56                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      66: athrow
      67: iload_2
      68: bipush        70
      70: if_icmpne     77
      73: iconst_1
      74: goto          78
      77: iconst_0
      78: ifne          91
      81: new           #53                 // class java/lang/IllegalStateException
      84: dup
      85: ldc           #55                 // String Check failed.
      87: invokespecial #56                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      90: athrow
      91: new           #8                  // class java/io/File
      94: dup
      95: ldc           #58                 // String src/day03/Day03.txt
      97: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
     100: aconst_null
     101: iconst_1
     102: aconst_null
     103: invokestatic  #20                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
     106: checkcast     #22                 // class java/lang/CharSequence
     109: invokestatic  #28                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     112: invokevirtual #32                 // Method java/lang/Object.toString:()Ljava/lang/String;
     115: astore_3
     116: aload_3
     117: invokestatic  #36                 // Method main$part1:(Ljava/lang/String;)I
     120: istore        4
     122: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     125: iload         4
     127: invokevirtual #51                 // Method java/io/PrintStream.println:(I)V
     130: aload_3
     131: invokestatic  #39                 // Method main$part2:(Ljava/lang/String;)I
     134: istore        4
     136: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     139: iload         4
     141: invokevirtual #51                 // Method java/io/PrintStream.println:(I)V
     144: return

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

  private static final int main$prioritiseItem(char);
    Code:
       0: iload_0
       1: invokestatic  #79                 // Method java/lang/Character.isUpperCase:(C)Z
       4: ifeq          17
       7: iload_0
       8: bipush        65
      10: isub
      11: bipush        27
      13: iadd
      14: goto          23
      17: iload_0
      18: bipush        97
      20: isub
      21: iconst_1
      22: iadd
      23: ireturn

  private static final java.util.Set main$part1$lambda$1$lambda$0(java.lang.CharSequence);
    Code:
       0: aload_0
       1: ldc           #84                 // String it
       3: invokestatic  #90                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #93                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      10: areturn

  private static final int main$part1(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #22                 // class java/lang/CharSequence
       4: invokestatic  #98                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
       7: astore_1
       8: aload_1
       9: checkcast     #100                // class java/lang/Iterable
      12: astore_3
      13: iconst_0
      14: istore        4
      16: aload_3
      17: astore        5
      19: new           #102                // class java/util/ArrayList
      22: dup
      23: invokespecial #104                // Method java/util/ArrayList."<init>":()V
      26: checkcast     #106                // class java/util/Collection
      29: astore        6
      31: iconst_0
      32: istore        7
      34: aload         5
      36: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        8
      43: aload         8
      45: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          153
      53: aload         8
      55: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        9
      62: aload         9
      64: checkcast     #66                 // class java/lang/String
      67: astore        10
      69: iconst_0
      70: istore        11
      72: aload         10
      74: checkcast     #22                 // class java/lang/CharSequence
      77: aload         10
      79: invokevirtual #124                // Method java/lang/String.length:()I
      82: iconst_2
      83: idiv
      84: invokedynamic #141,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      89: invokestatic  #145                // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;ILkotlin/jvm/functions/Function1;)Ljava/util/List;
      92: astore        12
      94: aload         12
      96: iconst_0
      97: invokeinterface #151,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     102: checkcast     #153                // class java/util/Set
     105: astore        13
     107: aload         12
     109: iconst_1
     110: invokeinterface #151,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     115: checkcast     #153                // class java/util/Set
     118: astore        14
     120: aload         13
     122: checkcast     #100                // class java/lang/Iterable
     125: aload         14
     127: checkcast     #100                // class java/lang/Iterable
     130: invokestatic  #159                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     133: astore        15
     135: aload         15
     137: checkcast     #100                // class java/lang/Iterable
     140: astore        10
     142: aload         6
     144: aload         10
     146: invokestatic  #163                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     149: pop
     150: goto          43
     153: aload         6
     155: checkcast     #147                // class java/util/List
     158: nop
     159: astore_2
     160: aload_2
     161: checkcast     #100                // class java/lang/Iterable
     164: astore_3
     165: iconst_0
     166: istore        4
     168: aload_3
     169: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     174: astore        5
     176: aload         5
     178: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     183: ifeq          229
     186: aload         5
     188: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     193: astore        6
     195: iload         4
     197: aload         6
     199: checkcast     #75                 // class java/lang/Character
     202: invokevirtual #167                // Method java/lang/Character.charValue:()C
     205: istore        7
     207: istore        16
     209: iconst_0
     210: istore        8
     212: iload         7
     214: invokestatic  #169                // Method main$prioritiseItem:(C)I
     217: istore        17
     219: iload         16
     221: iload         17
     223: iadd
     224: istore        4
     226: goto          176
     229: iload         4
     231: ireturn

  private static final int main$part2(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #22                 // class java/lang/CharSequence
       4: invokestatic  #98                 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
       7: checkcast     #100                // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: astore        4
      16: new           #102                // class java/util/ArrayList
      19: dup
      20: aload_2
      21: bipush        10
      23: invokestatic  #191                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #193                // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #106                // class java/util/Collection
      32: astore        5
      34: iconst_0
      35: istore        6
      37: aload         4
      39: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        7
      46: aload         7
      48: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          99
      56: aload         7
      58: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        8
      65: aload         5
      67: aload         8
      69: checkcast     #66                 // class java/lang/String
      72: astore        9
      74: astore        19
      76: iconst_0
      77: istore        10
      79: aload         9
      81: checkcast     #22                 // class java/lang/CharSequence
      84: invokestatic  #93                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
      87: aload         19
      89: swap
      90: invokeinterface #197,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      95: pop
      96: goto          46
      99: aload         5
     101: checkcast     #147                // class java/util/List
     104: nop
     105: astore_1
     106: aload_1
     107: checkcast     #100                // class java/lang/Iterable
     110: iconst_3
     111: invokestatic  #200                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
     114: checkcast     #100                // class java/lang/Iterable
     117: astore_3
     118: iconst_0
     119: istore        4
     121: aload_3
     122: astore        5
     124: new           #102                // class java/util/ArrayList
     127: dup
     128: invokespecial #104                // Method java/util/ArrayList."<init>":()V
     131: checkcast     #106                // class java/util/Collection
     134: astore        6
     136: iconst_0
     137: istore        7
     139: aload         5
     141: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     146: astore        8
     148: aload         8
     150: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     155: ifeq          291
     158: aload         8
     160: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     165: astore        9
     167: aload         9
     169: checkcast     #147                // class java/util/List
     172: astore        10
     174: iconst_0
     175: istore        11
     177: aload         10
     179: checkcast     #100                // class java/lang/Iterable
     182: astore        12
     184: iconst_0
     185: istore        13
     187: aload         12
     189: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     194: astore        14
     196: aload         14
     198: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     203: ifne          216
     206: new           #202                // class java/lang/UnsupportedOperationException
     209: dup
     210: ldc           #204                // String Empty collection can\'t be reduced.
     212: invokespecial #205                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     215: athrow
     216: aload         14
     218: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     223: astore        15
     225: aload         14
     227: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     232: ifeq          272
     235: aload         15
     237: aload         14
     239: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     244: checkcast     #100                // class java/lang/Iterable
     247: astore        16
     249: checkcast     #153                // class java/util/Set
     252: astore        17
     254: iconst_0
     255: istore        18
     257: aload         17
     259: checkcast     #100                // class java/lang/Iterable
     262: aload         16
     264: invokestatic  #159                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     267: astore        15
     269: goto          225
     272: aload         15
     274: checkcast     #100                // class java/lang/Iterable
     277: nop
     278: astore        10
     280: aload         6
     282: aload         10
     284: invokestatic  #163                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     287: pop
     288: goto          148
     291: aload         6
     293: checkcast     #147                // class java/util/List
     296: nop
     297: astore_2
     298: aload_2
     299: checkcast     #100                // class java/lang/Iterable
     302: astore_3
     303: iconst_0
     304: istore        4
     306: aload_3
     307: invokeinterface #110,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     312: astore        5
     314: aload         5
     316: invokeinterface #116,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     321: ifeq          367
     324: aload         5
     326: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     331: astore        6
     333: iload         4
     335: aload         6
     337: checkcast     #75                 // class java/lang/Character
     340: invokevirtual #167                // Method java/lang/Character.charValue:()C
     343: istore        7
     345: istore        19
     347: iconst_0
     348: istore        8
     350: iload         7
     352: invokestatic  #169                // Method main$prioritiseItem:(C)I
     355: istore        20
     357: iload         19
     359: iload         20
     361: iadd
     362: istore        4
     364: goto          314
     367: iload         4
     369: ireturn
}


package day02

import java.io.File

enum class MyHand(val hand: Char, val scoreWorth: Int) {
    X('R', 1), Y('P', 2), Z('S', 3);
}

enum class OpponentHand(val hand: Char) {
    A('R'), B('P'), C('S');
}

fun scoreGame(theirs: OpponentHand, mine: MyHand): Int = when {
    mine.hand == theirs.hand -> 3
    (mine == MyHand.X && theirs == OpponentHand.C) || (mine == MyHand.Y && theirs == OpponentHand.A) || (mine == MyHand.Z && theirs == OpponentHand.B) -> 6
    else -> 0
} + mine.scoreWorth

fun calculateHand(round: String): Int = when (round) {
    "A X", "B Z", "C Y" -> 3
    "B Y", "C X", "A Z" -> 2
    "A Y", "B X", "C Z" -> 1
    else -> 0
} + (round[2] - 'X') * 3

fun main() {

    fun part1(input: String): Int {
        val games = input.split("\n").map { it.split(" ") }
        println(games)
        val score = games.fold(0) { acc, hands ->
            acc + scoreGame(OpponentHand.valueOf(hands[0]), MyHand.valueOf(hands[1]))
        }
        return score
    }

    fun part2(input: String): Int {
        val games = input.split("\n")
        println(games)
        val score = games.fold(0) { acc, game ->
            acc + calculateHand(game)
        }
        return score
    }

    val testInput = File("src/day02/Day02_test.txt").readText().trim()
    val part1Solution = part1(testInput)
    val part2Solution = part2(testInput)
    println(part1Solution)
    check(part1Solution == 15)
    check(part2Solution == 12)

    val input = File("src/day02/Day02.txt").readText().trim()
    println(part1(input))
    println(part2(input))
}

Compiled from "Day02.kt"
public final class day02.Day02Kt {
  public static final int scoreGame(day02.OpponentHand, day02.MyHand);
    Code:
       0: aload_0
       1: ldc           #9                  // String theirs
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String mine
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: nop
      13: aload_1
      14: invokevirtual #23                 // Method day02/MyHand.getHand:()C
      17: aload_0
      18: invokevirtual #26                 // Method day02/OpponentHand.getHand:()C
      21: if_icmpne     28
      24: iconst_3
      25: goto          76
      28: aload_1
      29: getstatic     #30                 // Field day02/MyHand.X:Lday02/MyHand;
      32: if_acmpne     42
      35: aload_0
      36: getstatic     #34                 // Field day02/OpponentHand.C:Lday02/OpponentHand;
      39: if_acmpeq     70
      42: aload_1
      43: getstatic     #37                 // Field day02/MyHand.Y:Lday02/MyHand;
      46: if_acmpne     56
      49: aload_0
      50: getstatic     #40                 // Field day02/OpponentHand.A:Lday02/OpponentHand;
      53: if_acmpeq     70
      56: aload_1
      57: getstatic     #43                 // Field day02/MyHand.Z:Lday02/MyHand;
      60: if_acmpne     75
      63: aload_0
      64: getstatic     #46                 // Field day02/OpponentHand.B:Lday02/OpponentHand;
      67: if_acmpne     75
      70: bipush        6
      72: goto          76
      75: iconst_0
      76: aload_1
      77: invokevirtual #50                 // Method day02/MyHand.getScoreWorth:()I
      80: iadd
      81: ireturn

  public static final int calculateHand(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #54                 // String round
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: aload_1
       9: invokevirtual #59                 // Method java/lang/String.hashCode:()I
      12: lookupswitch  { // 9
                 63545: 96
                 63546: 108
                 63547: 156
                 64506: 120
                 64507: 132
                 64508: 168
                 65467: 144
                 65468: 180
                 65469: 192
               default: 216
          }
      96: aload_1
      97: ldc           #61                 // String A X
      99: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     102: ifne          204
     105: goto          216
     108: aload_1
     109: ldc           #67                 // String A Y
     111: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     114: ifne          212
     117: goto          216
     120: aload_1
     121: ldc           #69                 // String B X
     123: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     126: ifne          212
     129: goto          216
     132: aload_1
     133: ldc           #71                 // String B Y
     135: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     138: ifne          208
     141: goto          216
     144: aload_1
     145: ldc           #73                 // String C X
     147: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     150: ifne          208
     153: goto          216
     156: aload_1
     157: ldc           #75                 // String A Z
     159: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     162: ifne          208
     165: goto          216
     168: aload_1
     169: ldc           #77                 // String B Z
     171: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     174: ifne          204
     177: goto          216
     180: aload_1
     181: ldc           #79                 // String C Y
     183: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     186: ifne          204
     189: goto          216
     192: aload_1
     193: ldc           #81                 // String C Z
     195: invokevirtual #65                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     198: ifne          212
     201: goto          216
     204: iconst_3
     205: goto          217
     208: iconst_2
     209: goto          217
     212: iconst_1
     213: goto          217
     216: iconst_0
     217: aload_0
     218: iconst_2
     219: invokevirtual #85                 // Method java/lang/String.charAt:(I)C
     222: bipush        88
     224: isub
     225: iconst_3
     226: imul
     227: iadd
     228: ireturn

  public static final void main();
    Code:
       0: new           #90                 // class java/io/File
       3: dup
       4: ldc           #92                 // String src/day02/Day02_test.txt
       6: invokespecial #96                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #102                // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      15: checkcast     #104                // class java/lang/CharSequence
      18: invokestatic  #110                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      21: invokevirtual #114                // Method java/lang/Object.toString:()Ljava/lang/String;
      24: astore_0
      25: aload_0
      26: invokestatic  #117                // Method main$part1:(Ljava/lang/String;)I
      29: istore_1
      30: aload_0
      31: invokestatic  #120                // Method main$part2:(Ljava/lang/String;)I
      34: istore_2
      35: getstatic     #126                // Field java/lang/System.out:Ljava/io/PrintStream;
      38: iload_1
      39: invokevirtual #132                // Method java/io/PrintStream.println:(I)V
      42: iload_1
      43: bipush        15
      45: if_icmpne     52
      48: iconst_1
      49: goto          53
      52: iconst_0
      53: ifne          66
      56: new           #134                // class java/lang/IllegalStateException
      59: dup
      60: ldc           #136                // String Check failed.
      62: invokespecial #137                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      65: athrow
      66: iload_2
      67: bipush        12
      69: if_icmpne     76
      72: iconst_1
      73: goto          77
      76: iconst_0
      77: ifne          90
      80: new           #134                // class java/lang/IllegalStateException
      83: dup
      84: ldc           #136                // String Check failed.
      86: invokespecial #137                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      89: athrow
      90: new           #90                 // class java/io/File
      93: dup
      94: ldc           #139                // String src/day02/Day02.txt
      96: invokespecial #96                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      99: aconst_null
     100: iconst_1
     101: aconst_null
     102: invokestatic  #102                // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
     105: checkcast     #104                // class java/lang/CharSequence
     108: invokestatic  #110                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     111: invokevirtual #114                // Method java/lang/Object.toString:()Ljava/lang/String;
     114: astore_3
     115: aload_3
     116: invokestatic  #117                // Method main$part1:(Ljava/lang/String;)I
     119: istore        4
     121: getstatic     #126                // Field java/lang/System.out:Ljava/io/PrintStream;
     124: iload         4
     126: invokevirtual #132                // Method java/io/PrintStream.println:(I)V
     129: aload_3
     130: invokestatic  #120                // Method main$part2:(Ljava/lang/String;)I
     133: istore        4
     135: getstatic     #126                // Field java/lang/System.out:Ljava/io/PrintStream;
     138: iload         4
     140: invokevirtual #132                // Method java/io/PrintStream.println:(I)V
     143: return

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

  private static final int main$part1(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #104                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #56                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #151                // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #155                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #157                // class java/lang/Iterable
      26: astore_2
      27: iconst_0
      28: istore_3
      29: aload_2
      30: astore        4
      32: new           #159                // class java/util/ArrayList
      35: dup
      36: aload_2
      37: bipush        10
      39: invokestatic  #165                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      42: invokespecial #167                // Method java/util/ArrayList."<init>":(I)V
      45: checkcast     #169                // class java/util/Collection
      48: astore        5
      50: iconst_0
      51: istore        6
      53: aload         4
      55: invokeinterface #173,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        7
      62: aload         7
      64: invokeinterface #179,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          134
      72: aload         7
      74: invokeinterface #183,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        8
      81: aload         5
      83: aload         8
      85: checkcast     #56                 // class java/lang/String
      88: astore        9
      90: astore        12
      92: iconst_0
      93: istore        10
      95: aload         9
      97: checkcast     #104                // class java/lang/CharSequence
     100: iconst_1
     101: anewarray     #56                 // class java/lang/String
     104: astore        11
     106: aload         11
     108: iconst_0
     109: ldc           #185                // String
     111: aastore
     112: aload         11
     114: iconst_0
     115: iconst_0
     116: bipush        6
     118: aconst_null
     119: invokestatic  #155                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     122: aload         12
     124: swap
     125: invokeinterface #188,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     130: pop
     131: goto          62
     134: aload         5
     136: checkcast     #190                // class java/util/List
     139: nop
     140: astore_1
     141: getstatic     #126                // Field java/lang/System.out:Ljava/io/PrintStream;
     144: aload_1
     145: invokevirtual #193                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     148: aload_1
     149: checkcast     #157                // class java/lang/Iterable
     152: astore_3
     153: iconst_0
     154: istore        4
     156: iconst_0
     157: istore        5
     159: iload         4
     161: istore        6
     163: aload_3
     164: invokeinterface #173,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     169: astore        7
     171: aload         7
     173: invokeinterface #179,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifeq          243
     181: aload         7
     183: invokeinterface #183,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     188: astore        8
     190: iload         6
     192: aload         8
     194: checkcast     #190                // class java/util/List
     197: astore        9
     199: istore        10
     201: iconst_0
     202: istore        11
     204: iload         10
     206: aload         9
     208: iconst_0
     209: invokeinterface #197,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     214: checkcast     #56                 // class java/lang/String
     217: invokestatic  #201                // Method day02/OpponentHand.valueOf:(Ljava/lang/String;)Lday02/OpponentHand;
     220: aload         9
     222: iconst_1
     223: invokeinterface #197,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     228: checkcast     #56                 // class java/lang/String
     231: invokestatic  #204                // Method day02/MyHand.valueOf:(Ljava/lang/String;)Lday02/MyHand;
     234: invokestatic  #206                // Method scoreGame:(Lday02/OpponentHand;Lday02/MyHand;)I
     237: iadd
     238: istore        6
     240: goto          171
     243: iload         6
     245: istore_2
     246: iload_2
     247: ireturn

  private static final int main$part2(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #104                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #56                 // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #151                // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #155                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_1
      24: getstatic     #126                // Field java/lang/System.out:Ljava/io/PrintStream;
      27: aload_1
      28: invokevirtual #193                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      31: aload_1
      32: checkcast     #157                // class java/lang/Iterable
      35: astore_3
      36: iconst_0
      37: istore        4
      39: iconst_0
      40: istore        5
      42: iload         4
      44: istore        6
      46: aload_3
      47: invokeinterface #173,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      52: astore        7
      54: aload         7
      56: invokeinterface #179,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      61: ifeq          100
      64: aload         7
      66: invokeinterface #183,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      71: astore        8
      73: iload         6
      75: aload         8
      77: checkcast     #56                 // class java/lang/String
      80: astore        9
      82: istore        10
      84: iconst_0
      85: istore        11
      87: iload         10
      89: aload         9
      91: invokestatic  #230                // Method calculateHand:(Ljava/lang/String;)I
      94: iadd
      95: istore        6
      97: goto          54
     100: iload         6
     102: istore_2
     103: iload_2
     104: ireturn
}


package function

fun main() {
    var calculatedTime: Double = 2.08

    val currentStudyMins = try {
        calculateCurrentTimeOfStudyingInMin("18:43", "")
    } catch (e: Exception) {
        0
    }

    val currentStudy = try {
        calculateCurrentTimeOfStudying(currentStudyMins)
    } catch (e: Exception) {
        0.0
    }

    calculatedTime = calculateTotalTimeOfStudying(calculatedTime, currentStudy)

    println(calculatedTime.toString().split(".").let { parts ->
        val mins = (parts[1] + "0").take(2)
        "${parts[0]}h ${mins}m"
    })
}

/**
 * This fun receives the already calculated time of studying (e.g. 1.2) and current time of studying (e.g. 2.2) and
 * returns a Double representing the sum of both values (3.2 in this example, which means 3h 20m).
 */
fun calculateTotalTimeOfStudying(calculatedTime: Double, currentTime: Double): Double {
    return calculatedTime + currentTime
}

/**
 * This fun receives currentMins and cutMins* and returns a Double value representing the currentTimeOfStudying
 * (e.g. 1.2) in which "1" means 1 hour and "2" means 20 minutes. Or total - 1h 20m.
 */
fun calculateCurrentTimeOfStudying(mins: Int, cutMins: Int = 0): Double {
    val reducedMins = mins - cutMins

    val hour = (reducedMins / 60).toString()
    val min = (reducedMins - (hour.toInt() * 60)).toString()

    val res = if (min.toInt() < 10) {
        "$hour.0$min".toDouble()
    } else {
        "$hour.$min".toDouble()
    }

    return res
}

// 15:20 - 16:40 (80m)
/**
 * This fun receives startTime (e.g. 15:20) and endTime (e.g. 16:40) and calculates current time of studying in mins
 * (80 for this example).
 */
fun calculateCurrentTimeOfStudyingInMin(startTime: String, endTime: String): Int {
    val minutesPerHour = 60

    val startHourInMins = startTime.removeRange(2, 5).toInt() * minutesPerHour
    val totalStartTimeInMins = startHourInMins + startTime.removeRange(0, 3).toInt()

    val endHourInMins = endTime.removeRange(2, 5).toInt() * minutesPerHour
    val totalEndTimeInMins = endHourInMins + endTime.removeRange(0, 3).toInt()

    return totalEndTimeInMins - totalStartTimeInMins
}

Compiled from "CalculateHoursOfStudying.kt"
public final class function.CalculateHoursOfStudyingKt {
  public static final void main();
    Code:
       0: ldc2_w        #9                  // double 2.08d
       3: dstore_0
       4: nop
       5: ldc           #12                 // String 18:43
       7: ldc           #14                 // String
       9: invokestatic  #18                 // Method calculateCurrentTimeOfStudyingInMin:(Ljava/lang/String;Ljava/lang/String;)I
      12: istore_3
      13: goto          20
      16: astore        4
      18: iconst_0
      19: istore_3
      20: iload_3
      21: istore_2
      22: nop
      23: iload_2
      24: iconst_0
      25: iconst_2
      26: aconst_null
      27: invokestatic  #22                 // Method calculateCurrentTimeOfStudying$default:(IIILjava/lang/Object;)D
      30: dstore        5
      32: goto          40
      35: astore        7
      37: dconst_0
      38: dstore        5
      40: dload         5
      42: dstore_3
      43: dload_0
      44: dload_3
      45: invokestatic  #26                 // Method calculateTotalTimeOfStudying:(DD)D
      48: dstore_0
      49: dload_0
      50: invokestatic  #32                 // Method java/lang/String.valueOf:(D)Ljava/lang/String;
      53: checkcast     #34                 // class java/lang/CharSequence
      56: iconst_1
      57: anewarray     #28                 // class java/lang/String
      60: astore        5
      62: aload         5
      64: iconst_0
      65: ldc           #36                 // String .
      67: aastore
      68: aload         5
      70: iconst_0
      71: iconst_0
      72: bipush        6
      74: aconst_null
      75: invokestatic  #42                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      78: astore        6
      80: iconst_0
      81: istore        7
      83: new           #44                 // class java/lang/StringBuilder
      86: dup
      87: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
      90: aload         6
      92: iconst_1
      93: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      98: checkcast     #28                 // class java/lang/String
     101: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     104: bipush        48
     106: invokevirtual #60                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     109: invokevirtual #64                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     112: iconst_2
     113: invokestatic  #68                 // Method kotlin/text/StringsKt.take:(Ljava/lang/String;I)Ljava/lang/String;
     116: astore        8
     118: new           #44                 // class java/lang/StringBuilder
     121: dup
     122: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
     125: aload         6
     127: iconst_0
     128: invokeinterface #53,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     133: checkcast     #28                 // class java/lang/String
     136: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     139: ldc           #70                 // String h
     141: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     144: aload         8
     146: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     149: bipush        109
     151: invokevirtual #60                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     154: invokevirtual #64                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     157: astore        5
     159: getstatic     #76                 // Field java/lang/System.out:Ljava/io/PrintStream;
     162: aload         5
     164: invokevirtual #82                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     167: return
    Exception table:
       from    to  target type
           4    13    16   Class java/lang/Exception
          22    32    35   Class java/lang/Exception

  public static final double calculateTotalTimeOfStudying(double, double);
    Code:
       0: dload_0
       1: dload_2
       2: dadd
       3: dreturn

  public static final double calculateCurrentTimeOfStudying(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: isub
       3: istore_2
       4: iload_2
       5: bipush        60
       7: idiv
       8: invokestatic  #100                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
      11: astore_3
      12: iload_2
      13: aload_3
      14: invokestatic  #106                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      17: bipush        60
      19: imul
      20: isub
      21: invokestatic  #100                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
      24: astore        4
      26: aload         4
      28: invokestatic  #106                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      31: bipush        10
      33: if_icmpge     66
      36: new           #44                 // class java/lang/StringBuilder
      39: dup
      40: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
      43: aload_3
      44: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      47: ldc           #108                // String .0
      49: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: aload         4
      54: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      57: invokevirtual #64                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      60: invokestatic  #114                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      63: goto          93
      66: new           #44                 // class java/lang/StringBuilder
      69: dup
      70: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
      73: aload_3
      74: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      77: bipush        46
      79: invokevirtual #60                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      82: aload         4
      84: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      87: invokevirtual #64                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      90: invokestatic  #114                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      93: dstore        5
      95: dload         5
      97: dreturn

  public static double calculateCurrentTimeOfStudying$default(int, int, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: iload_0
       9: iload_1
      10: invokestatic  #121                // Method calculateCurrentTimeOfStudying:(II)D
      13: dreturn

  public static final int calculateCurrentTimeOfStudyingInMin(java.lang.String, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #124                // String startTime
       3: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #132                // String endTime
       9: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: bipush        60
      14: istore_2
      15: aload_0
      16: astore        4
      18: iconst_2
      19: istore        5
      21: iconst_5
      22: istore        6
      24: aload         4
      26: checkcast     #34                 // class java/lang/CharSequence
      29: iload         5
      31: iload         6
      33: invokestatic  #136                // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;
      36: invokevirtual #137                // Method java/lang/Object.toString:()Ljava/lang/String;
      39: invokestatic  #106                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      42: iload_2
      43: imul
      44: istore_3
      45: iload_3
      46: aload_0
      47: astore        5
      49: iconst_0
      50: istore        6
      52: iconst_3
      53: istore        7
      55: aload         5
      57: checkcast     #34                 // class java/lang/CharSequence
      60: iload         6
      62: iload         7
      64: invokestatic  #136                // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;
      67: invokevirtual #137                // Method java/lang/Object.toString:()Ljava/lang/String;
      70: invokestatic  #106                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      73: iadd
      74: istore        4
      76: aload_1
      77: astore        6
      79: iconst_2
      80: istore        7
      82: iconst_5
      83: istore        8
      85: aload         6
      87: checkcast     #34                 // class java/lang/CharSequence
      90: iload         7
      92: iload         8
      94: invokestatic  #136                // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;
      97: invokevirtual #137                // Method java/lang/Object.toString:()Ljava/lang/String;
     100: invokestatic  #106                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     103: iload_2
     104: imul
     105: istore        5
     107: iload         5
     109: aload_1
     110: astore        7
     112: iconst_0
     113: istore        8
     115: iconst_3
     116: istore        9
     118: aload         7
     120: checkcast     #34                 // class java/lang/CharSequence
     123: iload         8
     125: iload         9
     127: invokestatic  #136                // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;
     130: invokevirtual #137                // Method java/lang/Object.toString:()Ljava/lang/String;
     133: invokestatic  #106                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     136: iadd
     137: istore        6
     139: iload         6
     141: iload         4
     143: isub
     144: ireturn

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


package practice
//reserve a table
//input 1: peopleCount
//input 2: each person first name
//input 3: each person spending

//min consumation: 10 BGN/person (one can pay for the other). 10bgn is okay for 1 person
//reservation failed/successful (? advance need to pay && ? total)
//program says ? expense(all), advance money = 20% spending/person

fun main() {
    val reservation = tableReserve()
    println(reservation)

    if (validateReservation(reservation)) {
        println("Valid reservation.")
        println("Your table's total bill is ${calculateTotalBill(reservation)}.")
        println("Your table's money in advance is ${calculateAdvanceMoney(reservation)}.")
    } else {
        println("Invalid reservation.")
    }
}

data class Reservation(val peopleCount: Int, val firstNames: List<String>, val individualBill: List<Double>)

private fun tableReserve(): Reservation {
    val peopleCount = readInput("people count").toInt()
    val firstNames = mutableListOf<String>()
    val individualBill = mutableListOf<Double>()

    for (i in 1..peopleCount) {
        println("Enter person $i")
        firstNames.add(readInput("first name"))
        individualBill.add(readInput("individual spending").toDouble())
    }

    return Reservation(peopleCount, firstNames, individualBill)
}

private fun readInput(message: String): String {
    println("Enter $message")
    return readln()
}

fun validateReservation(reservation: Reservation): Boolean {
    val tableMin = reservation.peopleCount * 10
    val totalIndividualBillPlans = reservation.individualBill.sum()

    return reservation.peopleCount > 0 && totalIndividualBillPlans >= tableMin
}

fun calculateAdvanceMoney(reservation: Reservation): Double {
    return reservation.individualBill.sum() * 0.2
}

fun calculateTotalBill(reservation: Reservation): Double {
    return reservation.individualBill.sum()
}

Compiled from "Reservation.kt"
public final class practice.ReservationKt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method tableReserve:()Lpractice/Reservation;
       3: astore_0
       4: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
       7: aload_0
       8: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      11: aload_0
      12: invokestatic  #26                 // Method validateReservation:(Lpractice/Reservation;)Z
      15: ifeq          98
      18: ldc           #28                 // String Valid reservation.
      20: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      23: swap
      24: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      27: new           #30                 // class java/lang/StringBuilder
      30: dup
      31: invokespecial #33                 // Method java/lang/StringBuilder."<init>":()V
      34: ldc           #35                 // String Your table\'s total bill is
      36: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      39: aload_0
      40: invokestatic  #43                 // Method calculateTotalBill:(Lpractice/Reservation;)D
      43: invokevirtual #46                 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;
      46: bipush        46
      48: invokevirtual #49                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      51: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      54: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      57: swap
      58: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      61: new           #30                 // class java/lang/StringBuilder
      64: dup
      65: invokespecial #33                 // Method java/lang/StringBuilder."<init>":()V
      68: ldc           #55                 // String Your table\'s money in advance is
      70: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      73: aload_0
      74: invokestatic  #58                 // Method calculateAdvanceMoney:(Lpractice/Reservation;)D
      77: invokevirtual #46                 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;
      80: bipush        46
      82: invokevirtual #49                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      85: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      88: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      91: swap
      92: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      95: goto          107
      98: ldc           #60                 // String Invalid reservation.
     100: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: return

  private static final practice.Reservation tableReserve();
    Code:
       0: ldc           #66                 // String people count
       2: invokestatic  #70                 // Method readInput:(Ljava/lang/String;)Ljava/lang/String;
       5: invokestatic  #76                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
       8: istore_0
       9: new           #78                 // class java/util/ArrayList
      12: dup
      13: invokespecial #79                 // Method java/util/ArrayList."<init>":()V
      16: checkcast     #81                 // class java/util/List
      19: astore_1
      20: new           #78                 // class java/util/ArrayList
      23: dup
      24: invokespecial #79                 // Method java/util/ArrayList."<init>":()V
      27: checkcast     #81                 // class java/util/List
      30: astore_2
      31: iconst_1
      32: istore_3
      33: iload_3
      34: iload_0
      35: if_icmpgt     105
      38: new           #30                 // class java/lang/StringBuilder
      41: dup
      42: invokespecial #33                 // Method java/lang/StringBuilder."<init>":()V
      45: ldc           #83                 // String Enter person
      47: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      50: iload_3
      51: invokevirtual #86                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      54: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      57: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      60: swap
      61: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      64: aload_1
      65: ldc           #88                 // String first name
      67: invokestatic  #70                 // Method readInput:(Ljava/lang/String;)Ljava/lang/String;
      70: invokeinterface #92,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      75: pop
      76: aload_2
      77: ldc           #94                 // String individual spending
      79: invokestatic  #70                 // Method readInput:(Ljava/lang/String;)Ljava/lang/String;
      82: invokestatic  #100                // Method java/lang/Double.parseDouble:(Ljava/lang/String;)D
      85: invokestatic  #104                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      88: invokeinterface #92,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      93: pop
      94: iload_3
      95: iload_0
      96: if_icmpeq     105
      99: iinc          3, 1
     102: goto          38
     105: new           #64                 // class practice/Reservation
     108: dup
     109: iload_0
     110: aload_1
     111: aload_2
     112: invokespecial #107                // Method practice/Reservation."<init>":(ILjava/util/List;Ljava/util/List;)V
     115: areturn

  private static final java.lang.String readInput(java.lang.String);
    Code:
       0: new           #30                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #33                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #115                // String Enter
       9: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      16: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      19: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      22: swap
      23: invokevirtual #22                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      26: invokestatic  #120                // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      29: areturn

  public static final boolean validateReservation(practice.Reservation);
    Code:
       0: aload_0
       1: ldc           #124                // String reservation
       3: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #134                // Method practice/Reservation.getPeopleCount:()I
      10: bipush        10
      12: imul
      13: istore_1
      14: aload_0
      15: invokevirtual #138                // Method practice/Reservation.getIndividualBill:()Ljava/util/List;
      18: checkcast     #140                // class java/lang/Iterable
      21: invokestatic  #146                // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D
      24: dstore_2
      25: aload_0
      26: invokevirtual #134                // Method practice/Reservation.getPeopleCount:()I
      29: ifle          43
      32: dload_2
      33: iload_1
      34: i2d
      35: dcmpl
      36: iflt          43
      39: iconst_1
      40: goto          44
      43: iconst_0
      44: ireturn

  public static final double calculateAdvanceMoney(practice.Reservation);
    Code:
       0: aload_0
       1: ldc           #124                // String reservation
       3: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #138                // Method practice/Reservation.getIndividualBill:()Ljava/util/List;
      10: checkcast     #140                // class java/lang/Iterable
      13: invokestatic  #146                // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D
      16: ldc2_w        #150                // double 0.2d
      19: dmul
      20: dreturn

  public static final double calculateTotalBill(practice.Reservation);
    Code:
       0: aload_0
       1: ldc           #124                // String reservation
       3: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #138                // Method practice/Reservation.getIndividualBill:()Ljava/util/List;
      10: checkcast     #140                // class java/lang/Iterable
      13: invokestatic  #146                // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D
      16: dreturn

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

Compiled from "Reservation.kt"
public final class practice.Reservation {
  private final int peopleCount;

  private final java.util.List<java.lang.String> firstNames;

  private final java.util.List<java.lang.Double> individualBill;

  public practice.Reservation(int, java.util.List<java.lang.String>, java.util.List<java.lang.Double>);
    Code:
       0: aload_2
       1: ldc           #10                 // String firstNames
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #18                 // String individualBill
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokespecial #21                 // Method java/lang/Object."<init>":()V
      16: aload_0
      17: iload_1
      18: putfield      #25                 // Field peopleCount:I
      21: aload_0
      22: aload_2
      23: putfield      #28                 // Field firstNames:Ljava/util/List;
      26: aload_0
      27: aload_3
      28: putfield      #30                 // Field individualBill:Ljava/util/List;
      31: return

  public final int getPeopleCount();
    Code:
       0: aload_0
       1: getfield      #25                 // Field peopleCount:I
       4: ireturn

  public final java.util.List<java.lang.String> getFirstNames();
    Code:
       0: aload_0
       1: getfield      #28                 // Field firstNames:Ljava/util/List;
       4: areturn

  public final java.util.List<java.lang.Double> getIndividualBill();
    Code:
       0: aload_0
       1: getfield      #30                 // Field individualBill:Ljava/util/List;
       4: areturn

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

  public final java.util.List<java.lang.String> component2();
    Code:
       0: aload_0
       1: getfield      #28                 // Field firstNames:Ljava/util/List;
       4: areturn

  public final java.util.List<java.lang.Double> component3();
    Code:
       0: aload_0
       1: getfield      #30                 // Field individualBill:Ljava/util/List;
       4: areturn

  public final practice.Reservation copy(int, java.util.List<java.lang.String>, java.util.List<java.lang.Double>);
    Code:
       0: aload_2
       1: ldc           #10                 // String firstNames
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #18                 // String individualBill
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #2                  // class practice/Reservation
      15: dup
      16: iload_1
      17: aload_2
      18: aload_3
      19: invokespecial #47                 // Method "<init>":(ILjava/util/List;Ljava/util/List;)V
      22: areturn

  public static practice.Reservation copy$default(practice.Reservation, int, java.util.List, java.util.List, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #25                 // Field peopleCount:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #28                 // Field firstNames:Ljava/util/List;
      23: astore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #30                 // Field individualBill:Ljava/util/List;
      35: astore_3
      36: aload_0
      37: iload_1
      38: aload_2
      39: aload_3
      40: invokevirtual #51                 // Method copy:(ILjava/util/List;Ljava/util/List;)Lpractice/Reservation;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #55                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #56                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #58                 // String Reservation(peopleCount=
       9: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #25                 // Field peopleCount:I
      16: invokevirtual #65                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #67                 // String , firstNames=
      21: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #28                 // Field firstNames:Ljava/util/List;
      28: invokevirtual #70                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: ldc           #72                 // String , individualBill=
      33: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #30                 // Field individualBill:Ljava/util/List;
      40: invokevirtual #70                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #75                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #77                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #25                 // Field peopleCount:I
       4: invokestatic  #83                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #28                 // Field firstNames:Ljava/util/List;
      16: invokevirtual #85                 // Method java/lang/Object.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #30                 // Field individualBill:Ljava/util/List;
      29: invokevirtual #85                 // Method java/lang/Object.hashCode:()I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class practice/Reservation
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class practice/Reservation
      20: astore_2
      21: aload_0
      22: getfield      #25                 // Field peopleCount:I
      25: aload_2
      26: getfield      #25                 // Field peopleCount:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #28                 // Field firstNames:Ljava/util/List;
      38: aload_2
      39: getfield      #28                 // Field firstNames:Ljava/util/List;
      42: invokestatic  #93                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          50
      48: iconst_0
      49: ireturn
      50: aload_0
      51: getfield      #30                 // Field individualBill:Ljava/util/List;
      54: aload_2
      55: getfield      #30                 // Field individualBill:Ljava/util/List;
      58: invokestatic  #93                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      61: ifne          66
      64: iconst_0
      65: ireturn
      66: iconst_1
      67: ireturn
}