package lain

import java.math.BigInteger

data class RangeList(val list: List<Range>) {
    companion object {
        // creates a rangelist from input range
        // merges ranges that overlap
        fun from(list: List<Range>):RangeList {
            val first = RangeList(listOf(list[0]))
            val rest = list.subList(1, list.size)

            return rest.fold(first) { a, e -> a.plus(e) }
        }

        fun from(range: Range):RangeList {
            return from(listOf(range))
        }

        // all values that are a member of a, b, or both
        fun union(a: RangeList, b: RangeList): RangeList {
            return from(a.list.plus(b.list))
        }

        // all values that are a member of both a and b
        fun intersection(a: RangeList, b: RangeList): RangeList {
            val aover = a.list.filter { b.hasOverlap(it) }
            val bover = b.list.filter { a.hasOverlap(it) }

            val both = aover.plus(bover)

            val first = RangeList(listOf(both[0]))
            val rest = both.subList(1, both.size)

            return rest.fold(first) { q, e -> plusAnd(q, e) }
        }

        // All values of u that are not values of a
        fun setDiff (u: RangeList, a: RangeList): RangeList {
            val (match, rest) = u.list.partition { a.hasOverlap(it) }
            val amatch = a.list.filter { u.hasOverlap(it) }

            // rest are all not values of a
            // just need to check match now...
            // maybe
            val res = match.map {
                val muta = mutableListOf<List<Range>>()
                for (q in amatch)
                    if (Range.overlaps(it, q))
                        muta.add(Range.subtract(it, q))
                muta.toList()
            }.flatten().flatten()

            return RangeList(res.subList(1, res.size).fold(RangeList(listOf(res[0]))) {
                q, e -> plusAnd(q, e)
            }.list.plus(rest))
        }

        // Values that are in either a or b, but not both
        fun symmetricDiff(a: RangeList, b: RangeList): RangeList {
            // union minus intersection
            return setDiff(union(a, b), intersection(a, b))
        }

        // idk how this works but uhh i think it does work...
        // maybe
        fun plusAnd (a: RangeList, b: Range): RangeList {
            val (m, r) = a.list.partition { Range.overlaps(it, b) }
            val c:Range = m.fold(b) { q, e -> Range.and(q, e) }
            return RangeList(r.plus(c))
        }
    }

    fun union(b: RangeList): RangeList {
        return union(this, b)
    }

    fun intersection(b: RangeList): RangeList {
        return intersection(this, b)
    }

    fun setDiff(b: RangeList): RangeList {
        return setDiff(this, b)
    }

    fun symmetricDiff(b: RangeList): RangeList {
        return symmetricDiff(this, b)
    }

    // returns a rangelist that is this list with range element added
    // merges ranges if there is an overlap with range
    fun plus(range: Range): RangeList {
        // list of elements in the rangelist that overlap with range
        val (match, rest) = this.list.partition { Range.overlaps(it, range) }
        val c:Range = match.fold(range) { a, e -> Range.or(a, e) }
        return RangeList(rest.plus(c))
    }

    // sorts the rangelist and returns it
    fun sort(): RangeList {
        return RangeList(this.list.sortedBy { it.min })
    }

    // returns true if range overlaps with any member of this
    fun hasOverlap(range: Range): Boolean {
        for (e in this.list)
            if (Range.overlaps(e, range)) return true
        return false
    }

    // prints the RangeList by turning the width of each range into a char array
    fun print() {
        val list = this.sort().list
        val arr = list.subList(1, list.size).fold(BigInteger.valueOf(list[0].width().toLong()).toByteArray()) {
            a, e -> a.plus(BigInteger.valueOf(e.width().toLong()).toByteArray())
        }

        for (a in arr) {
            print(a.toChar())
        }
    }
}

Compiled from "RangeList.kt"
public final class lain.RangeList {
  public static final lain.RangeList$Companion Companion;

  private final java.util.List<lain.Range> list;

  public lain.RangeList(java.util.List<lain.Range>);
    Code:
       0: aload_1
       1: ldc           #10                 // String list
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #22                 // Field list:Ljava/util/List;
      15: return

  public final java.util.List<lain.Range> getList();
    Code:
       0: aload_0
       1: getfield      #22                 // Field list:Ljava/util/List;
       4: areturn

  public final lain.RangeList union(lain.RangeList);
    Code:
       0: aload_1
       1: ldc           #31                 // String b
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #35                 // Field Companion:Llain/RangeList$Companion;
       9: aload_0
      10: aload_1
      11: invokevirtual #40                 // Method lain/RangeList$Companion.union:(Llain/RangeList;Llain/RangeList;)Llain/RangeList;
      14: areturn

  public final lain.RangeList intersection(lain.RangeList);
    Code:
       0: aload_1
       1: ldc           #31                 // String b
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #35                 // Field Companion:Llain/RangeList$Companion;
       9: aload_0
      10: aload_1
      11: invokevirtual #43                 // Method lain/RangeList$Companion.intersection:(Llain/RangeList;Llain/RangeList;)Llain/RangeList;
      14: areturn

  public final lain.RangeList setDiff(lain.RangeList);
    Code:
       0: aload_1
       1: ldc           #31                 // String b
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #35                 // Field Companion:Llain/RangeList$Companion;
       9: aload_0
      10: aload_1
      11: invokevirtual #46                 // Method lain/RangeList$Companion.setDiff:(Llain/RangeList;Llain/RangeList;)Llain/RangeList;
      14: areturn

  public final lain.RangeList symmetricDiff(lain.RangeList);
    Code:
       0: aload_1
       1: ldc           #31                 // String b
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #35                 // Field Companion:Llain/RangeList$Companion;
       9: aload_0
      10: aload_1
      11: invokevirtual #49                 // Method lain/RangeList$Companion.symmetricDiff:(Llain/RangeList;Llain/RangeList;)Llain/RangeList;
      14: areturn

  public final lain.RangeList plus(lain.Range);
    Code:
       0: aload_1
       1: ldc           #53                 // String range
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #22                 // Field list:Ljava/util/List;
      10: checkcast     #55                 // class java/lang/Iterable
      13: astore_3
      14: iconst_0
      15: istore        4
      17: new           #57                 // class java/util/ArrayList
      20: dup
      21: invokespecial #58                 // Method java/util/ArrayList."<init>":()V
      24: astore        5
      26: new           #57                 // class java/util/ArrayList
      29: dup
      30: invokespecial #58                 // Method java/util/ArrayList."<init>":()V
      33: astore        6
      35: aload_3
      36: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          105
      53: aload         7
      55: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        8
      62: aload         8
      64: checkcast     #74                 // class lain/Range
      67: astore        9
      69: iconst_0
      70: istore        10
      72: getstatic     #77                 // Field lain/Range.Companion:Llain/Range$Companion;
      75: aload         9
      77: aload_1
      78: invokevirtual #83                 // Method lain/Range$Companion.overlaps:(Llain/Range;Llain/Range;)Z
      81: ifeq          94
      84: aload         5
      86: aload         8
      88: invokevirtual #87                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      91: goto          101
      94: aload         6
      96: aload         8
      98: invokevirtual #87                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     101: pop
     102: goto          43
     105: new           #89                 // class kotlin/Pair
     108: dup
     109: aload         5
     111: aload         6
     113: invokespecial #92                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     116: astore_2
     117: aload_2
     118: invokevirtual #95                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     121: checkcast     #97                 // class java/util/List
     124: astore_3
     125: aload_2
     126: invokevirtual #100                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     129: checkcast     #97                 // class java/util/List
     132: astore        4
     134: aload_3
     135: checkcast     #55                 // class java/lang/Iterable
     138: astore        6
     140: iconst_0
     141: istore        7
     143: aload_1
     144: astore        8
     146: aload         6
     148: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     153: astore        9
     155: aload         9
     157: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     162: ifeq          203
     165: aload         9
     167: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     172: astore        10
     174: aload         8
     176: aload         10
     178: checkcast     #74                 // class lain/Range
     181: astore        11
     183: astore        12
     185: iconst_0
     186: istore        13
     188: getstatic     #77                 // Field lain/Range.Companion:Llain/Range$Companion;
     191: aload         12
     193: aload         11
     195: invokevirtual #104                // Method lain/Range$Companion.or:(Llain/Range;Llain/Range;)Llain/Range;
     198: astore        8
     200: goto          155
     203: aload         8
     205: astore        5
     207: new           #2                  // class lain/RangeList
     210: dup
     211: aload         4
     213: checkcast     #106                // class java/util/Collection
     216: aload         5
     218: invokestatic  #111                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     221: invokespecial #113                // Method "<init>":(Ljava/util/List;)V
     224: areturn

