package com.lukaslechner.coroutineusecasesonandroid.playground.challenges

//Have the function StringChallenge(str) take the str parameter being passed and determine if it is possible to create a palindromic string of minimum length 3 characters by removing 1 or 2 characters
//For example: if str is "abjchba" then you can remove the characters jc to produce "abhba" which is a palindrome.
//For this example your program should return the two characters that were removed with no delimiter and in the order they appear in the string, so jc.
//If 1 or 2 characters cannot be removed to produce a palindrome, then return the string not possible.
//If the input string is already a palindrome, your program should return the string palindrome.
//The input will only contain lowercase alphabetic characters.
//Your program should always attempt to create the longest palindromic substring by removing 1 or 2 characters
// (see second sample test case as an example).
//The 2 characters you remove do not have to be adjacent in the string.
//Examples
//Input: "mmop"
//Output: not possible
//Input: "kjjjhjjj"
//Output: k

private fun stringChallenge(str: String): String {
    if (str == str.reversed()) return "palindrome"
    //min length 3 characters
    if (str.length < 3) return "not possible"

    str.indices.forEachIndexed { index, _ ->
        //remove 1 character
        val newStr = str.removeRange(index, index + 1)
        //min length 3 characters
        if (newStr.length < 3) return "not possible"
        if (newStr == newStr.reversed()) return str[index].toString()
        //remove 2 characters
    }

    //remove 2 characters (not adjacent)
    str.indices.forEachIndexed { index, _ ->
        val newStr = str.removeRange(index, index + 2)
        if (newStr.length < 3) return "not possible"
        if (newStr == newStr.reversed()) return str[index].toString() + str[index + 1].toString()
    }

    //If any of the above conditions are not met, return "not possible"
    return "not possible"
}

//test StringChallenge

fun main () {
    println(stringChallenge("abh"))
    println(stringChallenge("abhba"))
    println(stringChallenge("mmop"))
    println(stringChallenge("kjjjhjjj"))
    println(stringChallenge("abjchba"))
}

Compiled from "PalindromicNew.kt"
public final class com.lukaslechner.coroutineusecasesonandroid.playground.challenges.PalindromicNewKt {
  private static final java.lang.String stringChallenge(java.lang.String);
    Code:
       0: aload_0
       1: aload_0
       2: checkcast     #8                  // class java/lang/CharSequence
       5: invokestatic  #14                 // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
       8: invokevirtual #18                 // Method java/lang/Object.toString:()Ljava/lang/String;
      11: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      14: ifeq          20
      17: ldc           #26                 // String palindrome
      19: areturn
      20: aload_0
      21: invokevirtual #32                 // Method java/lang/String.length:()I
      24: iconst_3
      25: if_icmpge     31
      28: ldc           #34                 // String not possible
      30: areturn
      31: aload_0
      32: checkcast     #8                  // class java/lang/CharSequence
      35: invokestatic  #38                 // Method kotlin/text/StringsKt.getIndices:(Ljava/lang/CharSequence;)Lkotlin/ranges/IntRange;
      38: checkcast     #40                 // class java/lang/Iterable
      41: astore_1
      42: iconst_0
      43: istore_2
      44: iconst_0
      45: istore_3
      46: aload_1
      47: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      52: astore        4
      54: aload         4
      56: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      61: ifeq          167
      64: aload         4
      66: checkcast     #52                 // class kotlin/collections/IntIterator
      69: invokevirtual #55                 // Method kotlin/collections/IntIterator.nextInt:()I
      72: istore        5
      74: iload_3
      75: iinc          3, 1
      78: istore        6
      80: iload         6
      82: ifge          88
      85: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      88: iload         6
      90: istore        7
      92: iconst_0
      93: istore        8
      95: aload_0
      96: astore        9
      98: iload         7
     100: iconst_1
     101: iadd
     102: istore        10
     104: aload         9
     106: checkcast     #8                  // class java/lang/CharSequence
     109: iload         7
     111: iload         10
     113: invokestatic  #65                 // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;
     116: invokevirtual #18                 // Method java/lang/Object.toString:()Ljava/lang/String;
     119: astore        11
     121: aload         11
     123: invokevirtual #32                 // Method java/lang/String.length:()I
     126: iconst_3
     127: if_icmpge     133
     130: ldc           #34                 // String not possible
     132: areturn
     133: aload         11
     135: aload         11
     137: checkcast     #8                  // class java/lang/CharSequence
     140: invokestatic  #14                 // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     143: invokevirtual #18                 // Method java/lang/Object.toString:()Ljava/lang/String;
     146: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     149: ifeq          162
     152: aload_0
     153: iload         7
     155: invokevirtual #69                 // Method java/lang/String.charAt:(I)C
     158: invokestatic  #73                 // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     161: areturn
     162: nop
     163: nop
     164: goto          54
     167: nop
     168: aload_0
     169: checkcast     #8                  // class java/lang/CharSequence
     172: invokestatic  #38                 // Method kotlin/text/StringsKt.getIndices:(Ljava/lang/CharSequence;)Lkotlin/ranges/IntRange;
     175: checkcast     #40                 // class java/lang/Iterable
     178: astore_1
     179: iconst_0
     180: istore_2
     181: iconst_0
     182: istore_3
     183: aload_1
     184: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     189: astore        4
     191: aload         4
     193: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     198: ifeq          325
     201: aload         4
     203: checkcast     #52                 // class kotlin/collections/IntIterator
     206: invokevirtual #55                 // Method kotlin/collections/IntIterator.nextInt:()I
     209: istore        5
     211: iload_3
     212: iinc          3, 1
     215: istore        6
     217: iload         6
     219: ifge          225
     222: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     225: iload         6
     227: istore        7
     229: iconst_0
     230: istore        8
     232: aload_0
     233: astore        9
     235: iload         7
     237: iconst_2
     238: iadd
     239: istore        10
     241: aload         9
     243: checkcast     #8                  // class java/lang/CharSequence
     246: iload         7
     248: iload         10
     250: invokestatic  #65                 // Method kotlin/text/StringsKt.removeRange:(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;
     253: invokevirtual #18                 // Method java/lang/Object.toString:()Ljava/lang/String;
     256: astore        11
     258: aload         11
     260: invokevirtual #32                 // Method java/lang/String.length:()I
     263: iconst_3
     264: if_icmpge     270
     267: ldc           #34                 // String not possible
     269: areturn
     270: aload         11
     272: aload         11
     274: checkcast     #8                  // class java/lang/CharSequence
     277: invokestatic  #14                 // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
     280: invokevirtual #18                 // Method java/lang/Object.toString:()Ljava/lang/String;
     283: invokestatic  #24                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     286: ifeq          320
     289: new           #75                 // class java/lang/StringBuilder
     292: dup
     293: invokespecial #78                 // Method java/lang/StringBuilder."<init>":()V
     296: aload_0
     297: iload         7
     299: invokevirtual #69                 // Method java/lang/String.charAt:(I)C
     302: invokevirtual #82                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     305: aload_0
     306: iload         7
     308: iconst_1
     309: iadd
     310: invokevirtual #69                 // Method java/lang/String.charAt:(I)C
     313: invokevirtual #82                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     316: invokevirtual #83                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     319: areturn
     320: nop
     321: nop
     322: goto          191
     325: nop
     326: ldc           #34                 // String not possible
     328: areturn