  public final lain.RangeList sort();
    Code:
       0: new           #2                  // class lain/RangeList
       3: dup
       4: aload_0
       5: getfield      #22                 // Field list:Ljava/util/List;
       8: checkcast     #55                 // class java/lang/Iterable
      11: astore_1
      12: iconst_0
      13: istore_2
      14: aload_1
      15: new           #138                // class lain/RangeList$sort$$inlined$sortedBy$1
      18: dup
      19: invokespecial #139                // Method lain/RangeList$sort$$inlined$sortedBy$1."<init>":()V
      22: checkcast     #141                // class java/util/Comparator
      25: invokestatic  #145                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      28: invokespecial #113                // Method "<init>":(Ljava/util/List;)V
      31: areturn

  public final boolean hasOverlap(lain.Range);
    Code:
       0: aload_1
       1: ldc           #53                 // String range
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #22                 // Field list:Ljava/util/List;
      10: invokeinterface #150,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      15: astore_2
      16: aload_2
      17: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      22: ifeq          48
      25: aload_2
      26: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      31: checkcast     #74                 // class lain/Range
      34: astore_3
      35: getstatic     #77                 // Field lain/Range.Companion:Llain/Range$Companion;
      38: aload_3
      39: aload_1
      40: invokevirtual #83                 // Method lain/Range$Companion.overlaps:(Llain/Range;Llain/Range;)Z
      43: ifeq          16
      46: iconst_1
      47: ireturn
      48: iconst_0
      49: ireturn

  public final void print();
    Code:
       0: aload_0
       1: invokevirtual #153                // Method sort:()Llain/RangeList;
       4: getfield      #22                 // Field list:Ljava/util/List;
       7: astore_1
       8: aload_1
       9: iconst_1
      10: aload_1
      11: invokeinterface #157,  1          // InterfaceMethod java/util/List.size:()I
      16: invokeinterface #161,  3          // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      21: checkcast     #55                 // class java/lang/Iterable
      24: astore_3
      25: aload_1
      26: iconst_0
      27: invokeinterface #165,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      32: checkcast     #74                 // class lain/Range
      35: invokevirtual #168                // Method lain/Range.width:()I
      38: i2l
      39: invokestatic  #174                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
      42: invokevirtual #178                // Method java/math/BigInteger.toByteArray:()[B
      45: astore        4
      47: iconst_0
      48: istore        5
      50: aload         4
      52: astore        6
      54: aload_3
      55: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        7
      62: aload         7
      64: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          128
      72: aload         7
      74: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        8
      81: aload         6
      83: aload         8
      85: checkcast     #74                 // class lain/Range
      88: astore        9
      90: astore        10
      92: iconst_0
      93: istore        11
      95: aload         10
      97: invokestatic  #182                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     100: aload         10
     102: aload         9
     104: invokevirtual #168                // Method lain/Range.width:()I
     107: i2l
     108: invokestatic  #174                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
     111: invokevirtual #178                // Method java/math/BigInteger.toByteArray:()[B
     114: dup
     115: ldc           #184                // String toByteArray(...)
     117: invokestatic  #187                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     120: invokestatic  #192                // Method kotlin/collections/ArraysKt.plus:([B[B)[B
     123: astore        6
     125: goto          62
     128: aload         6
     130: astore_2
     131: iconst_0
     132: istore_3
     133: aload_2
     134: arraylength
     135: istore        4
     137: iload_3
     138: iload         4
     140: if_icmpge     167
     143: aload_2
     144: iload_3
     145: baload
     146: istore        5
     148: iload         5
     150: i2c
     151: istore        6
     153: getstatic     #198                // Field java/lang/System.out:Ljava/io/PrintStream;
     156: iload         6
     158: invokevirtual #203                // Method java/io/PrintStream.print:(C)V
     161: iinc          3, 1
     164: goto          137
     167: return

  public final java.util.List<lain.Range> component1();
    Code:
       0: aload_0
       1: getfield      #22                 // Field list:Ljava/util/List;
       4: areturn

  public final lain.RangeList copy(java.util.List<lain.Range>);
    Code:
       0: aload_1
       1: ldc           #10                 // String list
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class lain/RangeList
       9: dup
      10: aload_1
      11: invokespecial #113                // Method "<init>":(Ljava/util/List;)V
      14: areturn

  public static lain.RangeList copy$default(lain.RangeList, java.util.List, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #22                 // Field list:Ljava/util/List;
      10: astore_1
      11: aload_0
      12: aload_1
      13: invokevirtual #216                // Method copy:(Ljava/util/List;)Llain/RangeList;
      16: areturn

  public java.lang.String toString();
    Code:
       0: new           #220                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #221                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #223                // String RangeList(list=
       9: invokevirtual #227                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #22                 // Field list:Ljava/util/List;
      16: invokevirtual #230                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: bipush        41
      21: invokevirtual #233                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      24: invokevirtual #235                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      27: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #22                 // Field list:Ljava/util/List;
       4: invokevirtual #238                // Method java/lang/Object.hashCode:()I
       7: 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 lain/RangeList
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class lain/RangeList
      20: astore_2
      21: aload_0
      22: getfield      #22                 // Field list:Ljava/util/List;
      25: aload_2
      26: getfield      #22                 // Field list:Ljava/util/List;
      29: invokestatic  #244                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: iconst_1
      38: ireturn

  static {};
    Code:
       0: new           #37                 // class lain/RangeList$Companion
       3: dup
       4: aconst_null
       5: invokespecial #249                // Method lain/RangeList$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #35                 // Field Companion:Llain/RangeList$Companion;
      11: return
}

Compiled from "Comparisons.kt"
public final class lain.RangeList$sort$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public lain.RangeList$sort$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class lain/Range
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method lain/Range.getMin:()I
      12: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class lain/Range
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method lain/Range.getMin:()I
      32: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aload         5
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "RangeList.kt"
public final class lain.RangeList$Companion {
  private lain.RangeList$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final lain.RangeList from(java.util.List<lain.Range>);
    Code:
       0: aload_1
       1: ldc           #16                 // String list
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #24                 // class lain/RangeList
       9: dup
      10: aload_1
      11: iconst_0
      12: invokeinterface #30,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      17: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      20: invokespecial #39                 // Method lain/RangeList."<init>":(Ljava/util/List;)V
      23: astore_2
      24: aload_1
      25: iconst_1
      26: aload_1
      27: invokeinterface #43,  1           // InterfaceMethod java/util/List.size:()I
      32: invokeinterface #47,  3           // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
      37: astore_3
      38: aload_3
      39: checkcast     #49                 // class java/lang/Iterable
      42: astore        4
      44: iconst_0
      45: istore        5
      47: aload_2
      48: astore        6
      50: aload         4
      52: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      57: astore        7
      59: aload         7
      61: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      66: ifeq          104
      69: aload         7
      71: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      76: astore        8
      78: aload         6
      80: aload         8
      82: checkcast     #65                 // class lain/Range
      85: astore        9
      87: astore        10
      89: iconst_0
      90: istore        11
      92: aload         10
      94: aload         9
      96: invokevirtual #69                 // Method lain/RangeList.plus:(Llain/Range;)Llain/RangeList;
      99: astore        6
     101: goto          59
     104: aload         6
     106: areturn

  public final lain.RangeList from(lain.Range);
    Code:
       0: aload_1
       1: ldc           #86                 // String range
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      11: invokevirtual #88                 // Method from:(Ljava/util/List;)Llain/RangeList;
      14: areturn

  public final lain.RangeList union(lain.RangeList, lain.RangeList);
    Code:
       0: aload_1
       1: ldc           #91                 // String a
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #93                 // String b
       9: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: aload_1
      14: invokevirtual #97                 // Method lain/RangeList.getList:()Ljava/util/List;
      17: checkcast     #99                 // class java/util/Collection
      20: aload_2
      21: invokevirtual #97                 // Method lain/RangeList.getList:()Ljava/util/List;
      24: checkcast     #49                 // class java/lang/Iterable
      27: invokestatic  #102                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
      30: invokevirtual #88                 // Method from:(Ljava/util/List;)Llain/RangeList;
      33: areturn

  public final lain.RangeList intersection(lain.RangeList, lain.RangeList);
    Code:
       0: aload_1
       1: ldc           #91                 // String a
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #93                 // String b
       9: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokevirtual #97                 // Method lain/RangeList.getList:()Ljava/util/List;
      16: checkcast     #49                 // class java/lang/Iterable
      19: astore        4
      21: iconst_0
      22: istore        5
      24: aload         4
      26: astore        6
      28: new           #105                // class java/util/ArrayList
      31: dup
      32: invokespecial #106                // Method java/util/ArrayList."<init>":()V
      35: checkcast     #99                 // class java/util/Collection
      38: astore        7
      40: iconst_0
      41: istore        8
      43: aload         6
      45: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        9
      52: aload         9
      54: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          103
      62: aload         9
      64: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        10
      71: aload         10
      73: checkcast     #65                 // class lain/Range
      76: astore        11
      78: iconst_0
      79: istore        12
      81: aload_2
      82: aload         11
      84: invokevirtual #110                // Method lain/RangeList.hasOverlap:(Llain/Range;)Z
      87: ifeq          52
      90: aload         7
      92: aload         10
      94: invokeinterface #114,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      99: pop
     100: goto          52
     103: aload         7
     105: checkcast     #26                 // class java/util/List
     108: nop
     109: astore_3
     110: aload_2
     111: invokevirtual #97                 // Method lain/RangeList.getList:()Ljava/util/List;
     114: checkcast     #49                 // class java/lang/Iterable
     117: astore        5
     119: iconst_0
     120: istore        6
     122: aload         5
     124: astore        7
     126: new           #105                // class java/util/ArrayList
     129: dup
     130: invokespecial #106                // Method java/util/ArrayList."<init>":()V
     133: checkcast     #99                 // class java/util/Collection
     136: astore        8
     138: iconst_0
     139: istore        9
     141: aload         7
     143: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     148: astore        10
     150: aload         10
     152: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     157: ifeq          201
     160: aload         10
     162: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     167: astore        11
     169: aload         11
     171: checkcast     #65                 // class lain/Range
     174: astore        12
     176: iconst_0
     177: istore        13
     179: aload_1
     180: aload         12
     182: invokevirtual #110                // Method lain/RangeList.hasOverlap:(Llain/Range;)Z
     185: ifeq          150
     188: aload         8
     190: aload         11
     192: invokeinterface #114,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     197: pop
     198: goto          150
     201: aload         8
     203: checkcast     #26                 // class java/util/List
     206: nop
     207: astore        4
     209: aload_3
     210: checkcast     #99                 // class java/util/Collection
     213: aload         4
     215: checkcast     #49                 // class java/lang/Iterable
     218: invokestatic  #102                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     221: astore        5
     223: new           #24                 // class lain/RangeList
     226: dup
     227: aload         5
     229: iconst_0
     230: invokeinterface #30,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     235: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     238: invokespecial #39                 // Method lain/RangeList."<init>":(Ljava/util/List;)V
     241: astore        6
     243: aload         5
     245: iconst_1
     246: aload         5
     248: invokeinterface #43,  1           // InterfaceMethod java/util/List.size:()I
     253: invokeinterface #47,  3           // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     258: astore        7
     260: aload         7
     262: checkcast     #49                 // class java/lang/Iterable
     265: astore        8
     267: iconst_0
     268: istore        9
     270: aload         6
     272: astore        10
     274: aload         8
     276: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     281: astore        11
     283: aload         11
     285: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     290: ifeq          331
     293: aload         11
     295: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     300: astore        12
     302: aload         10
     304: aload         12
     306: checkcast     #65                 // class lain/Range
     309: astore        13
     311: astore        14
     313: iconst_0
     314: istore        15
     316: getstatic     #117                // Field lain/RangeList.Companion:Llain/RangeList$Companion;
     319: aload         14
     321: aload         13
     323: invokevirtual #121                // Method plusAnd:(Llain/RangeList;Llain/Range;)Llain/RangeList;
     326: astore        10
     328: goto          283
     331: aload         10
     333: areturn

  public final lain.RangeList setDiff(lain.RangeList, lain.RangeList);
    Code:
       0: aload_1
       1: ldc           #139                // String u
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #91                 // String a
       9: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokevirtual #97                 // Method lain/RangeList.getList:()Ljava/util/List;
      16: checkcast     #49                 // class java/lang/Iterable
      19: astore        4
      21: iconst_0
      22: istore        5
      24: new           #105                // class java/util/ArrayList
      27: dup
      28: invokespecial #106                // Method java/util/ArrayList."<init>":()V
      31: astore        6
      33: new           #105                // class java/util/ArrayList
      36: dup
      37: invokespecial #106                // Method java/util/ArrayList."<init>":()V
      40: astore        7
      42: aload         4
      44: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      49: astore        8
      51: aload         8
      53: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          110
      61: aload         8
      63: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: astore        9
      70: aload         9
      72: checkcast     #65                 // class lain/Range
      75: astore        10
      77: iconst_0
      78: istore        11
      80: aload_2
      81: aload         10
      83: invokevirtual #110                // Method lain/RangeList.hasOverlap:(Llain/Range;)Z
      86: ifeq          99
      89: aload         6
      91: aload         9
      93: invokevirtual #140                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      96: goto          106
      99: aload         7
     101: aload         9
     103: invokevirtual #140                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     106: pop
     107: goto          51
     110: new           #142                // class kotlin/Pair
     113: dup
     114: aload         6
     116: aload         7
     118: invokespecial #145                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     121: astore_3
     122: aload_3
     123: invokevirtual #148                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     126: checkcast     #26                 // class java/util/List
     129: astore        4
     131: aload_3
     132: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     135: checkcast     #26                 // class java/util/List
     138: astore        5
     140: aload_2
     141: invokevirtual #97                 // Method lain/RangeList.getList:()Ljava/util/List;
     144: checkcast     #49                 // class java/lang/Iterable
     147: astore        7
     149: iconst_0
     150: istore        8
     152: aload         7
     154: astore        9
     156: new           #105                // class java/util/ArrayList
     159: dup
     160: invokespecial #106                // Method java/util/ArrayList."<init>":()V
     163: checkcast     #99                 // class java/util/Collection
     166: astore        10
     168: iconst_0
     169: istore        11
     171: aload         9
     173: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     178: astore        12
     180: aload         12
     182: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     187: ifeq          231
     190: aload         12
     192: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     197: astore        13
     199: aload         13
     201: checkcast     #65                 // class lain/Range
     204: astore        14
     206: iconst_0
     207: istore        15
     209: aload_1
     210: aload         14
     212: invokevirtual #110                // Method lain/RangeList.hasOverlap:(Llain/Range;)Z
     215: ifeq          180
     218: aload         10
     220: aload         13
     222: invokeinterface #114,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     227: pop
     228: goto          180
     231: aload         10
     233: checkcast     #26                 // class java/util/List
     236: nop
     237: astore        6
     239: aload         4
     241: checkcast     #49                 // class java/lang/Iterable
     244: astore        8
     246: iconst_0
     247: istore        9
     249: aload         8
     251: astore        10
     253: new           #105                // class java/util/ArrayList
     256: dup
     257: aload         8
     259: bipush        10
     261: invokestatic  #155                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     264: invokespecial #158                // Method java/util/ArrayList."<init>":(I)V
     267: checkcast     #99                 // class java/util/Collection
     270: astore        11
     272: iconst_0
     273: istore        12
     275: aload         10
     277: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     282: astore        13
     284: aload         13
     286: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     291: ifeq          414
     294: aload         13
     296: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     301: astore        14
     303: aload         11
     305: aload         14
     307: checkcast     #65                 // class lain/Range
     310: astore        15
     312: astore        20
     314: iconst_0
     315: istore        16
     317: new           #105                // class java/util/ArrayList
     320: dup
     321: invokespecial #106                // Method java/util/ArrayList."<init>":()V
     324: checkcast     #26                 // class java/util/List
     327: astore        17
     329: aload         6
     331: invokeinterface #159,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     336: astore        18
     338: aload         18
     340: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     345: ifeq          394
     348: aload         18
     350: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     355: checkcast     #65                 // class lain/Range
     358: astore        19
     360: getstatic     #162                // Field lain/Range.Companion:Llain/Range$Companion;
     363: aload         15
     365: aload         19
     367: invokevirtual #168                // Method lain/Range$Companion.overlaps:(Llain/Range;Llain/Range;)Z
     370: ifeq          338
     373: aload         17
     375: getstatic     #162                // Field lain/Range.Companion:Llain/Range$Companion;
     378: aload         15
     380: aload         19
     382: invokevirtual #172                // Method lain/Range$Companion.subtract:(Llain/Range;Llain/Range;)Ljava/util/List;
     385: invokeinterface #173,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     390: pop
     391: goto          338
     394: aload         17
     396: checkcast     #49                 // class java/lang/Iterable
     399: invokestatic  #177                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     402: aload         20
     404: swap
     405: invokeinterface #114,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     410: pop
     411: goto          284
     414: aload         11
     416: checkcast     #26                 // class java/util/List
     419: nop
     420: checkcast     #49                 // class java/lang/Iterable
     423: invokestatic  #180                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     426: checkcast     #49                 // class java/lang/Iterable
     429: invokestatic  #180                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     432: astore        7
     434: aload         7
     436: iconst_1
     437: aload         7
     439: invokeinterface #43,  1           // InterfaceMethod java/util/List.size:()I
     444: invokeinterface #47,  3           // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     449: checkcast     #49                 // class java/lang/Iterable
     452: astore        8
     454: new           #24                 // class lain/RangeList
     457: dup
     458: aload         7
     460: iconst_0
     461: invokeinterface #30,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     466: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     469: invokespecial #39                 // Method lain/RangeList."<init>":(Ljava/util/List;)V
     472: astore        9
     474: iconst_0
     475: istore        10
     477: aload         9
     479: astore        11
     481: aload         8
     483: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     488: astore        12
     490: aload         12
     492: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     497: ifeq          538
     500: aload         12
     502: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     507: astore        13
     509: aload         11
     511: aload         13
     513: checkcast     #65                 // class lain/Range
     516: astore        14
     518: astore        15
     520: iconst_0
     521: istore        16
     523: getstatic     #117                // Field lain/RangeList.Companion:Llain/RangeList$Companion;
     526: aload         15
     528: aload         14
     530: invokevirtual #121                // Method plusAnd:(Llain/RangeList;Llain/Range;)Llain/RangeList;
     533: astore        11
     535: goto          490
     538: aload         11
     540: invokevirtual #97                 // Method lain/RangeList.getList:()Ljava/util/List;
     543: checkcast     #99                 // class java/util/Collection
     546: aload         5
     548: checkcast     #49                 // class java/lang/Iterable
     551: invokestatic  #102                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     554: astore        21
     556: new           #24                 // class lain/RangeList
     559: dup
     560: aload         21
     562: invokespecial #39                 // Method lain/RangeList."<init>":(Ljava/util/List;)V
     565: areturn