  public static final void main();
    Code:
       0: ldc           #98                 // String abh
       2: invokestatic  #100                // Method stringChallenge:(Ljava/lang/String;)Ljava/lang/String;
       5: getstatic     #106                // Field java/lang/System.out:Ljava/io/PrintStream;
       8: swap
       9: invokevirtual #112                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      12: ldc           #114                // String abhba
      14: invokestatic  #100                // Method stringChallenge:(Ljava/lang/String;)Ljava/lang/String;
      17: getstatic     #106                // Field java/lang/System.out:Ljava/io/PrintStream;
      20: swap
      21: invokevirtual #112                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      24: ldc           #116                // String mmop
      26: invokestatic  #100                // Method stringChallenge:(Ljava/lang/String;)Ljava/lang/String;
      29: getstatic     #106                // Field java/lang/System.out:Ljava/io/PrintStream;
      32: swap
      33: invokevirtual #112                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      36: ldc           #118                // String kjjjhjjj
      38: invokestatic  #100                // Method stringChallenge:(Ljava/lang/String;)Ljava/lang/String;
      41: getstatic     #106                // Field java/lang/System.out:Ljava/io/PrintStream;
      44: swap
      45: invokevirtual #112                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      48: ldc           #120                // String abjchba
      50: invokestatic  #100                // Method stringChallenge:(Ljava/lang/String;)Ljava/lang/String;
      53: getstatic     #106                // Field java/lang/System.out:Ljava/io/PrintStream;
      56: swap
      57: invokevirtual #112                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      60: return

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


package com.lukaslechner.coroutineusecasesonandroid.playground.challenges

//find the longest substring that contains k unique characters
//The input string str must have at least length 2.
//The first character of str must be a digit between 1 and 6 (inclusive), representing the number of unique characters in the longest substring to be found.
//The remaining characters of str must be printable ASCII characters (i.e., characters with ASCII codes between 32 and 126, inclusive).
//The function should return the longest substring of str that contains exactly k unique characters, where k is the digit extracted from the first character of str.
//If there are multiple longest substrings that satisfy the above condition, the function should return the first one.
fun SearchingChallenge(str: String): String {
    //The input string str must have at least length 2.
    if(str.length < 2) return "not possible"

    //get the number of unique characters handle exception use elvis operator
    val k = str[0].toString().toIntOrNull() ?: return "not possible"

    if(k !in 1..6) return "not possible"

    //Remove the first character from the string
    val substring = str.substring(1)

    //get the longest substring that contains k unique characters
    val longestSubstring = getLongestSubstring(substring, k)
    return if(longestSubstring.isEmpty()) "not possible" else longestSubstring
}

fun getLongestSubstring(substring: String, k: Int): String {
    //get the list of all substrings
    val substrings = mutableListOf<String>()
    for (i in substring.indices) {
        for (j in i + 1..substring.length) {
            substrings.add(substring.substring(i, j))
        }
    }

    //get the list of all substring that contains k unique characters
    val substringsWithKUniqueChars = mutableListOf<String>()
    substrings.forEach {
        if(it.toSet().size == k) substringsWithKUniqueChars.add(it)
    }

    //get the longest substring that contains k unique characters avoid use maxByOrNull
    var longestSubstring = ""
    substringsWithKUniqueChars.forEach {
        if(it.length > longestSubstring.length) longestSubstring = it
    }

    return longestSubstring
}

fun main() {
    println(SearchingChallenge("3aabacbebebe")) //cbebebe
    println(SearchingChallenge("2aabbcbbbadef")) //bbcbbb
    println(SearchingChallenge("2aabbacbaa")) //aabba
}

Compiled from "SearchingChallenge.kt"
public final class com.lukaslechner.coroutineusecasesonandroid.playground.challenges.SearchingChallengeKt {
  public static final java.lang.String SearchingChallenge(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #9                  // String str
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #21                 // Method java/lang/String.length:()I
      10: iconst_2
      11: if_icmpge     17
      14: ldc           #23                 // String not possible
      16: areturn
      17: aload_0
      18: iconst_0
      19: invokevirtual #27                 // Method java/lang/String.charAt:(I)C
      22: invokestatic  #31                 // Method java/lang/String.valueOf:(C)Ljava/lang/String;
      25: invokestatic  #37                 // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;
      28: dup
      29: ifnull        38
      32: invokevirtual #42                 // Method java/lang/Integer.intValue:()I
      35: goto          42
      38: pop
      39: ldc           #23                 // String not possible
      41: areturn
      42: istore_1
      43: iconst_1
      44: iload_1
      45: if_icmpgt     62
      48: iload_1
      49: bipush        7
      51: if_icmpge     58
      54: iconst_1
      55: goto          63
      58: iconst_0
      59: goto          63
      62: iconst_0
      63: ifne          69
      66: ldc           #23                 // String not possible
      68: areturn
      69: aload_0
      70: iconst_1
      71: invokevirtual #46                 // Method java/lang/String.substring:(I)Ljava/lang/String;
      74: dup
      75: ldc           #48                 // String substring(...)
      77: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      80: astore_2
      81: aload_2
      82: iload_1
      83: invokestatic  #55                 // Method getLongestSubstring:(Ljava/lang/String;I)Ljava/lang/String;
      86: astore_3
      87: aload_3
      88: checkcast     #57                 // class java/lang/CharSequence
      91: invokeinterface #58,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      96: ifne          103
      99: iconst_1
     100: goto          104
     103: iconst_0
     104: ifeq          112
     107: ldc           #23                 // String not possible
     109: goto          113
     112: aload_3
     113: areturn

  public static final java.lang.String getLongestSubstring(java.lang.String, int);
    Code:
       0: aload_0
       1: ldc           #63                 // String substring
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #65                 // class java/util/ArrayList
       9: dup
      10: invokespecial #69                 // Method java/util/ArrayList."<init>":()V
      13: checkcast     #71                 // class java/util/List
      16: astore_2
      17: iconst_0
      18: istore_3
      19: aload_0
      20: checkcast     #57                 // class java/lang/CharSequence
      23: invokeinterface #58,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      28: istore        4
      30: iload_3
      31: iload         4
      33: if_icmpge     93
      36: iload_3
      37: iconst_1
      38: iadd
      39: istore        5
      41: aload_0
      42: invokevirtual #21                 // Method java/lang/String.length:()I
      45: istore        6
      47: iload         5
      49: iload         6
      51: if_icmpgt     87
      54: aload_2
      55: aload_0
      56: iload_3
      57: iload         5
      59: invokevirtual #74                 // Method java/lang/String.substring:(II)Ljava/lang/String;
      62: dup
      63: ldc           #48                 // String substring(...)
      65: invokestatic  #51                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      68: invokeinterface #78,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      73: pop
      74: iload         5
      76: iload         6
      78: if_icmpeq     87
      81: iinc          5, 1
      84: goto          54
      87: iinc          3, 1
      90: goto          30
      93: new           #65                 // class java/util/ArrayList
      96: dup
      97: invokespecial #69                 // Method java/util/ArrayList."<init>":()V
     100: checkcast     #71                 // class java/util/List
     103: astore_3
     104: aload_2
     105: checkcast     #80                 // class java/lang/Iterable
     108: astore        4
     110: iconst_0
     111: istore        5
     113: aload         4
     115: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     120: astore        6
     122: aload         6
     124: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     129: ifeq          182
     132: aload         6
     134: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     139: astore        7
     141: aload         7
     143: checkcast     #17                 // class java/lang/String
     146: astore        8
     148: iconst_0
     149: istore        9
     151: aload         8
     153: checkcast     #57                 // class java/lang/CharSequence
     156: invokestatic  #98                 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;
     159: invokeinterface #103,  1          // InterfaceMethod java/util/Set.size:()I
     164: iload_1
     165: if_icmpne     177
     168: aload_3
     169: aload         8
     171: invokeinterface #78,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     176: pop
     177: nop
     178: nop
     179: goto          122
     182: nop
     183: aconst_null
     184: astore        4
     186: ldc           #105                // String
     188: astore        4
     190: aload_3
     191: checkcast     #80                 // class java/lang/Iterable
     194: astore        5
     196: iconst_0
     197: istore        6
     199: aload         5
     201: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     206: astore        7
     208: aload         7
     210: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     215: ifeq          259
     218: aload         7
     220: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     225: astore        8
     227: aload         8
     229: checkcast     #17                 // class java/lang/String
     232: astore        9
     234: iconst_0
     235: istore        10
     237: aload         9
     239: invokevirtual #21                 // Method java/lang/String.length:()I
     242: aload         4
     244: invokevirtual #21                 // Method java/lang/String.length:()I
     247: if_icmple     254
     250: aload         9
     252: astore        4
     254: nop
     255: nop
     256: goto          208
     259: nop
     260: aload         4
     262: areturn

  public static final void main();
    Code:
       0: ldc           #121                // String 3aabacbebebe
       2: invokestatic  #123                // Method SearchingChallenge:(Ljava/lang/String;)Ljava/lang/String;
       5: getstatic     #129                // Field java/lang/System.out:Ljava/io/PrintStream;
       8: swap
       9: invokevirtual #135                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      12: ldc           #137                // String 2aabbcbbbadef
      14: invokestatic  #123                // Method SearchingChallenge:(Ljava/lang/String;)Ljava/lang/String;
      17: getstatic     #129                // Field java/lang/System.out:Ljava/io/PrintStream;
      20: swap
      21: invokevirtual #135                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      24: ldc           #139                // String 2aabbacbaa
      26: invokestatic  #123                // Method SearchingChallenge:(Ljava/lang/String;)Ljava/lang/String;
      29: getstatic     #129                // Field java/lang/System.out:Ljava/io/PrintStream;
      32: swap
      33: invokevirtual #135                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      36: return

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


package com.lukaslechner.coroutineusecasesonandroid.playground.challenges

// Challenge
// Have the function MathChallenge(str) take the str parameter, which will be a simple mathematical formula with three numbers, a single operator (+, -, *, or /) and an equal sign (=) and return the digit that completes the equation. In one of the numbers in the equation, there will be an x character, and your program should determine what digit is missing. For example, if str is "3x + 12 = 46" then your program should output 4. The x character can appear in any of the three numbers and all three numbers will be greater than or equal to 0 and less than or equal to 1000000.
// Examples
// Input: "4 - 2 = x"
// Output: 2
// Input: "1x0 * 12 = 1200"
// Output: 0
// Input: "3x + 12 = 46"
// Output: 4
//Constrainst
//1. The x character can appear in any of the three numbers -> has x in it
//2. all three numbers will be greater than or equal to 0 and less than or equal to 1000000.

//Identify the missing number
private fun MathChallenge(str: String): String {
    //validate constraints 1 -> has x in it
    if (!str.contains("x")) return "not possible"

    //validate constraints 2 -> all three numbers will be greater than or equal to 0 and less than or equal to 1000000.
    val numbersSplit = str.split(" ")
    //remove operators and equal sign
    val numbersOnlyValid = numbersSplit.filter { it != "+" && it != "-" && it != "*" && it != "/" && it != "=" }
    //convert to int
    val numbersOnlyIntegers = numbersOnlyValid.map {
        //if it contains x, replace it with 1
        if (it.contains("x")) 1 else it.toInt()
    }
    //check if all numbers are between 0 and 1000000
    numbersOnlyIntegers.forEach {
        if (it < 0 || it > 1000000) return "not possible"
    }

    for(digit in 0..9){
        val newStr = str.replace("x", digit.toString())
        val numbers = newStr.split(" ")
        val numbersOnly = numbers.filter { it != "+" && it != "-" && it != "*" && it != "/" && it != "=" }
        val numbersOnlyInt = numbersOnly.map {
            //if it contains x, replace it with 1
            if (it.contains("x")) 1 else it.toInt()
        }
        val firstNumber = numbersOnlyInt[0]
        val secondNumber = numbersOnlyInt[1]
        val thirdNumber = numbersOnlyInt[2]
        val operator = numbers[1]

        //check if the equation is correct
        if (operator == "+") {
            if (firstNumber + secondNumber == thirdNumber) return digit.toString()
        }
        if (operator == "-") {
            if (firstNumber - secondNumber == thirdNumber) return digit.toString()
        }
        if (operator == "*") {
            if (firstNumber * secondNumber == thirdNumber) return digit.toString()
        }
        if (operator == "/") {
            if (firstNumber / secondNumber == thirdNumber) return digit.toString()
        }
    }

    //if no digit is found
    return "not possible"
}

fun main () {
    println(MathChallenge("4 - 2 = x"))
    println(MathChallenge("1x0 * 12 = 1200"))
    println(MathChallenge("3x + 12 = 46"))
}

Compiled from "MathChallenge.kt"
public final class com.lukaslechner.coroutineusecasesonandroid.playground.challenges.MathChallengeKt {
  private static final java.lang.String MathChallenge(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #8                  // class java/lang/CharSequence
       4: ldc           #10                 // String x
       6: checkcast     #8                  // class java/lang/CharSequence
       9: iconst_0
      10: iconst_2
      11: aconst_null
      12: invokestatic  #16                 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
      15: ifne          21
      18: ldc           #18                 // String not possible
      20: areturn
      21: aload_0
      22: checkcast     #8                  // class java/lang/CharSequence
      25: iconst_1
      26: anewarray     #20                 // class java/lang/String
      29: astore_2
      30: aload_2
      31: iconst_0
      32: ldc           #22                 // String
      34: aastore
      35: aload_2
      36: iconst_0
      37: iconst_0
      38: bipush        6
      40: aconst_null
      41: invokestatic  #26                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      44: astore_1
      45: aload_1
      46: checkcast     #28                 // class java/lang/Iterable
      49: astore_3
      50: iconst_0
      51: istore        4
      53: aload_3
      54: astore        5
      56: new           #30                 // class java/util/ArrayList
      59: dup
      60: invokespecial #34                 // Method java/util/ArrayList."<init>":()V
      63: checkcast     #36                 // class java/util/Collection
      66: astore        6
      68: iconst_0
      69: istore        7
      71: aload         5
      73: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      78: astore        8
      80: aload         8
      82: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      87: ifeq          180
      90: aload         8
      92: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      97: astore        9
      99: aload         9
     101: checkcast     #20                 // class java/lang/String
     104: astore        10
     106: iconst_0
     107: istore        11
     109: aload         10
     111: ldc           #52                 // String +
     113: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     116: ifne          163
     119: aload         10
     121: ldc           #60                 // String -
     123: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     126: ifne          163
     129: aload         10
     131: ldc           #62                 // String *
     133: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     136: ifne          163
     139: aload         10
     141: ldc           #64                 // String /
     143: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     146: ifne          163
     149: aload         10
     151: ldc           #66                 // String =
     153: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     156: ifne          163
     159: iconst_1
     160: goto          164
     163: iconst_0
     164: ifeq          80
     167: aload         6
     169: aload         9
     171: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     176: pop
     177: goto          80
     180: aload         6
     182: checkcast     #72                 // class java/util/List
     185: nop
     186: astore_2
     187: aload_2
     188: checkcast     #28                 // class java/lang/Iterable
     191: astore        4
     193: iconst_0
     194: istore        5
     196: aload         4
     198: astore        6
     200: new           #30                 // class java/util/ArrayList
     203: dup
     204: aload         4
     206: bipush        10
     208: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     211: invokespecial #81                 // Method java/util/ArrayList."<init>":(I)V
     214: checkcast     #36                 // class java/util/Collection
     217: astore        7
     219: iconst_0
     220: istore        8
     222: aload         6
     224: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     229: astore        9
     231: aload         9
     233: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     238: ifeq          308
     241: aload         9
     243: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     248: astore        10
     250: aload         7
     252: aload         10
     254: checkcast     #20                 // class java/lang/String
     257: astore        11
     259: astore        18
     261: iconst_0
     262: istore        12
     264: aload         11
     266: checkcast     #8                  // class java/lang/CharSequence
     269: ldc           #10                 // String x
     271: checkcast     #8                  // class java/lang/CharSequence
     274: iconst_0
     275: iconst_2
     276: aconst_null
     277: invokestatic  #16                 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
     280: ifeq          287
     283: iconst_1
     284: goto          292
     287: aload         11
     289: invokestatic  #87                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     292: nop
     293: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     296: aload         18
     298: swap
     299: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     304: pop
     305: goto          231
     308: aload         7
     310: checkcast     #72                 // class java/util/List
     313: nop
     314: astore_3
     315: aload_3
     316: checkcast     #28                 // class java/lang/Iterable
     319: astore        4
     321: iconst_0
     322: istore        5
     324: aload         4
     326: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     331: astore        6
     333: aload         6
     335: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     340: ifeq          385
     343: aload         6
     345: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     350: astore        7
     352: aload         7
     354: checkcast     #93                 // class java/lang/Number
     357: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     360: istore        8
     362: iconst_0
     363: istore        9
     365: iload         8
     367: iflt          377
     370: iload         8
     372: ldc           #98                 // int 1000000
     374: if_icmple     380
     377: ldc           #18                 // String not possible
     379: areturn
     380: nop
     381: nop
     382: goto          333
     385: nop
     386: iconst_0
     387: istore        4
     389: iload         4
     391: bipush        10
     393: if_icmpge     888
     396: aload_0
     397: ldc           #10                 // String x
     399: iload         4
     401: invokestatic  #101                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     404: iconst_0
     405: iconst_4
     406: aconst_null
     407: invokestatic  #105                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     410: astore        5
     412: aload         5
     414: checkcast     #8                  // class java/lang/CharSequence
     417: iconst_1
     418: anewarray     #20                 // class java/lang/String
     421: astore        7
     423: aload         7
     425: iconst_0
     426: ldc           #22                 // String
     428: aastore
     429: aload         7
     431: iconst_0
     432: iconst_0
     433: bipush        6
     435: aconst_null
     436: invokestatic  #26                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     439: astore        6
     441: aload         6
     443: checkcast     #28                 // class java/lang/Iterable
     446: astore        8
     448: iconst_0
     449: istore        9
     451: aload         8
     453: astore        10
     455: new           #30                 // class java/util/ArrayList
     458: dup
     459: invokespecial #34                 // Method java/util/ArrayList."<init>":()V
     462: checkcast     #36                 // class java/util/Collection
     465: astore        11
     467: iconst_0
     468: istore        12
     470: aload         10
     472: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     477: astore        13
     479: aload         13
     481: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     486: ifeq          579
     489: aload         13
     491: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     496: astore        14
     498: aload         14
     500: checkcast     #20                 // class java/lang/String
     503: astore        15
     505: iconst_0
     506: istore        16
     508: aload         15
     510: ldc           #52                 // String +
     512: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     515: ifne          562
     518: aload         15
     520: ldc           #60                 // String -
     522: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     525: ifne          562
     528: aload         15
     530: ldc           #62                 // String *
     532: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     535: ifne          562
     538: aload         15
     540: ldc           #64                 // String /
     542: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     545: ifne          562
     548: aload         15
     550: ldc           #66                 // String =
     552: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     555: ifne          562
     558: iconst_1
     559: goto          563
     562: iconst_0
     563: ifeq          479
     566: aload         11
     568: aload         14
     570: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     575: pop
     576: goto          479
     579: aload         11
     581: checkcast     #72                 // class java/util/List
     584: nop
     585: astore        7
     587: aload         7
     589: checkcast     #28                 // class java/lang/Iterable
     592: astore        9
     594: iconst_0
     595: istore        10
     597: aload         9
     599: astore        11
     601: new           #30                 // class java/util/ArrayList
     604: dup
     605: aload         9
     607: bipush        10
     609: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     612: invokespecial #81                 // Method java/util/ArrayList."<init>":(I)V
     615: checkcast     #36                 // class java/util/Collection
     618: astore        12
     620: iconst_0
     621: istore        13
     623: aload         11
     625: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     630: astore        14
     632: aload         14
     634: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     639: ifeq          709
     642: aload         14
     644: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     649: astore        15
     651: aload         12
     653: aload         15
     655: checkcast     #20                 // class java/lang/String
     658: astore        16
     660: astore        18
     662: iconst_0
     663: istore        17
     665: aload         16
     667: checkcast     #8                  // class java/lang/CharSequence
     670: ldc           #10                 // String x
     672: checkcast     #8                  // class java/lang/CharSequence
     675: iconst_0
     676: iconst_2
     677: aconst_null
     678: invokestatic  #16                 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
     681: ifeq          688
     684: iconst_1
     685: goto          693
     688: aload         16
     690: invokestatic  #87                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     693: nop
     694: invokestatic  #91                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     697: aload         18
     699: swap
     700: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     705: pop
     706: goto          632
     709: aload         12
     711: checkcast     #72                 // class java/util/List
     714: nop
     715: astore        8
     717: aload         8
     719: iconst_0
     720: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     725: checkcast     #93                 // class java/lang/Number
     728: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     731: istore        9
     733: aload         8
     735: iconst_1
     736: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     741: checkcast     #93                 // class java/lang/Number
     744: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     747: istore        10
     749: aload         8
     751: iconst_2
     752: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     757: checkcast     #93                 // class java/lang/Number
     760: invokevirtual #97                 // Method java/lang/Number.intValue:()I
     763: istore        11
     765: aload         6
     767: iconst_1
     768: invokeinterface #109,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     773: checkcast     #20                 // class java/lang/String
     776: astore        12
     778: aload         12
     780: ldc           #52                 // String +
     782: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     785: ifeq          804
     788: iload         9
     790: iload         10
     792: iadd
     793: iload         11
     795: if_icmpne     804
     798: iload         4
     800: invokestatic  #101                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     803: areturn
     804: aload         12
     806: ldc           #60                 // String -
     808: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     811: ifeq          830
     814: iload         9
     816: iload         10
     818: isub
     819: iload         11
     821: if_icmpne     830
     824: iload         4
     826: invokestatic  #101                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     829: areturn
     830: aload         12
     832: ldc           #62                 // String *
     834: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     837: ifeq          856
     840: iload         9
     842: iload         10
     844: imul
     845: iload         11
     847: if_icmpne     856
     850: iload         4
     852: invokestatic  #101                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     855: areturn
     856: aload         12
     858: ldc           #64                 // String /
     860: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     863: ifeq          882
     866: iload         9
     868: iload         10
     870: idiv
     871: iload         11
     873: if_icmpne     882
     876: iload         4
     878: invokestatic  #101                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     881: areturn
     882: iinc          4, 1
     885: goto          389
     888: ldc           #18                 // String not possible
     890: areturn

  public static final void main();
    Code:
       0: ldc           #153                // String 4 - 2 = x
       2: invokestatic  #155                // Method MathChallenge:(Ljava/lang/String;)Ljava/lang/String;
       5: getstatic     #161                // Field java/lang/System.out:Ljava/io/PrintStream;
       8: swap
       9: invokevirtual #167                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      12: ldc           #169                // String 1x0 * 12 = 1200
      14: invokestatic  #155                // Method MathChallenge:(Ljava/lang/String;)Ljava/lang/String;
      17: getstatic     #161                // Field java/lang/System.out:Ljava/io/PrintStream;
      20: swap
      21: invokevirtual #167                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      24: ldc           #171                // String 3x + 12 = 46
      26: invokestatic  #155                // Method MathChallenge:(Ljava/lang/String;)Ljava/lang/String;
      29: getstatic     #161                // Field java/lang/System.out:Ljava/io/PrintStream;
      32: swap
      33: invokevirtual #167                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      36: return

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


package day2

import java.io.File

fun main() {
   val input = File(object {}.javaClass.getResource("/day2/input.txt").toURI()).readLines()
   println("char count: ${matchingNrOfChars(input)}")
   println("char position: ${matchingPosition(input)}")
}

fun matchingNrOfChars(lines: List<String>) = prepare(lines)
   .map { (ruleAsString, password) -> Pair(charCountRule(ruleAsString), password) }
   .count { (rule, password) -> rule(password) }

fun matchingPosition(lines: List<String>) = prepare(lines)
   .map { (ruleAsString, password) -> Pair(charPositionRule(ruleAsString), password) }
   .count { (rule, password) -> rule(password) }

private fun charCountRule(asText: String): (String) -> Boolean =
   asText.split(" ").let { (charCounts, character) ->
      val (min, max) = charCounts.split("-").map { it.toInt() }
      val range = IntRange(min, max)
      val char = character.first()
      return { password ->  password.filter { it == char }.count() in range }
   }

private fun charPositionRule(asText: String): (String) -> Boolean =
   asText.split(" ").let { (positions, character) ->
      val (firstPos, secondPos) = positions.split("-").map { it.toInt() }
      val char = character.first()
      return { password ->
         password.withIndex().count {
            indexMatches(it.index, firstPos, secondPos) && it.value == char
         } == 1
      }
   }

private fun prepare(input: List<String>) =
   input.filter { it.isNotEmpty() }.map { it.split(": ") }

private fun indexMatches(actualIndex: Int, vararg desiredIndices: Int) =
   actualIndex + 1 in desiredIndices

Compiled from "Day2.kt"
public final class day2.Day2Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: new           #10                 // class day2/Day2Kt$main$input$1
       7: dup
       8: invokespecial #13                 // Method day2/Day2Kt$main$input$1."<init>":()V
      11: invokevirtual #17                 // Method java/lang/Object.getClass:()Ljava/lang/Class;
      14: ldc           #19                 // String /day2/input.txt
      16: invokevirtual #25                 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;
      19: invokevirtual #31                 // Method java/net/URL.toURI:()Ljava/net/URI;
      22: invokespecial #34                 // Method java/io/File."<init>":(Ljava/net/URI;)V
      25: aconst_null
      26: iconst_1
      27: aconst_null
      28: invokestatic  #40                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      31: astore_0
      32: new           #42                 // class java/lang/StringBuilder
      35: dup
      36: invokespecial #43                 // Method java/lang/StringBuilder."<init>":()V
      39: ldc           #45                 // String char count:
      41: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      44: aload_0
      45: invokestatic  #53                 // Method matchingNrOfChars:(Ljava/util/List;)I
      48: invokevirtual #56                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      51: invokevirtual #60                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      54: getstatic     #66                 // Field java/lang/System.out:Ljava/io/PrintStream;
      57: swap
      58: invokevirtual #72                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      61: new           #42                 // class java/lang/StringBuilder
      64: dup
      65: invokespecial #43                 // Method java/lang/StringBuilder."<init>":()V
      68: ldc           #74                 // String char position:
      70: invokevirtual #49                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      73: aload_0
      74: invokestatic  #77                 // Method matchingPosition:(Ljava/util/List;)I
      77: invokevirtual #56                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      80: invokevirtual #60                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      83: getstatic     #66                 // Field java/lang/System.out:Ljava/io/PrintStream;
      86: swap
      87: invokevirtual #72                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      90: return

  public static final int matchingNrOfChars(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #83                 // String lines
       3: invokestatic  #89                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #93                 // Method prepare:(Ljava/util/List;)Ljava/util/List;
      10: checkcast     #95                 // class java/lang/Iterable
      13: astore_1
      14: nop
      15: iconst_0
      16: istore_2
      17: aload_1
      18: astore_3
      19: new           #97                 // class java/util/ArrayList
      22: dup
      23: aload_1
      24: bipush        10
      26: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      29: invokespecial #106                // Method java/util/ArrayList."<init>":(I)V
      32: checkcast     #108                // class java/util/Collection
      35: astore        4
      37: iconst_0
      38: istore        5
      40: aload_3
      41: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      46: astore        6
      48: aload         6
      50: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      55: ifeq          133
      58: aload         6
      60: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      65: astore        7
      67: aload         4
      69: aload         7
      71: checkcast     #124                // class java/util/List
      74: astore        8
      76: astore        12
      78: iconst_0
      79: istore        9
      81: aload         8
      83: iconst_0
      84: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      89: checkcast     #130                // class java/lang/String
      92: astore        10
      94: aload         8
      96: iconst_1
      97: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     102: checkcast     #130                // class java/lang/String
     105: astore        11
     107: new           #132                // class kotlin/Pair
     110: dup
     111: aload         10
     113: invokestatic  #136                // Method charCountRule:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
     116: aload         11
     118: invokespecial #139                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     121: aload         12
     123: swap
     124: invokeinterface #143,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     129: pop
     130: goto          48
     133: aload         4
     135: checkcast     #124                // class java/util/List
     138: nop
     139: checkcast     #95                 // class java/lang/Iterable
     142: astore_1
     143: nop
     144: iconst_0
     145: istore_2
     146: aload_1
     147: instanceof    #108                // class java/util/Collection
     150: ifeq          169
     153: aload_1
     154: checkcast     #108                // class java/util/Collection
     157: invokeinterface #146,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     162: ifeq          169
     165: iconst_0
     166: goto          260
     169: iconst_0
     170: istore_3
     171: aload_1
     172: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     177: astore        4
     179: aload         4
     181: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     186: ifeq          259
     189: aload         4
     191: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     196: astore        5
     198: aload         5
     200: checkcast     #132                // class kotlin/Pair
     203: astore        6
     205: iconst_0
     206: istore        7
     208: aload         6
     210: invokevirtual #149                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     213: checkcast     #151                // class kotlin/jvm/functions/Function1
     216: astore        8
     218: aload         6
     220: invokevirtual #154                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     223: checkcast     #130                // class java/lang/String
     226: astore        9
     228: aload         8
     230: aload         9
     232: invokeinterface #158,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     237: checkcast     #160                // class java/lang/Boolean
     240: invokevirtual #163                // Method java/lang/Boolean.booleanValue:()Z
     243: ifeq          179
     246: iinc          3, 1
     249: iload_3
     250: ifge          179
     253: invokestatic  #166                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     256: goto          179
     259: iload_3
     260: ireturn

  public static final int matchingPosition(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #83                 // String lines
       3: invokestatic  #89                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #93                 // Method prepare:(Ljava/util/List;)Ljava/util/List;
      10: checkcast     #95                 // class java/lang/Iterable
      13: astore_1
      14: nop
      15: iconst_0
      16: istore_2
      17: aload_1
      18: astore_3
      19: new           #97                 // class java/util/ArrayList
      22: dup
      23: aload_1
      24: bipush        10
      26: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      29: invokespecial #106                // Method java/util/ArrayList."<init>":(I)V
      32: checkcast     #108                // class java/util/Collection
      35: astore        4
      37: iconst_0
      38: istore        5
      40: aload_3
      41: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      46: astore        6
      48: aload         6
      50: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      55: ifeq          133
      58: aload         6
      60: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      65: astore        7
      67: aload         4
      69: aload         7
      71: checkcast     #124                // class java/util/List
      74: astore        8
      76: astore        12
      78: iconst_0
      79: istore        9
      81: aload         8
      83: iconst_0
      84: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      89: checkcast     #130                // class java/lang/String
      92: astore        10
      94: aload         8
      96: iconst_1
      97: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     102: checkcast     #130                // class java/lang/String
     105: astore        11
     107: new           #132                // class kotlin/Pair
     110: dup
     111: aload         10
     113: invokestatic  #190                // Method charPositionRule:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
     116: aload         11
     118: invokespecial #139                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     121: aload         12
     123: swap
     124: invokeinterface #143,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     129: pop
     130: goto          48
     133: aload         4
     135: checkcast     #124                // class java/util/List
     138: nop
     139: checkcast     #95                 // class java/lang/Iterable
     142: astore_1
     143: nop
     144: iconst_0
     145: istore_2
     146: aload_1
     147: instanceof    #108                // class java/util/Collection
     150: ifeq          169
     153: aload_1
     154: checkcast     #108                // class java/util/Collection
     157: invokeinterface #146,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     162: ifeq          169
     165: iconst_0
     166: goto          260
     169: iconst_0
     170: istore_3
     171: aload_1
     172: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     177: astore        4
     179: aload         4
     181: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     186: ifeq          259
     189: aload         4
     191: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     196: astore        5
     198: aload         5
     200: checkcast     #132                // class kotlin/Pair
     203: astore        6
     205: iconst_0
     206: istore        7
     208: aload         6
     210: invokevirtual #149                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     213: checkcast     #151                // class kotlin/jvm/functions/Function1
     216: astore        8
     218: aload         6
     220: invokevirtual #154                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     223: checkcast     #130                // class java/lang/String
     226: astore        9
     228: aload         8
     230: aload         9
     232: invokeinterface #158,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     237: checkcast     #160                // class java/lang/Boolean
     240: invokevirtual #163                // Method java/lang/Boolean.booleanValue:()Z
     243: ifeq          179
     246: iinc          3, 1
     249: iload_3
     250: ifge          179
     253: invokestatic  #166                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     256: goto          179
     259: iload_3
     260: ireturn

  private static final kotlin.jvm.functions.Function1<java.lang.String, java.lang.Boolean> charCountRule(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #195                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #130                // class java/lang/String
       8: astore_1
       9: aload_1
      10: iconst_0
      11: ldc           #197                // String
      13: aastore
      14: aload_1
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #203                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_2
      24: iconst_0
      25: istore_3
      26: aload_2
      27: iconst_0
      28: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      33: checkcast     #130                // class java/lang/String
      36: astore        4
      38: aload_2
      39: iconst_1
      40: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      45: checkcast     #130                // class java/lang/String
      48: astore        5
      50: aload         4
      52: checkcast     #195                // class java/lang/CharSequence
      55: iconst_1
      56: anewarray     #130                // class java/lang/String
      59: astore        6
      61: aload         6
      63: iconst_0
      64: ldc           #205                // String -
      66: aastore
      67: aload         6
      69: iconst_0
      70: iconst_0
      71: bipush        6
      73: aconst_null
      74: invokestatic  #203                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      77: checkcast     #95                 // class java/lang/Iterable
      80: astore        6
      82: iconst_0
      83: istore        7
      85: aload         6
      87: astore        8
      89: new           #97                 // class java/util/ArrayList
      92: dup
      93: aload         6
      95: bipush        10
      97: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     100: invokespecial #106                // Method java/util/ArrayList."<init>":(I)V
     103: checkcast     #108                // class java/util/Collection
     106: astore        9
     108: iconst_0
     109: istore        10
     111: aload         8
     113: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     118: astore        11
     120: aload         11
     122: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     127: ifeq          174
     130: aload         11
     132: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     137: astore        12
     139: aload         9
     141: aload         12
     143: checkcast     #130                // class java/lang/String
     146: astore        13
     148: astore        14
     150: iconst_0
     151: istore        15
     153: aload         13
     155: invokestatic  #211                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     158: nop
     159: invokestatic  #215                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     162: aload         14
     164: swap
     165: invokeinterface #143,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     170: pop
     171: goto          120
     174: aload         9
     176: checkcast     #124                // class java/util/List
     179: nop
     180: astore        16
     182: aload         16
     184: iconst_0
     185: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     190: checkcast     #217                // class java/lang/Number
     193: invokevirtual #221                // Method java/lang/Number.intValue:()I
     196: istore        6
     198: aload         16
     200: iconst_1
     201: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     206: checkcast     #217                // class java/lang/Number
     209: invokevirtual #221                // Method java/lang/Number.intValue:()I
     212: istore        7
     214: new           #223                // class kotlin/ranges/IntRange
     217: dup
     218: iload         6
     220: iload         7
     222: invokespecial #226                // Method kotlin/ranges/IntRange."<init>":(II)V
     225: astore        8
     227: aload         5
     229: checkcast     #195                // class java/lang/CharSequence
     232: invokestatic  #230                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     235: istore        9
     237: aload         8
     239: iload         9
     241: invokedynamic #248,  0            // InvokeDynamic #0:invoke:(Lkotlin/ranges/IntRange;C)Lkotlin/jvm/functions/Function1;
     246: areturn

  private static final kotlin.jvm.functions.Function1<java.lang.String, java.lang.Boolean> charPositionRule(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #195                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #130                // class java/lang/String
       8: astore_1
       9: aload_1
      10: iconst_0
      11: ldc           #197                // String
      13: aastore
      14: aload_1
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #203                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_2
      24: iconst_0
      25: istore_3
      26: aload_2
      27: iconst_0
      28: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      33: checkcast     #130                // class java/lang/String
      36: astore        4
      38: aload_2
      39: iconst_1
      40: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      45: checkcast     #130                // class java/lang/String
      48: astore        5
      50: aload         4
      52: checkcast     #195                // class java/lang/CharSequence
      55: iconst_1
      56: anewarray     #130                // class java/lang/String
      59: astore        6
      61: aload         6
      63: iconst_0
      64: ldc           #205                // String -
      66: aastore
      67: aload         6
      69: iconst_0
      70: iconst_0
      71: bipush        6
      73: aconst_null
      74: invokestatic  #203                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      77: checkcast     #95                 // class java/lang/Iterable
      80: astore        6
      82: iconst_0
      83: istore        7
      85: aload         6
      87: astore        8
      89: new           #97                 // class java/util/ArrayList
      92: dup
      93: aload         6
      95: bipush        10
      97: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     100: invokespecial #106                // Method java/util/ArrayList."<init>":(I)V
     103: checkcast     #108                // class java/util/Collection
     106: astore        9
     108: iconst_0
     109: istore        10
     111: aload         8
     113: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     118: astore        11
     120: aload         11
     122: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     127: ifeq          174
     130: aload         11
     132: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     137: astore        12
     139: aload         9
     141: aload         12
     143: checkcast     #130                // class java/lang/String
     146: astore        13
     148: astore        14
     150: iconst_0
     151: istore        15
     153: aload         13
     155: invokestatic  #211                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     158: nop
     159: invokestatic  #215                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     162: aload         14
     164: swap
     165: invokeinterface #143,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     170: pop
     171: goto          120
     174: aload         9
     176: checkcast     #124                // class java/util/List
     179: nop
     180: astore        16
     182: aload         16
     184: iconst_0
     185: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     190: checkcast     #217                // class java/lang/Number
     193: invokevirtual #221                // Method java/lang/Number.intValue:()I
     196: istore        6
     198: aload         16
     200: iconst_1
     201: invokeinterface #128,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     206: checkcast     #217                // class java/lang/Number
     209: invokevirtual #221                // Method java/lang/Number.intValue:()I
     212: istore        7
     214: aload         5
     216: checkcast     #195                // class java/lang/CharSequence
     219: invokestatic  #230                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     222: istore        8
     224: iload         6
     226: iload         7
     228: iload         8
     230: invokedynamic #270,  0            // InvokeDynamic #1:invoke:(IIC)Lkotlin/jvm/functions/Function1;
     235: areturn

  private static final java.util.List<java.util.List<java.lang.String>> prepare(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #95                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #97                 // class java/util/ArrayList
      12: dup
      13: invokespecial #277                // Method java/util/ArrayList."<init>":()V
      16: checkcast     #108                // class java/util/Collection
      19: astore        4
      21: iconst_0
      22: istore        5
      24: aload_3
      25: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      30: astore        6
      32: aload         6
      34: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      39: ifeq          96
      42: aload         6
      44: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      49: astore        7
      51: aload         7
      53: checkcast     #130                // class java/lang/String
      56: astore        8
      58: iconst_0
      59: istore        9
      61: aload         8
      63: checkcast     #195                // class java/lang/CharSequence
      66: invokeinterface #280,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      71: ifle          78
      74: iconst_1
      75: goto          79
      78: iconst_0
      79: nop
      80: ifeq          32
      83: aload         4
      85: aload         7
      87: invokeinterface #143,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      92: pop
      93: goto          32
      96: aload         4
      98: checkcast     #124                // class java/util/List
     101: nop
     102: checkcast     #95                 // class java/lang/Iterable
     105: astore_1
     106: nop
     107: iconst_0
     108: istore_2
     109: aload_1
     110: astore_3
     111: new           #97                 // class java/util/ArrayList
     114: dup
     115: aload_1
     116: bipush        10
     118: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     121: invokespecial #106                // Method java/util/ArrayList."<init>":(I)V
     124: checkcast     #108                // class java/util/Collection
     127: astore        4
     129: iconst_0
     130: istore        5
     132: aload_3
     133: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     138: astore        6
     140: aload         6
     142: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     147: ifeq          213
     150: aload         6
     152: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     157: astore        7
     159: aload         4
     161: aload         7
     163: checkcast     #130                // class java/lang/String
     166: astore        8
     168: astore        11
     170: iconst_0
     171: istore        9
     173: aload         8
     175: checkcast     #195                // class java/lang/CharSequence
     178: iconst_1
     179: anewarray     #130                // class java/lang/String
     182: astore        10
     184: aload         10
     186: iconst_0
     187: ldc_w         #282                // String :
     190: aastore
     191: aload         10
     193: iconst_0
     194: iconst_0
     195: bipush        6
     197: aconst_null
     198: invokestatic  #203                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     201: aload         11
     203: swap
     204: invokeinterface #143,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     209: pop
     210: goto          140
     213: aload         4
     215: checkcast     #124                // class java/util/List
     218: nop
     219: areturn

  private static final boolean indexMatches(int, int...);
    Code:
       0: aload_1
       1: iload_0
       2: iconst_1
       3: iadd
       4: invokestatic  #297                // Method kotlin/collections/ArraysKt.contains:([II)Z
       7: ireturn

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

  private static final boolean charCountRule$lambda$7$lambda$6(kotlin.ranges.IntRange, char, java.lang.String);
    Code:
       0: aload_2
       1: ldc_w         #305                // String password
       4: invokestatic  #89                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #308                // Method kotlin/ranges/IntRange.getFirst:()I
      11: istore_3
      12: aload_0
      13: invokevirtual #311                // Method kotlin/ranges/IntRange.getLast:()I
      16: istore        4
      18: aload_2
      19: astore        6
      21: iconst_0
      22: istore        7
      24: aload         6
      26: checkcast     #195                // class java/lang/CharSequence
      29: astore        8
      31: new           #42                 // class java/lang/StringBuilder
      34: dup
      35: invokespecial #43                 // Method java/lang/StringBuilder."<init>":()V
      38: checkcast     #313                // class java/lang/Appendable
      41: astore        9
      43: iconst_0
      44: istore        10
      46: iconst_0
      47: istore        11
      49: aload         8
      51: invokeinterface #280,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      56: istore        12
      58: iload         11
      60: iload         12
      62: if_icmpge     113
      65: aload         8
      67: iload         11
      69: invokeinterface #317,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      74: istore        13
      76: iload         13
      78: istore        14
      80: iconst_0
      81: istore        15
      83: iload         14
      85: iload_1
      86: if_icmpne     93
      89: iconst_1
      90: goto          94
      93: iconst_0
      94: ifeq          107
      97: aload         9
      99: iload         13
     101: invokeinterface #320,  2          // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;
     106: pop
     107: iinc          11, 1
     110: goto          58
     113: aload         9
     115: checkcast     #42                 // class java/lang/StringBuilder
     118: invokevirtual #60                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     121: checkcast     #195                // class java/lang/CharSequence
     124: invokeinterface #280,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     129: istore        5
     131: iload_3
     132: iload         5
     134: if_icmpgt     152
     137: iload         5
     139: iload         4
     141: if_icmpgt     148
     144: iconst_1
     145: goto          153
     148: iconst_0
     149: goto          153
     152: iconst_0
     153: ireturn

  private static final boolean charPositionRule$lambda$11$lambda$10(int, int, char, java.lang.String);
    Code:
       0: aload_3
       1: ldc_w         #305                // String password
       4: invokestatic  #89                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_3
       8: checkcast     #195                // class java/lang/CharSequence
      11: invokestatic  #330                // Method kotlin/text/StringsKt.withIndex:(Ljava/lang/CharSequence;)Ljava/lang/Iterable;
      14: astore        4
      16: iconst_0
      17: istore        5
      19: aload         4
      21: instanceof    #108                // class java/util/Collection
      24: ifeq          44
      27: aload         4
      29: checkcast     #108                // class java/util/Collection
      32: invokeinterface #146,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      37: ifeq          44
      40: iconst_0
      41: goto          152
      44: iconst_0
      45: istore        6
      47: aload         4
      49: invokeinterface #112,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      54: astore        7
      56: aload         7
      58: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          150
      66: aload         7
      68: invokeinterface #122,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      73: astore        8
      75: aload         8
      77: checkcast     #332                // class kotlin/collections/IndexedValue
      80: astore        9
      82: iconst_0
      83: istore        10
      85: aload         9
      87: invokevirtual #335                // Method kotlin/collections/IndexedValue.getIndex:()I
      90: iconst_2
      91: newarray       int
      93: astore        11
      95: aload         11
      97: iconst_0
      98: iload_0
      99: iastore
     100: aload         11
     102: iconst_1
     103: iload_1
     104: iastore
     105: aload         11
     107: invokestatic  #337                // Method indexMatches:(I[I)Z
     110: ifeq          132
     113: aload         9
     115: invokevirtual #340                // Method kotlin/collections/IndexedValue.getValue:()Ljava/lang/Object;
     118: checkcast     #342                // class java/lang/Character
     121: invokevirtual #346                // Method java/lang/Character.charValue:()C
     124: iload_2
     125: if_icmpne     132
     128: iconst_1
     129: goto          133
     132: iconst_0
     133: ifeq          56
     136: iinc          6, 1
     139: iload         6
     141: ifge          56
     144: invokestatic  #166                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     147: goto          56
     150: iload         6
     152: iconst_1
     153: if_icmpne     160
     156: iconst_1
     157: goto          161
     160: iconst_0
     161: ireturn
}

Compiled from "Day2.kt"
public final class day2.Day2Kt$main$input$1 {
  day2.Day2Kt$main$input$1();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return
}


package com.terencepeh.leetcodepractice

fun intersection(nums1: IntArray, nums2: IntArray): IntArray {
    return nums1.intersect(nums2.toHashSet()).toIntArray()
}

fun intersection2(nums1: IntArray, nums2: IntArray): IntArray {
    val set1 = nums1.toHashSet()
    val set2 = nums2.toHashSet()

    return if (set1.size > set2.size) {
        setIntersection(set1, set2)
    } else {
        setIntersection(set2, set1)
    }
}

fun setIntersection(set1: HashSet<Int>, set2: HashSet<Int>): IntArray {
    val output = mutableListOf<Int>()

    set2.forEach { s ->
        if (set1.contains(s)) {
            output.add(s)
        }
    }

    return output.toIntArray()
}

fun main() {
    val nums1 = intArrayOf(4, 9, 5, 1)
    val nums2 = intArrayOf(9, 4, 9, 8, 4)

    println("intersection: ${intersection(nums1, nums2).contentToString()}")
    println("intersection: ${intersection2(nums1, nums2).contentToString()}")
}

Compiled from "IntersectionArrays.kt"
public final class com.terencepeh.leetcodepractice.IntersectionArraysKt {
  public static final int[] intersection(int[], int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String nums1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String nums2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: aload_1
      14: invokestatic  #23                 // Method kotlin/collections/ArraysKt.toHashSet:([I)Ljava/util/HashSet;
      17: checkcast     #25                 // class java/lang/Iterable
      20: invokestatic  #29                 // Method kotlin/collections/ArraysKt.intersect:([ILjava/lang/Iterable;)Ljava/util/Set;
      23: checkcast     #31                 // class java/util/Collection
      26: invokestatic  #37                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
      29: areturn

  public static final int[] intersection2(int[], int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String nums1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String nums2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokestatic  #23                 // Method kotlin/collections/ArraysKt.toHashSet:([I)Ljava/util/HashSet;
      16: astore_2
      17: aload_1
      18: invokestatic  #23                 // Method kotlin/collections/ArraysKt.toHashSet:([I)Ljava/util/HashSet;
      21: astore_3
      22: aload_2
      23: invokevirtual #45                 // Method java/util/HashSet.size:()I
      26: aload_3
      27: invokevirtual #45                 // Method java/util/HashSet.size:()I
      30: if_icmple     41
      33: aload_2
      34: aload_3
      35: invokestatic  #49                 // Method setIntersection:(Ljava/util/HashSet;Ljava/util/HashSet;)[I
      38: goto          46
      41: aload_3
      42: aload_2
      43: invokestatic  #49                 // Method setIntersection:(Ljava/util/HashSet;Ljava/util/HashSet;)[I
      46: areturn

  public static final int[] setIntersection(java.util.HashSet<java.lang.Integer>, java.util.HashSet<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #55                 // String set1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #56                 // String set2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #58                 // class java/util/ArrayList
      15: dup
      16: invokespecial #62                 // Method java/util/ArrayList."<init>":()V
      19: checkcast     #64                 // class java/util/List
      22: astore_2
      23: aload_1
      24: checkcast     #25                 // class java/lang/Iterable
      27: astore_3
      28: iconst_0
      29: istore        4
      31: aload_3
      32: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        5
      39: aload         5
      41: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          100
      49: aload         5
      51: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: astore        6
      58: aload         6
      60: checkcast     #80                 // class java/lang/Number
      63: invokevirtual #83                 // Method java/lang/Number.intValue:()I
      66: istore        7
      68: iconst_0
      69: istore        8
      71: aload_0
      72: iload         7
      74: invokestatic  #89                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: invokevirtual #93                 // Method java/util/HashSet.contains:(Ljava/lang/Object;)Z
      80: ifeq          95
      83: aload_2
      84: iload         7
      86: invokestatic  #89                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      89: invokeinterface #96,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      94: pop
      95: nop
      96: nop
      97: goto          39
     100: nop
     101: aload_2
     102: checkcast     #31                 // class java/util/Collection
     105: invokestatic  #37                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     108: areturn

  public static final void main();
    Code:
       0: iconst_4
       1: newarray       int
       3: astore_1
       4: aload_1
       5: iconst_0
       6: iconst_4
       7: iastore
       8: aload_1
       9: iconst_1
      10: bipush        9
      12: iastore
      13: aload_1
      14: iconst_2
      15: iconst_5
      16: iastore
      17: aload_1
      18: iconst_3
      19: iconst_1
      20: iastore
      21: aload_1
      22: astore_0
      23: iconst_5
      24: newarray       int
      26: astore_2
      27: aload_2
      28: iconst_0
      29: bipush        9
      31: iastore
      32: aload_2
      33: iconst_1
      34: iconst_4
      35: iastore
      36: aload_2
      37: iconst_2
      38: bipush        9
      40: iastore
      41: aload_2
      42: iconst_3
      43: bipush        8
      45: iastore
      46: aload_2
      47: iconst_4
      48: iconst_4
      49: iastore
      50: aload_2
      51: astore_1
      52: new           #109                // class java/lang/StringBuilder
      55: dup
      56: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
      59: ldc           #112                // String intersection:
      61: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      64: aload_0
      65: aload_1
      66: invokestatic  #118                // Method intersection:([I[I)[I
      69: invokestatic  #124                // Method java/util/Arrays.toString:([I)Ljava/lang/String;
      72: dup
      73: ldc           #126                // String toString(...)
      75: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      78: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      81: invokevirtual #132                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      84: getstatic     #138                // Field java/lang/System.out:Ljava/io/PrintStream;
      87: swap
      88: invokevirtual #144                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      91: new           #109                // class java/lang/StringBuilder
      94: dup
      95: invokespecial #110                // Method java/lang/StringBuilder."<init>":()V
      98: ldc           #112                // String intersection:
     100: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     103: aload_0
     104: aload_1
     105: invokestatic  #146                // Method intersection2:([I[I)[I
     108: invokestatic  #124                // Method java/util/Arrays.toString:([I)Ljava/lang/String;
     111: dup
     112: ldc           #126                // String toString(...)
     114: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     117: invokevirtual #116                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     120: invokevirtual #132                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     123: getstatic     #138                // Field java/lang/System.out:Ljava/io/PrintStream;
     126: swap
     127: invokevirtual #144                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     130: return

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