  public final lain.RangeList symmetricDiff(lain.RangeList, lain.RangeList);
    Code:
       0: aload_1
       1: ldc           #91                 // String a
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #93                 // String b
       9: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: aload_0
      14: aload_1
      15: aload_2
      16: invokevirtual #202                // Method union:(Llain/RangeList;Llain/RangeList;)Llain/RangeList;
      19: aload_0
      20: aload_1
      21: aload_2
      22: invokevirtual #204                // Method intersection:(Llain/RangeList;Llain/RangeList;)Llain/RangeList;
      25: invokevirtual #206                // Method setDiff:(Llain/RangeList;Llain/RangeList;)Llain/RangeList;
      28: areturn

  public final lain.RangeList plusAnd(lain.RangeList, lain.Range);
    Code:
       0: aload_1
       1: ldc           #91                 // String a
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #93                 // String b
       9: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: invokevirtual #97                 // Method lain/RangeList.getList:()Ljava/util/List;
      16: checkcast     #49                 // class java/lang/Iterable
      19: astore        4
      21: iconst_0
      22: istore        5
      24: new           #105                // class java/util/ArrayList
      27: dup
      28: invokespecial #106                // Method java/util/ArrayList."<init>":()V
      31: astore        6
      33: new           #105                // class java/util/ArrayList
      36: dup
      37: invokespecial #106                // Method java/util/ArrayList."<init>":()V
      40: astore        7
      42: aload         4
      44: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      49: astore        8
      51: aload         8
      53: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          113
      61: aload         8
      63: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: astore        9
      70: aload         9
      72: checkcast     #65                 // class lain/Range
      75: astore        10
      77: iconst_0
      78: istore        11
      80: getstatic     #162                // Field lain/Range.Companion:Llain/Range$Companion;
      83: aload         10
      85: aload_2
      86: invokevirtual #168                // Method lain/Range$Companion.overlaps:(Llain/Range;Llain/Range;)Z
      89: ifeq          102
      92: aload         6
      94: aload         9
      96: invokevirtual #140                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      99: goto          109
     102: aload         7
     104: aload         9
     106: invokevirtual #140                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     109: pop
     110: goto          51
     113: new           #142                // class kotlin/Pair
     116: dup
     117: aload         6
     119: aload         7
     121: invokespecial #145                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     124: astore_3
     125: aload_3
     126: invokevirtual #148                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     129: checkcast     #26                 // class java/util/List
     132: astore        4
     134: aload_3
     135: invokevirtual #151                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     138: checkcast     #26                 // class java/util/List
     141: astore        5
     143: aload         4
     145: checkcast     #49                 // class java/lang/Iterable
     148: astore        7
     150: iconst_0
     151: istore        8
     153: aload_2
     154: astore        9
     156: aload         7
     158: invokeinterface #53,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     163: astore        10
     165: aload         10
     167: invokeinterface #59,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     172: ifeq          213
     175: aload         10
     177: invokeinterface #63,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     182: astore        11
     184: aload         9
     186: aload         11
     188: checkcast     #65                 // class lain/Range
     191: astore        12
     193: astore        13
     195: iconst_0
     196: istore        14
     198: getstatic     #162                // Field lain/Range.Companion:Llain/Range$Companion;
     201: aload         13
     203: aload         12
     205: invokevirtual #210                // Method lain/Range$Companion.and:(Llain/Range;Llain/Range;)Llain/Range;
     208: astore        9
     210: goto          165
     213: aload         9
     215: astore        6
     217: new           #24                 // class lain/RangeList
     220: dup
     221: aload         5
     223: checkcast     #99                 // class java/util/Collection
     226: aload         6
     228: invokestatic  #213                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     231: invokespecial #39                 // Method lain/RangeList."<init>":(Ljava/util/List;)V
     234: areturn

  public lain.RangeList$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #220                // Method "<init>":()V
       4: return
}


package com.zortek.kata.yatzy

import java.util.stream.Stream

class DiceRoll(private val dice: List<Int>) {
    fun yatzy(): Boolean {
        return groupByValue()
            .values
            .any { it == 5 }
    }

    fun isFullHouse(): Boolean {
        val hasThreeOfAKind = getDiceWithCountGreaterThan(3) != 0
        val hasPair = !findPairs().isEmpty()
        val isYatzy = yatzy() //todo :it's debatable
        return hasThreeOfAKind && hasPair && !isYatzy
    }

    fun countDice(dice: Int): Int {
        return groupByValue()[dice] ?: 0
    }

    fun ones(roll: DiceRoll): Int {
        return roll.countDice(1)
    }

    fun twos(roll: DiceRoll): Int {
        return roll.countDice(2) * 2
    }

    fun threes(roll: DiceRoll): Int {
        return roll.countDice(3) * 3
    }

    fun fours(roll: DiceRoll): Int {
        return roll.countDice(4) * 4
    }

    fun fives(roll: DiceRoll): Int {
        return roll.countDice(5) * 5
    }

    fun sixes(roll: DiceRoll): Int {
        return roll.countDice(6) * 6
    }

    fun findPairs(): List<Int> {
        return filterNumberOfDiceGreaterThan(2)
            .sorted(Comparator.reverseOrder())
            .toList()
    }

    fun getDiceWithCountGreaterThan(n: Int) = filterNumberOfDiceGreaterThan(n)
        .findFirst()
        .orElse(0)!!

    fun sum() = dice.sum()

    fun isSmallStraight() = sort() == SMALL_STRAIGHT

    fun isLargeStraight() = sort() == LARGE_STRAIGHT

    private fun sort() = dice.sorted()

    private fun filterNumberOfDiceGreaterThan(n: Int): Stream<Int> {
        return groupByValue()
            .entries
            .stream()
            .filter { it.value >= n }
            .map { it.key }
    }

    private fun groupByValue(): Map<Int, Int> {
        return dice
            .groupingBy { it }
            .eachCount()
    }

    companion object {
        private val SMALL_STRAIGHT: List<Int> = listOf(1, 2, 3, 4, 5)
        private val LARGE_STRAIGHT: List<Int> = listOf(2, 3, 4, 5, 6)
        fun of(d1: Int, d2: Int, d3: Int, d4: Int, d5: Int) = DiceRoll(listOf(d1, d2, d3, d4, d5))
    }
}

Compiled from "_Collections.kt"
public final class com.zortek.kata.yatzy.DiceRoll$groupByValue$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.Integer, java.lang.Integer> {
  final java.lang.Iterable $this_groupingBy;

  public com.zortek.kata.yatzy.DiceRoll$groupByValue$$inlined$groupingBy$1(java.lang.Iterable);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<java.lang.Integer> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       4: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: areturn

  public java.lang.Integer keyOf(java.lang.Integer);
    Code:
       0: aload_1
       1: checkcast     #37                 // class java/lang/Number
       4: invokevirtual #41                 // Method java/lang/Number.intValue:()I
       7: istore_2
       8: iconst_0
       9: istore_3
      10: iload_2
      11: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: areturn
}

Compiled from "DiceRoll.kt"
public final class com.zortek.kata.yatzy.DiceRoll {
  public static final com.zortek.kata.yatzy.DiceRoll$Companion Companion;

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

  private static final java.util.List<java.lang.Integer> SMALL_STRAIGHT;

  private static final java.util.List<java.lang.Integer> LARGE_STRAIGHT;

  public com.zortek.kata.yatzy.DiceRoll(java.util.List<java.lang.Integer>);
    Code:
       0: aload_1
       1: ldc           #10                 // String dice
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #22                 // Field dice:Ljava/util/List;
      15: return

  public final boolean yatzy();
    Code:
       0: aload_0
       1: invokespecial #30                 // Method groupByValue:()Ljava/util/Map;
       4: invokeinterface #36,  1           // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
       9: checkcast     #38                 // class java/lang/Iterable
      12: astore_1
      13: nop
      14: iconst_0
      15: istore_2
      16: aload_1
      17: instanceof    #40                 // class java/util/Collection
      20: ifeq          39
      23: aload_1
      24: checkcast     #40                 // class java/util/Collection
      27: invokeinterface #43,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      32: ifeq          39
      35: iconst_0
      36: goto          95
      39: aload_1
      40: invokeinterface #47,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore_3
      46: aload_3
      47: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          94
      55: aload_3
      56: invokeinterface #56,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        4
      63: aload         4
      65: checkcast     #58                 // class java/lang/Number
      68: invokevirtual #62                 // Method java/lang/Number.intValue:()I
      71: istore        5
      73: iconst_0
      74: istore        6
      76: iload         5
      78: iconst_5
      79: if_icmpne     86
      82: iconst_1
      83: goto          87
      86: iconst_0
      87: ifeq          46
      90: iconst_1
      91: goto          95
      94: iconst_0
      95: ireturn

  public final boolean isFullHouse();
    Code:
       0: aload_0
       1: iconst_3
       2: invokevirtual #75                 // Method getDiceWithCountGreaterThan:(I)I
       5: ifeq          12
       8: iconst_1
       9: goto          13
      12: iconst_0
      13: istore_1
      14: aload_0
      15: invokevirtual #79                 // Method findPairs:()Ljava/util/List;
      18: invokeinterface #82,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      23: ifne          30
      26: iconst_1
      27: goto          31
      30: iconst_0
      31: istore_2
      32: aload_0
      33: invokevirtual #84                 // Method yatzy:()Z
      36: istore_3
      37: iload_1
      38: ifeq          53
      41: iload_2
      42: ifeq          53
      45: iload_3
      46: ifne          53
      49: iconst_1
      50: goto          54
      53: iconst_0
      54: ireturn

  public final int countDice(int);
    Code:
       0: aload_0
       1: invokespecial #30                 // Method groupByValue:()Ljava/util/Map;
       4: iload_1
       5: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       8: invokeinterface #99,  2           // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      13: checkcast     #91                 // class java/lang/Integer
      16: dup
      17: ifnull        26
      20: invokevirtual #100                // Method java/lang/Integer.intValue:()I
      23: goto          28
      26: pop
      27: iconst_0
      28: ireturn

  public final int ones(com.zortek.kata.yatzy.DiceRoll);
    Code:
       0: aload_1
       1: ldc           #104                // String roll
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: iconst_1
       8: invokevirtual #106                // Method countDice:(I)I
      11: ireturn

  public final int twos(com.zortek.kata.yatzy.DiceRoll);
    Code:
       0: aload_1
       1: ldc           #104                // String roll
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: iconst_2
       8: invokevirtual #106                // Method countDice:(I)I
      11: iconst_2
      12: imul
      13: ireturn

  public final int threes(com.zortek.kata.yatzy.DiceRoll);
    Code:
       0: aload_1
       1: ldc           #104                // String roll
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: iconst_3
       8: invokevirtual #106                // Method countDice:(I)I
      11: iconst_3
      12: imul
      13: ireturn

  public final int fours(com.zortek.kata.yatzy.DiceRoll);
    Code:
       0: aload_1
       1: ldc           #104                // String roll
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: iconst_4
       8: invokevirtual #106                // Method countDice:(I)I
      11: iconst_4
      12: imul
      13: ireturn

  public final int fives(com.zortek.kata.yatzy.DiceRoll);
    Code:
       0: aload_1
       1: ldc           #104                // String roll
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: iconst_5
       8: invokevirtual #106                // Method countDice:(I)I
      11: iconst_5
      12: imul
      13: ireturn

  public final int sixes(com.zortek.kata.yatzy.DiceRoll);
    Code:
       0: aload_1
       1: ldc           #104                // String roll
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: bipush        6
       9: invokevirtual #106                // Method countDice:(I)I
      12: bipush        6
      14: imul
      15: ireturn

  public final java.util.List<java.lang.Integer> findPairs();
    Code:
       0: aload_0
       1: iconst_2
       2: invokespecial #116                // Method filterNumberOfDiceGreaterThan:(I)Ljava/util/stream/Stream;
       5: invokestatic  #122                // InterfaceMethod java/util/Comparator.reverseOrder:()Ljava/util/Comparator;
       8: invokeinterface #128,  2          // InterfaceMethod java/util/stream/Stream.sorted:(Ljava/util/Comparator;)Ljava/util/stream/Stream;
      13: invokeinterface #131,  1          // InterfaceMethod java/util/stream/Stream.toList:()Ljava/util/List;
      18: dup
      19: ldc           #133                // String toList(...)
      21: invokestatic  #136                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      24: areturn

  public final int getDiceWithCountGreaterThan(int);
    Code:
       0: aload_0
       1: iload_1
       2: invokespecial #116                // Method filterNumberOfDiceGreaterThan:(I)Ljava/util/stream/Stream;
       5: invokeinterface #140,  1          // InterfaceMethod java/util/stream/Stream.findFirst:()Ljava/util/Optional;
      10: iconst_0
      11: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: invokevirtual #145                // Method java/util/Optional.orElse:(Ljava/lang/Object;)Ljava/lang/Object;
      17: dup
      18: invokestatic  #149                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      21: checkcast     #58                 // class java/lang/Number
      24: invokevirtual #62                 // Method java/lang/Number.intValue:()I
      27: ireturn

  public final int sum();
    Code:
       0: aload_0
       1: getfield      #22                 // Field dice:Ljava/util/List;
       4: checkcast     #38                 // class java/lang/Iterable
       7: invokestatic  #157                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
      10: ireturn

  public final boolean isSmallStraight();
    Code:
       0: aload_0
       1: invokespecial #161                // Method sort:()Ljava/util/List;
       4: getstatic     #164                // Field SMALL_STRAIGHT:Ljava/util/List;
       7: invokestatic  #168                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      10: ireturn

  public final boolean isLargeStraight();
    Code:
       0: aload_0
       1: invokespecial #161                // Method sort:()Ljava/util/List;
       4: getstatic     #172                // Field LARGE_STRAIGHT:Ljava/util/List;
       7: invokestatic  #168                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      10: ireturn

  private final java.util.List<java.lang.Integer> sort();
    Code:
       0: aload_0
       1: getfield      #22                 // Field dice:Ljava/util/List;
       4: checkcast     #38                 // class java/lang/Iterable
       7: invokestatic  #175                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
      10: areturn

  private final java.util.stream.Stream<java.lang.Integer> filterNumberOfDiceGreaterThan(int);
    Code:
       0: aload_0
       1: invokespecial #30                 // Method groupByValue:()Ljava/util/Map;
       4: invokeinterface #180,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
       9: invokeinterface #186,  1          // InterfaceMethod java/util/Set.stream:()Ljava/util/stream/Stream;
      14: iload_1
      15: invokedynamic #205,  0            // InvokeDynamic #0:invoke:(I)Lkotlin/jvm/functions/Function1;
      20: invokedynamic #216,  0            // InvokeDynamic #1:test:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Predicate;
      25: invokeinterface #220,  2          // InterfaceMethod java/util/stream/Stream.filter:(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;
      30: invokedynamic #229,  0            // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
      35: invokedynamic #240,  0            // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;
      40: invokeinterface #244,  2          // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;
      45: dup
      46: ldc           #246                // String map(...)
      48: invokestatic  #136                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      51: areturn

  private final java.util.Map<java.lang.Integer, java.lang.Integer> groupByValue();
    Code:
       0: aload_0
       1: getfield      #22                 // Field dice:Ljava/util/List;
       4: checkcast     #38                 // class java/lang/Iterable
       7: astore_1
       8: nop
       9: iconst_0
      10: istore_2
      11: new           #249                // class com/zortek/kata/yatzy/DiceRoll$groupByValue$$inlined$groupingBy$1
      14: dup
      15: aload_1
      16: invokespecial #252                // Method com/zortek/kata/yatzy/DiceRoll$groupByValue$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
      19: checkcast     #254                // class kotlin/collections/Grouping
      22: invokestatic  #260                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
      25: areturn

  private static final boolean filterNumberOfDiceGreaterThan$lambda$1(int, java.util.Map$Entry);
    Code:
       0: aload_1
       1: invokeinterface #267,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
       6: checkcast     #58                 // class java/lang/Number
       9: invokevirtual #62                 // Method java/lang/Number.intValue:()I
      12: iload_0
      13: if_icmplt     20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ireturn

  private static final boolean filterNumberOfDiceGreaterThan$lambda$2(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #273,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #275                // class java/lang/Boolean
      10: invokevirtual #278                // Method java/lang/Boolean.booleanValue:()Z
      13: ireturn

  private static final java.lang.Integer filterNumberOfDiceGreaterThan$lambda$3(java.util.Map$Entry);
    Code:
       0: aload_0
       1: invokeinterface #284,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
       6: checkcast     #91                 // class java/lang/Integer
       9: areturn

  private static final java.lang.Integer filterNumberOfDiceGreaterThan$lambda$4(kotlin.jvm.functions.Function1, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #273,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
       7: checkcast     #91                 // class java/lang/Integer
      10: areturn

  static {};
    Code:
       0: new           #287                // class com/zortek/kata/yatzy/DiceRoll$Companion
       3: dup
       4: aconst_null
       5: invokespecial #290                // Method com/zortek/kata/yatzy/DiceRoll$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #294                // Field Companion:Lcom/zortek/kata/yatzy/DiceRoll$Companion;
      11: iconst_5
      12: anewarray     #91                 // class java/lang/Integer
      15: astore_0
      16: aload_0
      17: iconst_0
      18: iconst_1
      19: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      22: aastore
      23: aload_0
      24: iconst_1
      25: iconst_2
      26: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      29: aastore
      30: aload_0
      31: iconst_2
      32: iconst_3
      33: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      36: aastore
      37: aload_0
      38: iconst_3
      39: iconst_4
      40: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: aastore
      44: aload_0
      45: iconst_4
      46: iconst_5
      47: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      50: aastore
      51: aload_0
      52: invokestatic  #298                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      55: putstatic     #164                // Field SMALL_STRAIGHT:Ljava/util/List;
      58: iconst_5
      59: anewarray     #91                 // class java/lang/Integer
      62: astore_0
      63: aload_0
      64: iconst_0
      65: iconst_2
      66: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      69: aastore
      70: aload_0
      71: iconst_1
      72: iconst_3
      73: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      76: aastore
      77: aload_0
      78: iconst_2
      79: iconst_4
      80: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      83: aastore
      84: aload_0
      85: iconst_3
      86: iconst_5
      87: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      90: aastore
      91: aload_0
      92: iconst_4
      93: bipush        6
      95: invokestatic  #95                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      98: aastore
      99: aload_0
     100: invokestatic  #298                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     103: putstatic     #172                // Field LARGE_STRAIGHT:Ljava/util/List;
     106: return
}

Compiled from "DiceRoll.kt"
public final class com.zortek.kata.yatzy.DiceRoll$Companion {
  private com.zortek.kata.yatzy.DiceRoll$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final com.zortek.kata.yatzy.DiceRoll of(int, int, int, int, int);
    Code:
       0: new           #15                 // class com/zortek/kata/yatzy/DiceRoll
       3: dup
       4: iconst_5
       5: anewarray     #17                 // class java/lang/Integer
       8: astore        6
      10: aload         6
      12: iconst_0
      13: iload_1
      14: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: aastore
      18: aload         6
      20: iconst_1
      21: iload_2
      22: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: aastore
      26: aload         6
      28: iconst_2
      29: iload_3
      30: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: aastore
      34: aload         6
      36: iconst_3
      37: iload         4
      39: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      42: aastore
      43: aload         6
      45: iconst_4
      46: iload         5
      48: invokestatic  #21                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      51: aastore
      52: aload         6
      54: invokestatic  #27                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      57: invokespecial #30                 // Method com/zortek/kata/yatzy/DiceRoll."<init>":(Ljava/util/List;)V
      60: areturn

  public com.zortek.kata.yatzy.DiceRoll$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #38                 // Method "<init>":()V
       4: return
}


package com.github.mmauro94.media_merger.util

import java.math.BigDecimal
import java.time.Duration
import java.util.concurrent.TimeUnit

fun Duration.toTimeString(): String {
    val abs = abs()
    val firstPart = (if (isNegative) "-" else "") + mutableListOf<String>().apply {
        fun add(v: Int) {
            add(v.toString().padStart(2, '0'))
        }
        if (abs.toHoursPart() > 0) {
            add(abs.toHoursPart())
        }
        add(abs.toMinutesPart())
        add(abs.toSecondsPart())
    }.joinToString(":")

    val secondPart = if (abs.nano > 0) {
        mutableListOf<String>().apply {
            var added = false
            fun add(v: Int) {
                if (added || v > 0) {
                    add(v.toString().padStart(3, '0'))
                    added = true
                }
            }

            add(abs.nano % 1000)
            add((abs.nano / 1000) % 1000)
            add(abs.toMillisPart())
            reverse()
        }.joinToString(separator = "", prefix = ".")
    } else ""

    return firstPart + secondPart
}

fun Duration?.toTimeStringOrUnknown(): String = this?.toTimeString() ?: "Unknown"

fun String.parseTimeStringOrNull(): Duration? {
    val regex = "(-?)(?:(?:([0-9]{1,2}):)?([0-9]{1,2}):)?([0-9]{1,2})(?:\\.([0-9]{1,9}))?".toRegex()
    val units = listOf(TimeUnit.HOURS, TimeUnit.MINUTES, TimeUnit.SECONDS)
    return regex.matchEntire(this)?.let { m ->
        val neg = m.groupValues[1] == "-"
        val totalNanos =
            m.groupValues.drop(2).zip(units).map { (match, unit) ->
                unit.toNanos(match.toLongOrNull() ?: 0)
            }.sum() + m.groupValues.last().padEnd(9, '0').toLong()
        Duration.ofNanos(totalNanos * if (neg) -1 else 1)
    }
}

/**
 * Converts [this] double as a number of seconds and coverts it to a [Duration]
 */
fun Double.toSecondsDuration(onZero: Duration? = null): Duration? {
    check(this >= 0)
    return if (this == 0.0) onZero else Duration.ofSeconds(toLong(), ((this % 1) * 1000000000).toLong())!!
}

/**
 * Converts [this] BigDecimal as a number of seconds and coverts it to a [Duration]
 */
fun BigDecimal.toSecondsDuration() = Duration.ofNanos(this.setScale(9).unscaledValue().longValueExact())!!

/**
 * Converts this duration to a [BigDecimal] in seconds and returns its plain string representation.
 */
fun Duration.toTotalSeconds(): String = BigDecimal.valueOf(toNanos(), 9).toPlainString()

/**
 * Sums this iterable of [Duration]s.
 */
fun Iterable<Duration>.sum(): Duration = fold(Duration.ZERO) { acc, it -> acc + it }

Compiled from "DurationUtils.kt"
public final class com.github.mmauro94.media_merger.util.DurationUtilsKt {
  public static final java.lang.String toTimeString(java.time.Duration);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #21                 // Method java/time/Duration.abs:()Ljava/time/Duration;
      10: astore_1
      11: new           #23                 // class java/lang/StringBuilder
      14: dup
      15: invokespecial #27                 // Method java/lang/StringBuilder."<init>":()V
      18: aload_0
      19: invokevirtual #31                 // Method java/time/Duration.isNegative:()Z
      22: ifeq          30
      25: ldc           #33                 // String -
      27: goto          32
      30: ldc           #35                 // String
      32: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      35: new           #41                 // class java/util/ArrayList
      38: dup
      39: invokespecial #42                 // Method java/util/ArrayList."<init>":()V
      42: checkcast     #44                 // class java/util/List
      45: astore_3
      46: aload_3
      47: astore        4
      49: astore        8
      51: iconst_0
      52: istore        5
      54: aload_1
      55: invokevirtual #48                 // Method java/time/Duration.toHoursPart:()I
      58: ifle          70
      61: aload         4
      63: aload_1
      64: invokevirtual #48                 // Method java/time/Duration.toHoursPart:()I
      67: invokestatic  #52                 // Method toTimeString$lambda$0$add:(Ljava/util/List;I)V
      70: aload         4
      72: aload_1
      73: invokevirtual #55                 // Method java/time/Duration.toMinutesPart:()I
      76: invokestatic  #52                 // Method toTimeString$lambda$0$add:(Ljava/util/List;I)V
      79: aload         4
      81: aload_1
      82: invokevirtual #58                 // Method java/time/Duration.toSecondsPart:()I
      85: invokestatic  #52                 // Method toTimeString$lambda$0$add:(Ljava/util/List;I)V
      88: nop
      89: aload         8
      91: aload_3
      92: checkcast     #60                 // class java/lang/Iterable
      95: ldc           #62                 // String :
      97: checkcast     #64                 // class java/lang/CharSequence
     100: aconst_null
     101: aconst_null
     102: iconst_0
     103: aconst_null
     104: aconst_null
     105: bipush        62
     107: aconst_null
     108: invokestatic  #70                 // 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;
     111: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     114: invokevirtual #74                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     117: astore_2
     118: aload_1
     119: invokevirtual #77                 // Method java/time/Duration.getNano:()I
     122: ifle          232
     125: new           #41                 // class java/util/ArrayList
     128: dup
     129: invokespecial #42                 // Method java/util/ArrayList."<init>":()V
     132: checkcast     #44                 // class java/util/List
     135: astore        4
     137: aload         4
     139: astore        5
     141: iconst_0
     142: istore        6
     144: new           #79                 // class kotlin/jvm/internal/Ref$BooleanRef
     147: dup
     148: invokespecial #80                 // Method kotlin/jvm/internal/Ref$BooleanRef."<init>":()V
     151: astore        7
     153: aload         7
     155: aload         5
     157: aload_1
     158: invokevirtual #77                 // Method java/time/Duration.getNano:()I
     161: sipush        1000
     164: irem
     165: invokestatic  #84                 // Method toTimeString$lambda$2$add$1:(Lkotlin/jvm/internal/Ref$BooleanRef;Ljava/util/List;I)V
     168: aload         7
     170: aload         5
     172: aload_1
     173: invokevirtual #77                 // Method java/time/Duration.getNano:()I
     176: sipush        1000
     179: idiv
     180: sipush        1000
     183: irem
     184: invokestatic  #84                 // Method toTimeString$lambda$2$add$1:(Lkotlin/jvm/internal/Ref$BooleanRef;Ljava/util/List;I)V
     187: aload         7
     189: aload         5
     191: aload_1
     192: invokevirtual #87                 // Method java/time/Duration.toMillisPart:()I
     195: invokestatic  #84                 // Method toTimeString$lambda$2$add$1:(Lkotlin/jvm/internal/Ref$BooleanRef;Ljava/util/List;I)V
     198: aload         5
     200: invokestatic  #91                 // Method kotlin/collections/CollectionsKt.reverse:(Ljava/util/List;)V
     203: nop
     204: aload         4
     206: checkcast     #60                 // class java/lang/Iterable
     209: ldc           #35                 // String
     211: checkcast     #64                 // class java/lang/CharSequence
     214: ldc           #93                 // String .
     216: checkcast     #64                 // class java/lang/CharSequence
     219: aconst_null
     220: iconst_0
     221: aconst_null
     222: aconst_null
     223: bipush        60
     225: aconst_null
     226: invokestatic  #70                 // 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;
     229: goto          234
     232: ldc           #35                 // String
     234: astore_3
     235: new           #23                 // class java/lang/StringBuilder
     238: dup
     239: invokespecial #27                 // Method java/lang/StringBuilder."<init>":()V
     242: aload_2
     243: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     246: aload_3
     247: invokevirtual #39                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     250: invokevirtual #74                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     253: areturn

  public static final java.lang.String toTimeStringOrUnknown(java.time.Duration);
    Code:
       0: aload_0
       1: dup
       2: ifnull        12
       5: invokestatic  #112                // Method toTimeString:(Ljava/time/Duration;)Ljava/lang/String;
       8: dup
       9: ifnonnull     15
      12: pop
      13: ldc           #114                // String Unknown
      15: areturn

  public static final java.time.Duration parseTimeStringOrNull(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #119                // class kotlin/text/Regex
       9: dup
      10: ldc           #121                // String (-?)(?:(?:([0-9]{1,2}):)?([0-9]{1,2}):)?([0-9]{1,2})(?:\\.([0-9]{1,9}))?
      12: invokespecial #124                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      15: astore_1
      16: iconst_3
      17: anewarray     #126                // class java/util/concurrent/TimeUnit
      20: astore_3
      21: aload_3
      22: iconst_0
      23: getstatic     #130                // Field java/util/concurrent/TimeUnit.HOURS:Ljava/util/concurrent/TimeUnit;
      26: aastore
      27: aload_3
      28: iconst_1
      29: getstatic     #133                // Field java/util/concurrent/TimeUnit.MINUTES:Ljava/util/concurrent/TimeUnit;
      32: aastore
      33: aload_3
      34: iconst_2
      35: getstatic     #136                // Field java/util/concurrent/TimeUnit.SECONDS:Ljava/util/concurrent/TimeUnit;
      38: aastore
      39: aload_3
      40: invokestatic  #140                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      43: astore_2
      44: aload_1
      45: aload_0
      46: checkcast     #64                 // class java/lang/CharSequence
      49: invokevirtual #144                // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      52: dup
      53: ifnull        296
      56: astore        4
      58: iconst_0
      59: istore        5
      61: aload         4
      63: invokeinterface #150,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      68: iconst_1
      69: invokeinterface #154,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      74: ldc           #33                 // String -
      76: invokestatic  #158                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      79: istore        6
      81: aload         4
      83: invokeinterface #150,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
      88: checkcast     #60                 // class java/lang/Iterable
      91: iconst_2
      92: invokestatic  #162                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      95: checkcast     #60                 // class java/lang/Iterable
      98: aload_2
      99: checkcast     #60                 // class java/lang/Iterable
     102: invokestatic  #166                // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
     105: checkcast     #60                 // class java/lang/Iterable
     108: astore        7
     110: iconst_0
     111: istore        8
     113: aload         7
     115: astore        9
     117: new           #41                 // class java/util/ArrayList
     120: dup
     121: aload         7
     123: bipush        10
     125: invokestatic  #170                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     128: invokespecial #173                // Method java/util/ArrayList."<init>":(I)V
     131: checkcast     #175                // class java/util/Collection
     134: astore        10
     136: iconst_0
     137: istore        11
     139: aload         9
     141: invokeinterface #179,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     146: astore        12
     148: aload         12
     150: invokeinterface #184,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     155: ifeq          238
     158: aload         12
     160: invokeinterface #188,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     165: astore        13
     167: aload         10
     169: aload         13
     171: checkcast     #190                // class kotlin/Pair
     174: astore        14
     176: astore        15
     178: iconst_0
     179: istore        16
     181: aload         14
     183: invokevirtual #193                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     186: checkcast     #108                // class java/lang/String
     189: astore        17
     191: aload         14
     193: invokevirtual #196                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     196: checkcast     #126                // class java/util/concurrent/TimeUnit
     199: astore        18
     201: aload         18
     203: aload         17
     205: invokestatic  #202                // Method kotlin/text/StringsKt.toLongOrNull:(Ljava/lang/String;)Ljava/lang/Long;
     208: dup
     209: ifnull        218
     212: invokevirtual #208                // Method java/lang/Long.longValue:()J
     215: goto          220
     218: pop
     219: lconst_0
     220: invokevirtual #212                // Method java/util/concurrent/TimeUnit.toNanos:(J)J
     223: invokestatic  #216                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     226: aload         15
     228: swap
     229: invokeinterface #220,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     234: pop
     235: goto          148
     238: aload         10
     240: checkcast     #44                 // class java/util/List
     243: nop
     244: checkcast     #60                 // class java/lang/Iterable
     247: invokestatic  #224                // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     250: aload         4
     252: invokeinterface #150,  1          // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     257: invokestatic  #228                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     260: checkcast     #108                // class java/lang/String
     263: bipush        9
     265: bipush        48
     267: invokestatic  #232                // Method kotlin/text/StringsKt.padEnd:(Ljava/lang/String;IC)Ljava/lang/String;
     270: invokestatic  #236                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     273: ladd
     274: lstore        19
     276: lload         19
     278: iload         6
     280: ifeq          287
     283: iconst_m1
     284: goto          288
     287: iconst_1
     288: i2l
     289: lmul
     290: invokestatic  #240                // Method java/time/Duration.ofNanos:(J)Ljava/time/Duration;
     293: goto          298
     296: pop
     297: aconst_null
     298: areturn

  public static final java.time.Duration toSecondsDuration(double, java.time.Duration);
    Code:
       0: dload_0
       1: dconst_0
       2: dcmpl
       3: iflt          10
       6: iconst_1
       7: goto          11
      10: iconst_0
      11: ifne          25
      14: new           #269                // class java/lang/IllegalStateException
      17: dup
      18: ldc_w         #271                // String Check failed.
      21: invokespecial #272                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      24: athrow
      25: dload_0
      26: dconst_0
      27: dcmpg
      28: ifne          35
      31: iconst_1
      32: goto          36
      35: iconst_0
      36: ifeq          43
      39: aload_2
      40: goto          62
      43: dload_0
      44: d2l
      45: dload_0
      46: iconst_1
      47: i2d
      48: drem
      49: ldc_w         #273                // int 1000000000
      52: i2d
      53: dmul
      54: d2l
      55: invokestatic  #277                // Method java/time/Duration.ofSeconds:(JJ)Ljava/time/Duration;
      58: dup
      59: invokestatic  #281                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      62: areturn

  public static java.time.Duration toSecondsDuration$default(double, java.time.Duration, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          8
       6: aconst_null
       7: astore_2
       8: dload_0
       9: aload_2
      10: invokestatic  #288                // Method toSecondsDuration:(DLjava/time/Duration;)Ljava/time/Duration;
      13: areturn

  public static final java.time.Duration toSecondsDuration(java.math.BigDecimal);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: bipush        9
       9: invokevirtual #295                // Method java/math/BigDecimal.setScale:(I)Ljava/math/BigDecimal;
      12: invokevirtual #299                // Method java/math/BigDecimal.unscaledValue:()Ljava/math/BigInteger;
      15: invokevirtual #304                // Method java/math/BigInteger.longValueExact:()J
      18: invokestatic  #240                // Method java/time/Duration.ofNanos:(J)Ljava/time/Duration;
      21: dup
      22: invokestatic  #281                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      25: areturn

  public static final java.lang.String toTotalSeconds(java.time.Duration);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #308                // Method java/time/Duration.toNanos:()J
      10: bipush        9
      12: invokestatic  #311                // Method java/math/BigDecimal.valueOf:(JI)Ljava/math/BigDecimal;
      15: invokevirtual #314                // Method java/math/BigDecimal.toPlainString:()Ljava/lang/String;
      18: dup
      19: ldc_w         #316                // String toPlainString(...)
      22: invokestatic  #319                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      25: areturn

  public static final java.time.Duration sum(java.lang.Iterable<java.time.Duration>);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: getstatic     #326                // Field java/time/Duration.ZERO:Ljava/time/Duration;
      11: astore_2
      12: iconst_0
      13: istore_3
      14: aload_2
      15: astore        4
      17: aload_1
      18: invokeinterface #179,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      23: astore        5
      25: aload         5
      27: invokeinterface #184,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          70
      35: aload         5
      37: invokeinterface #188,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        6
      44: aload         4
      46: aload         6
      48: checkcast     #17                 // class java/time/Duration
      51: astore        7
      53: astore        8
      55: iconst_0
      56: istore        9
      58: aload         8
      60: aload         7
      62: invokevirtual #330                // Method java/time/Duration.plus:(Ljava/time/Duration;)Ljava/time/Duration;
      65: astore        4
      67: goto          25
      70: aload         4
      72: dup
      73: ldc_w         #332                // String fold(...)
      76: invokestatic  #319                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      79: areturn

  private static final void toTimeString$lambda$0$add(java.util.List<java.lang.String>, int);
    Code:
       0: aload_0
       1: iload_1
       2: invokestatic  #345                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
       5: iconst_2
       6: bipush        48
       8: invokestatic  #348                // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;
      11: invokeinterface #349,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      16: pop
      17: return

  private static final void toTimeString$lambda$2$add$1(kotlin.jvm.internal.Ref$BooleanRef, java.util.List<java.lang.String>, int);
    Code:
       0: aload_0
       1: getfield      #355                // Field kotlin/jvm/internal/Ref$BooleanRef.element:Z
       4: ifne          11
       7: iload_2
       8: ifle          33
      11: aload_1
      12: iload_2
      13: invokestatic  #345                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
      16: iconst_3
      17: bipush        48
      19: invokestatic  #348                // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;
      22: invokeinterface #349,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      27: pop
      28: aload_0
      29: iconst_1
      30: putfield      #355                // Field kotlin/jvm/internal/Ref$BooleanRef.element:Z
      33: return
}