package kr.co.programmers

import java.util.*

// https://github.com/antop-dev/algorithm/issues/415
class P67257 {
    // 문자열이 숫자인지 판단하는 정규표현식
    val number = Regex("^[0-9]*$")
    // 연산자 우선 순위 경우의 수
    private val ops = listOf(
        arrayOf('*', '+', '-'),
        arrayOf('*', '-', '+'),
        arrayOf('+', '*', '-'),
        arrayOf('+', '-', '*'),
        arrayOf('-', '*', '+'),
        arrayOf('-', '+', '*')
    )

    fun solution(expression: String): Long {
        var answer = 0L
        for (op in ops) {
            val postfix = toPostfix(expression, op)
            var value = calculate(postfix)
            if (value < 0) value *= -1
            if (value > answer) {
                answer = value
            }
        }
        return answer
    }

    // 중위 표기법 → 후위 표기법
    private fun toPostfix(infix: String, op: Array<Char>): List<String> {
        val stack = Stack<Char>()
        val postfix = mutableListOf<String>()
        var num = 0

        for (ch in infix) {
            if (ch in '0'..'9') {
                num = (num * 10) + (ch - '0')
            } else {
                postfix += "$num"
                num = 0

                while (stack.isNotEmpty() && op.indexOf(stack.peek()) <= op.indexOf(ch)) {
                    postfix += "${stack.pop()}"
                }
                stack += ch
            }
        }
        // 남은 숫자와 연산자들 처리
        postfix += "$num"
        while (stack.isNotEmpty()) {
            postfix += "${stack.pop()}"
        }
        return postfix
    }

    // 후위 표기법으로 계산
    private fun calculate(postfix: List<String>): Long {
        val stack = Stack<Long>()
        for (v in postfix) {
            stack += if (v.matches(number)) {
                v.toLong()
            } else {
                val b = stack.pop()
                val a = stack.pop()
                when (v[0]) {
                    '+' -> a + b
                    '-' -> a - b
                    else -> a * b
                }
            }
        }
        return stack.pop()
    }

}

Compiled from "P67257.kt"
public final class kr.co.programmers.P67257 {
  private final kotlin.text.Regex number;

  private final java.util.List<java.lang.Character[]> ops;

  public kr.co.programmers.P67257();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: new           #10                 // class kotlin/text/Regex
       8: dup
       9: ldc           #12                 // String ^[0-9]*$
      11: invokespecial #15                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      14: putfield      #19                 // Field number:Lkotlin/text/Regex;
      17: aload_0
      18: bipush        6
      20: anewarray     #21                 // class "[Ljava/lang/Character;"
      23: astore_1
      24: aload_1
      25: iconst_0
      26: iconst_3
      27: anewarray     #23                 // class java/lang/Character
      30: astore_2
      31: aload_2
      32: iconst_0
      33: bipush        42
      35: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      38: aastore
      39: aload_2
      40: iconst_1
      41: bipush        43
      43: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      46: aastore
      47: aload_2
      48: iconst_2
      49: bipush        45
      51: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      54: aastore
      55: aload_2
      56: aastore
      57: aload_1
      58: iconst_1
      59: iconst_3
      60: anewarray     #23                 // class java/lang/Character
      63: astore_2
      64: aload_2
      65: iconst_0
      66: bipush        42
      68: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      71: aastore
      72: aload_2
      73: iconst_1
      74: bipush        45
      76: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      79: aastore
      80: aload_2
      81: iconst_2
      82: bipush        43
      84: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      87: aastore
      88: aload_2
      89: aastore
      90: aload_1
      91: iconst_2
      92: iconst_3
      93: anewarray     #23                 // class java/lang/Character
      96: astore_2
      97: aload_2
      98: iconst_0
      99: bipush        43
     101: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     104: aastore
     105: aload_2
     106: iconst_1
     107: bipush        42
     109: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     112: aastore
     113: aload_2
     114: iconst_2
     115: bipush        45
     117: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     120: aastore
     121: aload_2
     122: aastore
     123: aload_1
     124: iconst_3
     125: iconst_3
     126: anewarray     #23                 // class java/lang/Character
     129: astore_2
     130: aload_2
     131: iconst_0
     132: bipush        43
     134: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     137: aastore
     138: aload_2
     139: iconst_1
     140: bipush        45
     142: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     145: aastore
     146: aload_2
     147: iconst_2
     148: bipush        42
     150: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     153: aastore
     154: aload_2
     155: aastore
     156: aload_1
     157: iconst_4
     158: iconst_3
     159: anewarray     #23                 // class java/lang/Character
     162: astore_2
     163: aload_2
     164: iconst_0
     165: bipush        45
     167: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     170: aastore
     171: aload_2
     172: iconst_1
     173: bipush        42
     175: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     178: aastore
     179: aload_2
     180: iconst_2
     181: bipush        43
     183: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     186: aastore
     187: aload_2
     188: aastore
     189: aload_1
     190: iconst_5
     191: iconst_3
     192: anewarray     #23                 // class java/lang/Character
     195: astore_2
     196: aload_2
     197: iconst_0
     198: bipush        45
     200: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     203: aastore
     204: aload_2
     205: iconst_1
     206: bipush        43
     208: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     211: aastore
     212: aload_2
     213: iconst_2
     214: bipush        42
     216: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     219: aastore
     220: aload_2
     221: aastore
     222: aload_1
     223: checkcast     #29                 // class "[Ljava/lang/Object;"
     226: invokestatic  #35                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     229: putfield      #39                 // Field ops:Ljava/util/List;
     232: return

  public final kotlin.text.Regex getNumber();
    Code:
       0: aload_0
       1: getfield      #19                 // Field number:Lkotlin/text/Regex;
       4: areturn

  public final long solution(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #48                 // String expression
       3: invokestatic  #54                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: lconst_0
       7: lstore_2
       8: aload_0
       9: getfield      #39                 // Field ops:Ljava/util/List;
      12: invokeinterface #60,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      17: astore        4
      19: aload         4
      21: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      26: ifeq          85
      29: aload         4
      31: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: checkcast     #21                 // class "[Ljava/lang/Character;"
      39: astore        5
      41: aload_0
      42: aload_1
      43: aload         5
      45: invokespecial #74                 // Method toPostfix:(Ljava/lang/String;[Ljava/lang/Character;)Ljava/util/List;
      48: astore        6
      50: aload_0
      51: aload         6
      53: invokespecial #78                 // Method calculate:(Ljava/util/List;)J
      56: lstore        7
      58: lload         7
      60: lconst_0
      61: lcmp
      62: ifge          72
      65: lload         7
      67: iconst_m1
      68: i2l
      69: lmul
      70: lstore        7
      72: lload         7
      74: lload_2
      75: lcmp
      76: ifle          19
      79: lload         7
      81: lstore_2
      82: goto          19
      85: lload_2
      86: lreturn

  private final java.util.List<java.lang.String> toPostfix(java.lang.String, java.lang.Character[]);
    Code:
       0: new           #87                 // class java/util/Stack
       3: dup
       4: invokespecial #88                 // Method java/util/Stack."<init>":()V
       7: astore_3
       8: new           #90                 // class java/util/ArrayList
      11: dup
      12: invokespecial #91                 // Method java/util/ArrayList."<init>":()V
      15: checkcast     #56                 // class java/util/List
      18: astore        4
      20: iconst_0
      21: istore        5
      23: iconst_0
      24: istore        6
      26: aload_1
      27: invokevirtual #97                 // Method java/lang/String.length:()I
      30: istore        7
      32: iload         6
      34: iload         7
      36: if_icmpge     194
      39: aload_1
      40: iload         6
      42: invokevirtual #101                // Method java/lang/String.charAt:(I)C
      45: istore        8
      47: bipush        48
      49: iload         8
      51: if_icmpgt     69
      54: iload         8
      56: bipush        58
      58: if_icmpge     65
      61: iconst_1
      62: goto          70
      65: iconst_0
      66: goto          70
      69: iconst_0
      70: ifeq          89
      73: iload         5
      75: bipush        10
      77: imul
      78: iload         8
      80: bipush        48
      82: isub
      83: iadd
      84: istore        5
      86: goto          188
      89: aload         4
      91: checkcast     #103                // class java/util/Collection
      94: iload         5
      96: invokestatic  #106                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
      99: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     104: pop
     105: iconst_0
     106: istore        5
     108: aload_3
     109: checkcast     #103                // class java/util/Collection
     112: invokeinterface #113,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     117: ifne          124
     120: iconst_1
     121: goto          125
     124: iconst_0
     125: ifeq          169
     128: aload_2
     129: aload_3
     130: invokevirtual #116                // Method java/util/Stack.peek:()Ljava/lang/Object;
     133: invokestatic  #122                // Method kotlin/collections/ArraysKt.indexOf:([Ljava/lang/Object;Ljava/lang/Object;)I
     136: aload_2
     137: iload         8
     139: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     142: invokestatic  #122                // Method kotlin/collections/ArraysKt.indexOf:([Ljava/lang/Object;Ljava/lang/Object;)I
     145: if_icmpgt     169
     148: aload         4
     150: checkcast     #103                // class java/util/Collection
     153: aload_3
     154: invokevirtual #125                // Method java/util/Stack.pop:()Ljava/lang/Object;
     157: invokestatic  #128                // Method java/lang/String.valueOf:(Ljava/lang/Object;)Ljava/lang/String;
     160: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     165: pop
     166: goto          108
     169: iload         8
     171: invokestatic  #27                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     174: astore        9
     176: aload_3
     177: checkcast     #103                // class java/util/Collection
     180: aload         9
     182: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     187: pop
     188: iinc          6, 1
     191: goto          32
     194: aload         4
     196: checkcast     #103                // class java/util/Collection
     199: iload         5
     201: invokestatic  #106                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     204: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     209: pop
     210: aload_3
     211: checkcast     #103                // class java/util/Collection
     214: invokeinterface #113,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     219: ifne          226
     222: iconst_1
     223: goto          227
     226: iconst_0
     227: ifeq          251
     230: aload         4
     232: checkcast     #103                // class java/util/Collection
     235: aload_3
     236: invokevirtual #125                // Method java/util/Stack.pop:()Ljava/lang/Object;
     239: invokestatic  #128                // Method java/lang/String.valueOf:(Ljava/lang/Object;)Ljava/lang/String;
     242: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     247: pop
     248: goto          210
     251: aload         4
     253: areturn

  private final long calculate(java.util.List<java.lang.String>);
    Code:
       0: new           #87                 // class java/util/Stack
       3: dup
       4: invokespecial #88                 // Method java/util/Stack."<init>":()V
       7: astore_2
       8: aload_1
       9: invokeinterface #60,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      14: astore_3
      15: aload_3
      16: invokeinterface #66,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      21: ifeq          192
      24: aload_3
      25: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      30: checkcast     #93                 // class java/lang/String
      33: astore        4
      35: aload_2
      36: checkcast     #103                // class java/util/Collection
      39: astore        5
      41: aload         4
      43: checkcast     #138                // class java/lang/CharSequence
      46: astore        6
      48: aload_0
      49: getfield      #19                 // Field number:Lkotlin/text/Regex;
      52: aload         6
      54: invokevirtual #142                // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z
      57: ifeq          68
      60: aload         4
      62: invokestatic  #147                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      65: goto          174
      68: aload_2
      69: invokevirtual #125                // Method java/util/Stack.pop:()Ljava/lang/Object;
      72: checkcast     #144                // class java/lang/Long
      75: astore        6
      77: aload_2
      78: invokevirtual #125                // Method java/util/Stack.pop:()Ljava/lang/Object;
      81: checkcast     #144                // class java/lang/Long
      84: astore        7
      86: aload         4
      88: iconst_0
      89: invokevirtual #101                // Method java/lang/String.charAt:(I)C
      92: tableswitch   { // 43 to 45
                    43: 120
                    44: 158
                    45: 139
               default: 158
          }
     120: aload         7
     122: invokevirtual #151                // Method java/lang/Long.longValue:()J
     125: aload         6
     127: invokestatic  #155                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     130: aload         6
     132: invokevirtual #151                // Method java/lang/Long.longValue:()J
     135: ladd
     136: goto          174
     139: aload         7
     141: invokevirtual #151                // Method java/lang/Long.longValue:()J
     144: aload         6
     146: invokestatic  #155                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     149: aload         6
     151: invokevirtual #151                // Method java/lang/Long.longValue:()J
     154: lsub
     155: goto          174
     158: aload         7
     160: invokevirtual #151                // Method java/lang/Long.longValue:()J
     163: aload         6
     165: invokestatic  #155                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     168: aload         6
     170: invokevirtual #151                // Method java/lang/Long.longValue:()J
     173: lmul
     174: invokestatic  #158                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     177: astore        6
     179: aload         5
     181: aload         6
     183: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     188: pop
     189: goto          15
     192: aload_2
     193: invokevirtual #125                // Method java/util/Stack.pop:()Ljava/lang/Object;
     196: dup
     197: ldc           #160                // String pop(...)
     199: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     202: checkcast     #165                // class java/lang/Number
     205: invokevirtual #166                // Method java/lang/Number.longValue:()J
     208: lreturn
}


package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/465
class P154540 {
    fun solution(maps: Array<String>): IntArray {
        val box = maps.map { StringBuilder(it) }
        val answer = mutableListOf<Int>()
        // DFS
        for (y in box.indices) {
            for (x in box[y].indices) {
                if (box[y][x] in '1'..'9') {
                    answer += dfs(box, y, x)
                }
            }
        }
        if (answer.isEmpty()) answer += -1
        return answer.sorted().toIntArray()
    }

    private fun dfs(box: List<StringBuilder>, y: Int, x: Int): Int {
        // 좌표가 넘처기나 'X' 지역이면 0 리턴
        if (y !in 0..box.lastIndex
            || x !in 0..box[y].lastIndex
            || box[y][x] == 'X'
        ) return 0

        val v = box[y][x] - '0' // '1' → 1
        box[y][x] = 'X'
        return v +
                dfs(box, y - 1, x) +
                dfs(box, y, x + 1) +
                dfs(box, y + 1, x) +
                dfs(box, y, x - 1)
    }
}

Compiled from "P154540.kt"
public final class kr.co.programmers.P154540 {
  public kr.co.programmers.P154540();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int[] solution(java.lang.String[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String maps
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: astore_3
       8: iconst_0
       9: istore        4
      11: aload_3
      12: astore        5
      14: new           #23                 // class java/util/ArrayList
      17: dup
      18: aload_3
      19: arraylength
      20: invokespecial #26                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #28                 // class java/util/Collection
      26: astore        6
      28: iconst_0
      29: istore        7
      31: iconst_0
      32: istore        8
      34: aload         5
      36: arraylength
      37: istore        9
      39: iload         8
      41: iload         9
      43: if_icmpge     88
      46: aload         5
      48: iload         8
      50: aaload
      51: astore        10
      53: aload         6
      55: aload         10
      57: astore        11
      59: astore        13
      61: iconst_0
      62: istore        12
      64: new           #30                 // class java/lang/StringBuilder
      67: dup
      68: aload         11
      70: invokespecial #33                 // Method java/lang/StringBuilder."<init>":(Ljava/lang/String;)V
      73: aload         13
      75: swap
      76: invokeinterface #37,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      81: pop
      82: iinc          8, 1
      85: goto          39
      88: aload         6
      90: checkcast     #39                 // class java/util/List
      93: nop
      94: astore_2
      95: new           #23                 // class java/util/ArrayList
      98: dup
      99: invokespecial #40                 // Method java/util/ArrayList."<init>":()V
     102: checkcast     #39                 // class java/util/List
     105: astore_3
     106: iconst_0
     107: istore        4
     109: aload_2
     110: checkcast     #28                 // class java/util/Collection
     113: invokeinterface #44,  1           // InterfaceMethod java/util/Collection.size:()I
     118: istore        5
     120: iload         4
     122: iload         5
     124: if_icmpge     233
     127: iconst_0
     128: istore        6
     130: aload_2
     131: iload         4
     133: invokeinterface #48,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     138: checkcast     #50                 // class java/lang/CharSequence
     141: invokeinterface #53,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     146: istore        7
     148: iload         6
     150: iload         7
     152: if_icmpge     227
     155: aload_2
     156: iload         4
     158: invokeinterface #48,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     163: checkcast     #30                 // class java/lang/StringBuilder
     166: iload         6
     168: invokevirtual #57                 // Method java/lang/StringBuilder.charAt:(I)C
     171: istore        8
     173: bipush        49
     175: iload         8
     177: if_icmpgt     195
     180: iload         8
     182: bipush        58
     184: if_icmpge     191
     187: iconst_1
     188: goto          196
     191: iconst_0
     192: goto          196
     195: iconst_0
     196: ifeq          221
     199: aload_3
     200: checkcast     #28                 // class java/util/Collection
     203: aload_0
     204: aload_2
     205: iload         4
     207: iload         6
     209: invokespecial #61                 // Method dfs:(Ljava/util/List;II)I
     212: invokestatic  #67                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     215: invokeinterface #37,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     220: pop
     221: iinc          6, 1
     224: goto          148
     227: iinc          4, 1
     230: goto          120
     233: aload_3
     234: invokeinterface #71,  1           // InterfaceMethod java/util/List.isEmpty:()Z
     239: ifeq          256
     242: aload_3
     243: checkcast     #28                 // class java/util/Collection
     246: iconst_m1
     247: invokestatic  #67                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     250: invokeinterface #37,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     255: pop
     256: aload_3
     257: checkcast     #73                 // class java/lang/Iterable
     260: invokestatic  #79                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     263: checkcast     #28                 // class java/util/Collection
     266: invokestatic  #83                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     269: areturn

  private final int dfs(java.util.List<java.lang.StringBuilder>, int, int);
    Code:
       0: iconst_0
       1: iload_2
       2: if_icmpgt     21
       5: iload_2
       6: aload_1
       7: invokestatic  #108                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
      10: if_icmpgt     17
      13: iconst_1
      14: goto          22
      17: iconst_0
      18: goto          22
      21: iconst_0
      22: ifeq          78
      25: iconst_0
      26: iload_3
      27: if_icmpgt     55
      30: iload_3
      31: aload_1
      32: iload_2
      33: invokeinterface #48,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      38: checkcast     #50                 // class java/lang/CharSequence
      41: invokestatic  #113                // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I
      44: if_icmpgt     51
      47: iconst_1
      48: goto          56
      51: iconst_0
      52: goto          56
      55: iconst_0
      56: ifeq          78
      59: aload_1
      60: iload_2
      61: invokeinterface #48,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      66: checkcast     #30                 // class java/lang/StringBuilder
      69: iload_3
      70: invokevirtual #57                 // Method java/lang/StringBuilder.charAt:(I)C
      73: bipush        88
      75: if_icmpne     80
      78: iconst_0
      79: ireturn
      80: aload_1
      81: iload_2
      82: invokeinterface #48,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      87: checkcast     #30                 // class java/lang/StringBuilder
      90: iload_3
      91: invokevirtual #57                 // Method java/lang/StringBuilder.charAt:(I)C
      94: bipush        48
      96: isub
      97: istore        4
      99: aload_1
     100: iload_2
     101: invokeinterface #48,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     106: checkcast     #30                 // class java/lang/StringBuilder
     109: iload_3
     110: bipush        88
     112: invokevirtual #117                // Method java/lang/StringBuilder.setCharAt:(IC)V
     115: iload         4
     117: aload_0
     118: aload_1
     119: iload_2
     120: iconst_1
     121: isub
     122: iload_3
     123: invokespecial #61                 // Method dfs:(Ljava/util/List;II)I
     126: iadd
     127: aload_0
     128: aload_1
     129: iload_2
     130: iload_3
     131: iconst_1
     132: iadd
     133: invokespecial #61                 // Method dfs:(Ljava/util/List;II)I
     136: iadd
     137: aload_0
     138: aload_1
     139: iload_2
     140: iconst_1
     141: iadd
     142: iload_3
     143: invokespecial #61                 // Method dfs:(Ljava/util/List;II)I
     146: iadd
     147: aload_0
     148: aload_1
     149: iload_2
     150: iload_3
     151: iconst_1
     152: isub
     153: invokespecial #61                 // Method dfs:(Ljava/util/List;II)I
     156: iadd
     157: ireturn
}


package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/363
class P81302 {

    fun solution(places: Array<Array<String>>): IntArray {
        val answer = IntArray(places.size)
        for (i in places.indices) answer[i] = place(places[i])
        return answer
    }

    private fun place(place: Array<String>): Int {
        val box = Array(9) { CharArray(9) { 'X' } }.apply {
            for (r in 0 until 5) {
                for (c in 0 until 5) {
                    this[r + 2][c + 2] = place[r][c]
                }
            }
        }

        for (r in 2 until box.size - 2) {
            for (c in 2 until box[r].size - 2) {
                if (check(box, r, c)) return 0
            }
        }
        return 1
    }

    private fun check(box: Array<CharArray>, r: Int, c: Int): Boolean {
        if (box[r][c] != 'P') return false
        return when { // box[r][c] == 'P'
            box[r - 1][c] == 'P' -> true
            box[r][c + 1] == 'P' -> true
            box[r + 1][c] == 'P' -> true
            box[r][c - 1] == 'P' -> true
            box[r - 2][c] == 'P' && box[r - 1][c] == 'O' -> true
            box[r][c + 2] == 'P' && box[r][c + 1] == 'O' -> true
            box[r + 2][c] == 'P' && box[r + 1][c] == 'O' -> true
            box[r][c - 2] == 'P' && box[r][c - 1] == 'O' -> true
            box[r - 1][c - 1] == 'P' && (box[r - 1][c] != 'X' || box[r][c - 1] != 'X') -> return true
            box[r - 1][c + 1] == 'P' && (box[r - 1][c] != 'X' || box[r][c + 1] != 'X') -> return true
            box[r + 1][c + 1] == 'P' && (box[r + 1][c] != 'X' || box[r][c + 1] != 'X') -> return true
            box[r + 1][c - 1] == 'P' && (box[r + 1][c] != 'X' || box[r][c - 1] != 'X') -> return true
            else -> false
        }
    }

}

Compiled from "P81302.kt"
public final class kr.co.programmers.P81302 {
  public kr.co.programmers.P81302();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int[] solution(java.lang.String[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String places
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #23                 // class "[Ljava/lang/Object;"
      10: arraylength
      11: newarray       int
      13: astore_2
      14: iconst_0
      15: istore_3
      16: aload_1
      17: checkcast     #23                 // class "[Ljava/lang/Object;"
      20: arraylength
      21: istore        4
      23: iload_3
      24: iload         4
      26: if_icmpge     45
      29: aload_2
      30: iload_3
      31: aload_0
      32: aload_1
      33: iload_3
      34: aaload
      35: invokespecial #27                 // Method place:([Ljava/lang/String;)I
      38: iastore
      39: iinc          3, 1
      42: goto          23
      45: aload_2
      46: areturn

  private final int place(java.lang.String[]);
    Code:
       0: iconst_0
       1: istore_3
       2: bipush        9
       4: anewarray     #35                 // class "[C"
       7: astore        4
       9: iload_3
      10: bipush        9
      12: if_icmpge     72
      15: iload_3
      16: istore        5
      18: aload         4
      20: iload         5
      22: iconst_0
      23: istore        6
      25: bipush        9
      27: newarray       char
      29: astore        7
      31: istore        10
      33: astore        9
      35: iload         6
      37: bipush        9
      39: if_icmpge     59
      42: iload         6
      44: istore        8
      46: aload         7
      48: iload         8
      50: bipush        88
      52: castore
      53: iinc          6, 1
      56: goto          35
      59: aload         9
      61: iload         10
      63: aload         7
      65: aastore
      66: iinc          3, 1
      69: goto          9
      72: aload         4
      74: astore_3
      75: aload_3
      76: checkcast     #37                 // class "[[C"
      79: astore        4
      81: iconst_0
      82: istore        5
      84: iconst_0
      85: istore        6
      87: iload         6
      89: iconst_5
      90: if_icmpge     135
      93: iconst_0
      94: istore        7
      96: iload         7
      98: iconst_5
      99: if_icmpge     129
     102: aload         4
     104: iload         6
     106: iconst_2
     107: iadd
     108: aaload
     109: iload         7
     111: iconst_2
     112: iadd
     113: aload_1
     114: iload         6
     116: aaload
     117: iload         7
     119: invokevirtual #43                 // Method java/lang/String.charAt:(I)C
     122: castore
     123: iinc          7, 1
     126: goto          96
     129: iinc          6, 1
     132: goto          87
     135: nop
     136: aload_3
     137: checkcast     #37                 // class "[[C"
     140: astore_2
     141: iconst_2
     142: istore_3
     143: aload_2
     144: checkcast     #23                 // class "[Ljava/lang/Object;"
     147: arraylength
     148: iconst_2
     149: isub
     150: istore        4
     152: iload_3
     153: iload         4
     155: if_icmpge     201
     158: iconst_2
     159: istore        5
     161: aload_2
     162: iload_3
     163: aaload
     164: arraylength
     165: iconst_2
     166: isub
     167: istore        6
     169: iload         5
     171: iload         6
     173: if_icmpge     195
     176: aload_0
     177: aload_2
     178: iload_3
     179: iload         5
     181: invokespecial #47                 // Method check:([[CII)Z
     184: ifeq          189
     187: iconst_0
     188: ireturn
     189: iinc          5, 1
     192: goto          169
     195: iinc          3, 1
     198: goto          152
     201: iconst_1
     202: ireturn

  private final boolean check(char[][], int, int);
    Code:
       0: aload_1
       1: iload_2
       2: aaload
       3: iload_3
       4: caload
       5: bipush        80
       7: if_icmpeq     12
      10: iconst_0
      11: ireturn
      12: nop
      13: aload_1
      14: iload_2
      15: iconst_1
      16: isub
      17: aaload
      18: iload_3
      19: caload
      20: bipush        80
      22: if_icmpne     29
      25: iconst_1
      26: goto          350
      29: aload_1
      30: iload_2
      31: aaload
      32: iload_3
      33: iconst_1
      34: iadd
      35: caload
      36: bipush        80
      38: if_icmpne     45
      41: iconst_1
      42: goto          350
      45: aload_1
      46: iload_2
      47: iconst_1
      48: iadd
      49: aaload
      50: iload_3
      51: caload
      52: bipush        80
      54: if_icmpne     61
      57: iconst_1
      58: goto          350
      61: aload_1
      62: iload_2
      63: aaload
      64: iload_3
      65: iconst_1
      66: isub
      67: caload
      68: bipush        80
      70: if_icmpne     77
      73: iconst_1
      74: goto          350
      77: aload_1
      78: iload_2
      79: iconst_2
      80: isub
      81: aaload
      82: iload_3
      83: caload
      84: bipush        80
      86: if_icmpne     105
      89: aload_1
      90: iload_2
      91: iconst_1
      92: isub
      93: aaload
      94: iload_3
      95: caload
      96: bipush        79
      98: if_icmpne     105
     101: iconst_1
     102: goto          350
     105: aload_1
     106: iload_2
     107: aaload
     108: iload_3
     109: iconst_2
     110: iadd
     111: caload
     112: bipush        80
     114: if_icmpne     133
     117: aload_1
     118: iload_2
     119: aaload
     120: iload_3
     121: iconst_1
     122: iadd
     123: caload
     124: bipush        79
     126: if_icmpne     133
     129: iconst_1
     130: goto          350
     133: aload_1
     134: iload_2
     135: iconst_2
     136: iadd
     137: aaload
     138: iload_3
     139: caload
     140: bipush        80
     142: if_icmpne     161
     145: aload_1
     146: iload_2
     147: iconst_1
     148: iadd
     149: aaload
     150: iload_3
     151: caload
     152: bipush        79
     154: if_icmpne     161
     157: iconst_1
     158: goto          350
     161: aload_1
     162: iload_2
     163: aaload
     164: iload_3
     165: iconst_2
     166: isub
     167: caload
     168: bipush        80
     170: if_icmpne     189
     173: aload_1
     174: iload_2
     175: aaload
     176: iload_3
     177: iconst_1
     178: isub
     179: caload
     180: bipush        79
     182: if_icmpne     189
     185: iconst_1
     186: goto          350
     189: aload_1
     190: iload_2
     191: iconst_1
     192: isub
     193: aaload
     194: iload_3
     195: iconst_1
     196: isub
     197: caload
     198: bipush        80
     200: if_icmpne     229
     203: aload_1
     204: iload_2
     205: iconst_1
     206: isub
     207: aaload
     208: iload_3
     209: caload
     210: bipush        88
     212: if_icmpne     227
     215: aload_1
     216: iload_2
     217: aaload
     218: iload_3
     219: iconst_1
     220: isub
     221: caload
     222: bipush        88
     224: if_icmpeq     229
     227: iconst_1
     228: ireturn
     229: aload_1
     230: iload_2
     231: iconst_1
     232: isub
     233: aaload
     234: iload_3
     235: iconst_1
     236: iadd
     237: caload
     238: bipush        80
     240: if_icmpne     269
     243: aload_1
     244: iload_2
     245: iconst_1
     246: isub
     247: aaload
     248: iload_3
     249: caload
     250: bipush        88
     252: if_icmpne     267
     255: aload_1
     256: iload_2
     257: aaload
     258: iload_3
     259: iconst_1
     260: iadd
     261: caload
     262: bipush        88
     264: if_icmpeq     269
     267: iconst_1
     268: ireturn
     269: aload_1
     270: iload_2
     271: iconst_1
     272: iadd
     273: aaload
     274: iload_3
     275: iconst_1
     276: iadd
     277: caload
     278: bipush        80
     280: if_icmpne     309
     283: aload_1
     284: iload_2
     285: iconst_1
     286: iadd
     287: aaload
     288: iload_3
     289: caload
     290: bipush        88
     292: if_icmpne     307
     295: aload_1
     296: iload_2
     297: aaload
     298: iload_3
     299: iconst_1
     300: iadd
     301: caload
     302: bipush        88
     304: if_icmpeq     309
     307: iconst_1
     308: ireturn
     309: aload_1
     310: iload_2
     311: iconst_1
     312: iadd
     313: aaload
     314: iload_3
     315: iconst_1
     316: isub
     317: caload
     318: bipush        80
     320: if_icmpne     349
     323: aload_1
     324: iload_2
     325: iconst_1
     326: iadd
     327: aaload
     328: iload_3
     329: caload
     330: bipush        88
     332: if_icmpne     347
     335: aload_1
     336: iload_2
     337: aaload
     338: iload_3
     339: iconst_1
     340: isub
     341: caload
     342: bipush        88
     344: if_icmpeq     349
     347: iconst_1
     348: ireturn
     349: iconst_0
     350: ireturn
}


package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/537
class P136797 {
    // 한 자판에서 다른 자판으로 가는 가중치
    private val costs = arrayOf(
        intArrayOf(1, 7, 6, 7, 5, 4, 5, 3, 2, 3), // 자판 0
        intArrayOf(7, 1, 2, 4, 2, 3, 5, 4, 5, 6),
        intArrayOf(6, 2, 1, 2, 3, 2, 3, 5, 4, 5),
        intArrayOf(7, 4, 2, 1, 5, 3, 2, 6, 5, 4),
        intArrayOf(5, 2, 3, 5, 1, 2, 4, 2, 3, 5),
        intArrayOf(4, 3, 2, 3, 2, 1, 2, 3, 2, 3),
        intArrayOf(5, 5, 3, 2, 4, 2, 1, 5, 3, 2),
        intArrayOf(3, 4, 5, 6, 2, 3, 5, 1, 2, 4),
        intArrayOf(2, 5, 4, 5, 3, 2, 3, 2, 1, 2),
        intArrayOf(3, 6, 5, 4, 5, 3, 2, 4, 2, 1) // 자판 9
    )

    fun solution(numbers: String): Int {
        // 메모제이션
        val memo = Array(numbers.length) {
            Array(10) { IntArray(10) { -1 } }
        }
        // 왼손은 4, 오른손은 6 자판에서 시작
        return f(numbers, 0, memo, 4, 6)
    }

    /**
     * @param numbers 눌러야 할 숫자 문자열
     * @param i 다음으로 눌러야하는 번호 인덱스
     * @param memo 메모제이션
     * @param left 현재 왼손의 자판 번호
     * @param right 현재 오른손의 자판 번호
     */
    private fun f(numbers: String, i: Int, memo: Array<Array<IntArray>>, left: Int, right: Int): Int {
        if (i == numbers.length) return 0
        // 이미 전에 계산했던 이력이 있다면 더 깊이 내려가지 않고
        // 이전 이력 값을 사용한다.
        if (memo[i][left][right] != -1) {
            return memo[i][left][right]
        }
        // 눌러야 하는 숫자 자판 번호
        val num = numbers[i] - '0'

        var min = Int.MAX_VALUE
        if (num != right) { // 왼손이 움직일 수 있는 경우 (오른손이 가야할 자판에 있다면 손이 겹치게 된다.)
            // (왼손이 num으로 이동) + (다음 자판~마지막 자판까지 누른 최소 가중치)
            val cost = costs[left][num] + f(numbers, i + 1, memo, num, right)
            min = minOf(min, cost)
        }
        if (num != left) { // 오른손이 움직일 수 있는 경우
            // (오른손이 num으로 이동) + (다음 자판~마지막 자판까지 누른 최소 가중치)
            val cost = costs[right][num] + f(numbers, i + 1, memo, left, num)
            min = minOf(min, cost)
        }

        memo[i][left][right] = min // 메모제이션
        return min
    }
}

Compiled from "P136797.kt"
public final class kr.co.programmers.P136797 {
  private final int[][] costs;

  public kr.co.programmers.P136797();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: bipush        10
       7: anewarray     #10                 // class "[I"
      10: astore_1
      11: aload_1
      12: iconst_0
      13: bipush        10
      15: newarray       int
      17: astore_2
      18: aload_2
      19: iconst_0
      20: iconst_1
      21: iastore
      22: aload_2
      23: iconst_1
      24: bipush        7
      26: iastore
      27: aload_2
      28: iconst_2
      29: bipush        6
      31: iastore
      32: aload_2
      33: iconst_3
      34: bipush        7
      36: iastore
      37: aload_2
      38: iconst_4
      39: iconst_5
      40: iastore
      41: aload_2
      42: iconst_5
      43: iconst_4
      44: iastore
      45: aload_2
      46: bipush        6
      48: iconst_5
      49: iastore
      50: aload_2
      51: bipush        7
      53: iconst_3
      54: iastore
      55: aload_2
      56: bipush        8
      58: iconst_2
      59: iastore
      60: aload_2
      61: bipush        9
      63: iconst_3
      64: iastore
      65: aload_2
      66: aastore
      67: aload_1
      68: iconst_1
      69: bipush        10
      71: newarray       int
      73: astore_2
      74: aload_2
      75: iconst_0
      76: bipush        7
      78: iastore
      79: aload_2
      80: iconst_1
      81: iconst_1
      82: iastore
      83: aload_2
      84: iconst_2
      85: iconst_2
      86: iastore
      87: aload_2
      88: iconst_3
      89: iconst_4
      90: iastore
      91: aload_2
      92: iconst_4
      93: iconst_2
      94: iastore
      95: aload_2
      96: iconst_5
      97: iconst_3
      98: iastore
      99: aload_2
     100: bipush        6
     102: iconst_5
     103: iastore
     104: aload_2
     105: bipush        7
     107: iconst_4
     108: iastore
     109: aload_2
     110: bipush        8
     112: iconst_5
     113: iastore
     114: aload_2
     115: bipush        9
     117: bipush        6
     119: iastore
     120: aload_2
     121: aastore
     122: aload_1
     123: iconst_2
     124: bipush        10
     126: newarray       int
     128: astore_2
     129: aload_2
     130: iconst_0
     131: bipush        6
     133: iastore
     134: aload_2
     135: iconst_1
     136: iconst_2
     137: iastore
     138: aload_2
     139: iconst_2
     140: iconst_1
     141: iastore
     142: aload_2
     143: iconst_3
     144: iconst_2
     145: iastore
     146: aload_2
     147: iconst_4
     148: iconst_3
     149: iastore
     150: aload_2
     151: iconst_5
     152: iconst_2
     153: iastore
     154: aload_2
     155: bipush        6
     157: iconst_3
     158: iastore
     159: aload_2
     160: bipush        7
     162: iconst_5
     163: iastore
     164: aload_2
     165: bipush        8
     167: iconst_4
     168: iastore
     169: aload_2
     170: bipush        9
     172: iconst_5
     173: iastore
     174: aload_2
     175: aastore
     176: aload_1
     177: iconst_3
     178: bipush        10
     180: newarray       int
     182: astore_2
     183: aload_2
     184: iconst_0
     185: bipush        7
     187: iastore
     188: aload_2
     189: iconst_1
     190: iconst_4
     191: iastore
     192: aload_2
     193: iconst_2
     194: iconst_2
     195: iastore
     196: aload_2
     197: iconst_3
     198: iconst_1
     199: iastore
     200: aload_2
     201: iconst_4
     202: iconst_5
     203: iastore
     204: aload_2
     205: iconst_5
     206: iconst_3
     207: iastore
     208: aload_2
     209: bipush        6
     211: iconst_2
     212: iastore
     213: aload_2
     214: bipush        7
     216: bipush        6
     218: iastore
     219: aload_2
     220: bipush        8
     222: iconst_5
     223: iastore
     224: aload_2
     225: bipush        9
     227: iconst_4
     228: iastore
     229: aload_2
     230: aastore
     231: aload_1
     232: iconst_4
     233: bipush        10
     235: newarray       int
     237: astore_2
     238: aload_2
     239: iconst_0
     240: iconst_5
     241: iastore
     242: aload_2
     243: iconst_1
     244: iconst_2
     245: iastore
     246: aload_2
     247: iconst_2
     248: iconst_3
     249: iastore
     250: aload_2
     251: iconst_3
     252: iconst_5
     253: iastore
     254: aload_2
     255: iconst_4
     256: iconst_1
     257: iastore
     258: aload_2
     259: iconst_5
     260: iconst_2
     261: iastore
     262: aload_2
     263: bipush        6
     265: iconst_4
     266: iastore
     267: aload_2
     268: bipush        7
     270: iconst_2
     271: iastore
     272: aload_2
     273: bipush        8
     275: iconst_3
     276: iastore
     277: aload_2
     278: bipush        9
     280: iconst_5
     281: iastore
     282: aload_2
     283: aastore
     284: aload_1
     285: iconst_5
     286: bipush        10
     288: newarray       int
     290: astore_2
     291: aload_2
     292: iconst_0
     293: iconst_4
     294: iastore
     295: aload_2
     296: iconst_1
     297: iconst_3
     298: iastore
     299: aload_2
     300: iconst_2
     301: iconst_2
     302: iastore
     303: aload_2
     304: iconst_3
     305: iconst_3
     306: iastore
     307: aload_2
     308: iconst_4
     309: iconst_2
     310: iastore
     311: aload_2
     312: iconst_5
     313: iconst_1
     314: iastore
     315: aload_2
     316: bipush        6
     318: iconst_2
     319: iastore
     320: aload_2
     321: bipush        7
     323: iconst_3
     324: iastore
     325: aload_2
     326: bipush        8
     328: iconst_2
     329: iastore
     330: aload_2
     331: bipush        9
     333: iconst_3
     334: iastore
     335: aload_2
     336: aastore
     337: aload_1
     338: bipush        6
     340: bipush        10
     342: newarray       int
     344: astore_2
     345: aload_2
     346: iconst_0
     347: iconst_5
     348: iastore
     349: aload_2
     350: iconst_1
     351: iconst_5
     352: iastore
     353: aload_2
     354: iconst_2
     355: iconst_3
     356: iastore
     357: aload_2
     358: iconst_3
     359: iconst_2
     360: iastore
     361: aload_2
     362: iconst_4
     363: iconst_4
     364: iastore
     365: aload_2
     366: iconst_5
     367: iconst_2
     368: iastore
     369: aload_2
     370: bipush        6
     372: iconst_1
     373: iastore
     374: aload_2
     375: bipush        7
     377: iconst_5
     378: iastore
     379: aload_2
     380: bipush        8
     382: iconst_3
     383: iastore
     384: aload_2
     385: bipush        9
     387: iconst_2
     388: iastore
     389: aload_2
     390: aastore
     391: aload_1
     392: bipush        7
     394: bipush        10
     396: newarray       int
     398: astore_2
     399: aload_2
     400: iconst_0
     401: iconst_3
     402: iastore
     403: aload_2
     404: iconst_1
     405: iconst_4
     406: iastore
     407: aload_2
     408: iconst_2
     409: iconst_5
     410: iastore
     411: aload_2
     412: iconst_3
     413: bipush        6
     415: iastore
     416: aload_2
     417: iconst_4
     418: iconst_2
     419: iastore
     420: aload_2
     421: iconst_5
     422: iconst_3
     423: iastore
     424: aload_2
     425: bipush        6
     427: iconst_5
     428: iastore
     429: aload_2
     430: bipush        7
     432: iconst_1
     433: iastore
     434: aload_2
     435: bipush        8
     437: iconst_2
     438: iastore
     439: aload_2
     440: bipush        9
     442: iconst_4
     443: iastore
     444: aload_2
     445: aastore
     446: aload_1
     447: bipush        8
     449: bipush        10
     451: newarray       int
     453: astore_2
     454: aload_2
     455: iconst_0
     456: iconst_2
     457: iastore
     458: aload_2
     459: iconst_1
     460: iconst_5
     461: iastore
     462: aload_2
     463: iconst_2
     464: iconst_4
     465: iastore
     466: aload_2
     467: iconst_3
     468: iconst_5
     469: iastore
     470: aload_2
     471: iconst_4
     472: iconst_3
     473: iastore
     474: aload_2
     475: iconst_5
     476: iconst_2
     477: iastore
     478: aload_2
     479: bipush        6
     481: iconst_3
     482: iastore
     483: aload_2
     484: bipush        7
     486: iconst_2
     487: iastore
     488: aload_2
     489: bipush        8
     491: iconst_1
     492: iastore
     493: aload_2
     494: bipush        9
     496: iconst_2
     497: iastore
     498: aload_2
     499: aastore
     500: aload_1
     501: bipush        9
     503: bipush        10
     505: newarray       int
     507: astore_2
     508: aload_2
     509: iconst_0
     510: iconst_3
     511: iastore
     512: aload_2
     513: iconst_1
     514: bipush        6
     516: iastore
     517: aload_2
     518: iconst_2
     519: iconst_5
     520: iastore
     521: aload_2
     522: iconst_3
     523: iconst_4
     524: iastore
     525: aload_2
     526: iconst_4
     527: iconst_5
     528: iastore
     529: aload_2
     530: iconst_5
     531: iconst_3
     532: iastore
     533: aload_2
     534: bipush        6
     536: iconst_2
     537: iastore
     538: aload_2
     539: bipush        7
     541: iconst_4
     542: iastore
     543: aload_2
     544: bipush        8
     546: iconst_2
     547: iastore
     548: aload_2
     549: bipush        9
     551: iconst_1
     552: iastore
     553: aload_2
     554: aastore
     555: aload_1
     556: putfield      #14                 // Field costs:[[I
     559: return

  public final int solution(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #21                 // String numbers
       3: invokestatic  #27                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_3
       8: aload_1
       9: invokevirtual #33                 // Method java/lang/String.length:()I
      12: istore        4
      14: iload         4
      16: anewarray     #34                 // class "[[I"
      19: astore        5
      21: iload_3
      22: iload         4
      24: if_icmpge     125
      27: iload_3
      28: istore        6
      30: aload         5
      32: iload         6
      34: iconst_0
      35: istore        7
      37: bipush        10
      39: anewarray     #10                 // class "[I"
      42: astore        8
      44: istore        14
      46: astore        13
      48: iload         7
      50: bipush        10
      52: if_icmpge     112
      55: iload         7
      57: istore        9
      59: aload         8
      61: iload         9
      63: iconst_0
      64: istore        10
      66: bipush        10
      68: newarray       int
      70: astore        11
      72: istore        16
      74: astore        15
      76: iload         10
      78: bipush        10
      80: if_icmpge     99
      83: iload         10
      85: istore        12
      87: aload         11
      89: iload         12
      91: iconst_m1
      92: iastore
      93: iinc          10, 1
      96: goto          76
      99: aload         15
     101: iload         16
     103: aload         11
     105: aastore
     106: iinc          7, 1
     109: goto          48
     112: aload         13
     114: iload         14
     116: aload         8
     118: aastore
     119: iinc          3, 1
     122: goto          21
     125: aload         5
     127: astore_2
     128: aload_0
     129: aload_1
     130: iconst_0
     131: aload_2
     132: iconst_4
     133: bipush        6
     135: invokespecial #38                 // Method f:(Ljava/lang/String;I[[[III)I
     138: ireturn

  private final int f(java.lang.String, int, int[][][], int, int);
    Code:
       0: iload_2
       1: aload_1
       2: invokevirtual #33                 // Method java/lang/String.length:()I
       5: if_icmpne     10
       8: iconst_0
       9: ireturn
      10: aload_3
      11: iload_2
      12: aaload
      13: iload         4
      15: aaload
      16: iload         5
      18: iaload
      19: iconst_m1
      20: if_icmpeq     33
      23: aload_3
      24: iload_2
      25: aaload
      26: iload         4
      28: aaload
      29: iload         5
      31: iaload
      32: ireturn
      33: aload_1
      34: iload_2
      35: invokevirtual #46                 // Method java/lang/String.charAt:(I)C
      38: bipush        48
      40: isub
      41: istore        6
      43: ldc           #47                 // int 2147483647
      45: istore        7
      47: iload         6
      49: iload         5
      51: if_icmpeq     89
      54: aload_0
      55: getfield      #14                 // Field costs:[[I
      58: iload         4
      60: aaload
      61: iload         6
      63: iaload
      64: aload_0
      65: aload_1
      66: iload_2
      67: iconst_1
      68: iadd
      69: aload_3
      70: iload         6
      72: iload         5
      74: invokespecial #38                 // Method f:(Ljava/lang/String;I[[[III)I
      77: iadd
      78: istore        8
      80: iload         7
      82: iload         8
      84: invokestatic  #53                 // Method java/lang/Math.min:(II)I
      87: istore        7
      89: iload         6
      91: iload         4
      93: if_icmpeq     131
      96: aload_0
      97: getfield      #14                 // Field costs:[[I
     100: iload         5
     102: aaload
     103: iload         6
     105: iaload
     106: aload_0
     107: aload_1
     108: iload_2
     109: iconst_1
     110: iadd
     111: aload_3
     112: iload         4
     114: iload         6
     116: invokespecial #38                 // Method f:(Ljava/lang/String;I[[[III)I
     119: iadd
     120: istore        8
     122: iload         7
     124: iload         8
     126: invokestatic  #53                 // Method java/lang/Math.min:(II)I
     129: istore        7
     131: aload_3
     132: iload_2
     133: aaload
     134: iload         4
     136: aaload
     137: iload         5
     139: iload         7
     141: iastore
     142: iload         7
     144: ireturn
}


package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/253
class P77485 {
    fun solution(rows: Int, columns: Int, queries: Array<IntArray>): IntArray {
        // 숫자 채우기
        var n = 1
        val box = Array(rows + 1) { Array(columns + 1) { 0 } }
        for (i in 1 until box.size) {
            for (j in 1 until box[i].size) {
                box[i][j] = n++
            }
        }
        // 회전
        return IntArray(queries.size) { i -> rotate(box, queries[i]) }
    }

    private fun rotate(box: Array<Array<Int>>, q: IntArray): Int {
        var min = Int.MAX_VALUE
        val tmp = box[q[0] + 1][q[1]]

        for (i in q[0] + 1..q[2]) {
            box[i][q[1]] = if (i < q[2]) box[i + 1][q[1]] else box[i][q[1] + 1]
            min = minOf(min, box[i][q[1]])
        }
        for (j in q[1] + 1..q[3]) {
            box[q[2]][j] = if (j < q[3]) box[q[2]][j + 1] else box[q[2] - 1][j]
            min = minOf(min, box[q[2]][j])
        }
        for (i in q[2] - 1 downTo q[0]) {
            box[i][q[3]] = if (i > q[0]) box[i - 1][q[3]] else box[i][q[3] - 1]
            min = minOf(min, box[i][q[3]])
        }
        for (j in q[3] - 1 downTo q[1]) {
            box[q[0]][j] = if (j > q[1]) box[q[0]][j - 1] else tmp
            min = minOf(min, box[q[0]][j])
        }
        return min
    }

}

Compiled from "P77485.kt"
public final class kr.co.programmers.P77485 {
  public kr.co.programmers.P77485();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int[] solution(int, int, int[][]);
    Code:
       0: aload_3
       1: ldc           #15                 // String queries
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_1
       7: istore        4
       9: iconst_0
      10: istore        6
      12: iload_1
      13: iconst_1
      14: iadd
      15: istore        7
      17: iload         7
      19: anewarray     #23                 // class "[Ljava/lang/Integer;"
      22: astore        8
      24: iload         6
      26: iload         7
      28: if_icmpge     97
      31: iload         6
      33: istore        9
      35: aload         8
      37: iload         9
      39: iconst_0
      40: istore        10
      42: iload_2
      43: iconst_1
      44: iadd
      45: istore        11
      47: iload         11
      49: anewarray     #25                 // class java/lang/Integer
      52: astore        12
      54: istore        15
      56: astore        14
      58: iload         10
      60: iload         11
      62: if_icmpge     84
      65: iload         10
      67: istore        13
      69: aload         12
      71: iload         13
      73: iconst_0
      74: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: aastore
      78: iinc          10, 1
      81: goto          58
      84: aload         14
      86: iload         15
      88: aload         12
      90: aastore
      91: iinc          6, 1
      94: goto          24
      97: aload         8
      99: astore        5
     101: iconst_1
     102: istore        6
     104: aload         5
     106: checkcast     #31                 // class "[Ljava/lang/Object;"
     109: arraylength
     110: istore        7
     112: iload         6
     114: iload         7
     116: if_icmpge     165
     119: iconst_1
     120: istore        8
     122: aload         5
     124: iload         6
     126: aaload
     127: arraylength
     128: istore        9
     130: iload         8
     132: iload         9
     134: if_icmpge     159
     137: aload         5
     139: iload         6
     141: aaload
     142: iload         8
     144: iload         4
     146: iinc          4, 1
     149: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     152: aastore
     153: iinc          8, 1
     156: goto          130
     159: iinc          6, 1
     162: goto          112
     165: iconst_0
     166: istore        6
     168: aload_3
     169: checkcast     #31                 // class "[Ljava/lang/Object;"
     172: arraylength
     173: istore        7
     175: iload         7
     177: newarray       int
     179: astore        8
     181: iload         6
     183: iload         7
     185: if_icmpge     213
     188: iload         6
     190: istore        9
     192: aload         8
     194: iload         9
     196: aload_0
     197: aload         5
     199: aload_3
     200: iload         9
     202: aaload
     203: invokespecial #35                 // Method rotate:([[Ljava/lang/Integer;[I)I
     206: iastore
     207: iinc          6, 1
     210: goto          181
     213: aload         8
     215: areturn

  private final int rotate(java.lang.Integer[][], int[]);
    Code:
       0: ldc           #49                 // int 2147483647
       2: istore_3
       3: aload_1
       4: aload_2
       5: iconst_0
       6: iaload
       7: iconst_1
       8: iadd
       9: aaload
      10: aload_2
      11: iconst_1
      12: iaload
      13: aaload
      14: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
      17: istore        4
      19: aload_2
      20: iconst_0
      21: iaload
      22: iconst_1
      23: iadd
      24: istore        5
      26: aload_2
      27: iconst_2
      28: iaload
      29: istore        6
      31: iload         5
      33: iload         6
      35: if_icmpgt     115
      38: aload_1
      39: iload         5
      41: aaload
      42: aload_2
      43: iconst_1
      44: iaload
      45: iload         5
      47: aload_2
      48: iconst_2
      49: iaload
      50: if_icmpge     69
      53: aload_1
      54: iload         5
      56: iconst_1
      57: iadd
      58: aaload
      59: aload_2
      60: iconst_1
      61: iaload
      62: aaload
      63: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
      66: goto          82
      69: aload_1
      70: iload         5
      72: aaload
      73: aload_2
      74: iconst_1
      75: iaload
      76: iconst_1
      77: iadd
      78: aaload
      79: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
      82: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      85: aastore
      86: iload_3
      87: aload_1
      88: iload         5
      90: aaload
      91: aload_2
      92: iconst_1
      93: iaload
      94: aaload
      95: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
      98: invokestatic  #59                 // Method java/lang/Math.min:(II)I
     101: istore_3
     102: iload         5
     104: iload         6
     106: if_icmpeq     115
     109: iinc          5, 1
     112: goto          38
     115: aload_2
     116: iconst_1
     117: iaload
     118: iconst_1
     119: iadd
     120: istore        5
     122: aload_2
     123: iconst_3
     124: iaload
     125: istore        6
     127: iload         5
     129: iload         6
     131: if_icmpgt     211
     134: aload_1
     135: aload_2
     136: iconst_2
     137: iaload
     138: aaload
     139: iload         5
     141: iload         5
     143: aload_2
     144: iconst_3
     145: iaload
     146: if_icmpge     165
     149: aload_1
     150: aload_2
     151: iconst_2
     152: iaload
     153: aaload
     154: iload         5
     156: iconst_1
     157: iadd
     158: aaload
     159: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
     162: goto          178
     165: aload_1
     166: aload_2
     167: iconst_2
     168: iaload
     169: iconst_1
     170: isub
     171: aaload
     172: iload         5
     174: aaload
     175: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
     178: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     181: aastore
     182: iload_3
     183: aload_1
     184: aload_2
     185: iconst_2
     186: iaload
     187: aaload
     188: iload         5
     190: aaload
     191: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
     194: invokestatic  #59                 // Method java/lang/Math.min:(II)I
     197: istore_3
     198: iload         5
     200: iload         6
     202: if_icmpeq     211
     205: iinc          5, 1
     208: goto          134
     211: aload_2
     212: iconst_2
     213: iaload
     214: iconst_1
     215: isub
     216: istore        5
     218: aload_2
     219: iconst_0
     220: iaload
     221: istore        6
     223: iload         6
     225: iload         5
     227: if_icmpgt     307
     230: aload_1
     231: iload         5
     233: aaload
     234: aload_2
     235: iconst_3
     236: iaload
     237: iload         5
     239: aload_2
     240: iconst_0
     241: iaload
     242: if_icmple     261
     245: aload_1
     246: iload         5
     248: iconst_1
     249: isub
     250: aaload
     251: aload_2
     252: iconst_3
     253: iaload
     254: aaload
     255: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
     258: goto          274
     261: aload_1
     262: iload         5
     264: aaload
     265: aload_2
     266: iconst_3
     267: iaload
     268: iconst_1
     269: isub
     270: aaload
     271: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
     274: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     277: aastore
     278: iload_3
     279: aload_1
     280: iload         5
     282: aaload
     283: aload_2
     284: iconst_3
     285: iaload
     286: aaload
     287: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
     290: invokestatic  #59                 // Method java/lang/Math.min:(II)I
     293: istore_3
     294: iload         5
     296: iload         6
     298: if_icmpeq     307
     301: iinc          5, -1
     304: goto          230
     307: aload_2
     308: iconst_3
     309: iaload
     310: iconst_1
     311: isub
     312: istore        5
     314: aload_2
     315: iconst_1
     316: iaload
     317: istore        6
     319: iload         6
     321: iload         5
     323: if_icmpgt     392
     326: aload_1
     327: aload_2
     328: iconst_0
     329: iaload
     330: aaload
     331: iload         5
     333: iload         5
     335: aload_2
     336: iconst_1
     337: iaload
     338: if_icmple     357
     341: aload_1
     342: aload_2
     343: iconst_0
     344: iaload
     345: aaload
     346: iload         5
     348: iconst_1
     349: isub
     350: aaload
     351: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
     354: goto          359
     357: iload         4
     359: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     362: aastore
     363: iload_3
     364: aload_1
     365: aload_2
     366: iconst_0
     367: iaload
     368: aaload
     369: iload         5
     371: aaload
     372: invokevirtual #53                 // Method java/lang/Integer.intValue:()I
     375: invokestatic  #59                 // Method java/lang/Math.min:(II)I
     378: istore_3
     379: iload         5
     381: iload         6
     383: if_icmpeq     392
     386: iinc          5, -1
     389: goto          326
     392: iload_3
     393: ireturn
}


package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/486
class P152995 {
    fun solution(scores: Array<IntArray>): Int {
        var rank = 1
        val me = scores[0]
        var maxScore = 0
        // 근무태도 내림차순 정렬.
        // 근무태도 동점인 경우 동료평가 오름차순 정렬
        scores.sortWith(Comparator { a, b ->
            if (a[0] == b[0]) a[1] - b[1] else b[0] - a[0]
        })

        // 두 점수의 합이 다른 점수의 합보다 크다면
        // 근무태도 또는 동료평가 둘 중 하나는 높다
        for (score in scores) {
            if (score[1] < maxScore) {
                if (score.contentEquals(me)) {
                    return -1
                }
            } else {
                maxScore = maxOf(maxScore, score[1])
                if (score[0] + score[1] > me[0] + me[1]) {
                    rank++
                }
            }
        }

        return rank
    }
}

Compiled from "P152995.kt"
public final class kr.co.programmers.P152995 {
  public kr.co.programmers.P152995();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int solution(int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String scores
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_1
       7: istore_2
       8: aload_1
       9: iconst_0
      10: aaload
      11: astore_3
      12: iconst_0
      13: istore        4
      15: aload_1
      16: checkcast     #23                 // class "[Ljava/lang/Object;"
      19: invokedynamic #42,  0             // InvokeDynamic #0:compare:()Ljava/util/Comparator;
      24: invokestatic  #48                 // Method kotlin/collections/ArraysKt.sortWith:([Ljava/lang/Object;Ljava/util/Comparator;)V
      27: iconst_0
      28: istore        5
      30: aload_1
      31: checkcast     #23                 // class "[Ljava/lang/Object;"
      34: arraylength
      35: istore        6
      37: iload         5
      39: iload         6
      41: if_icmpge     109
      44: aload_1
      45: iload         5
      47: aaload
      48: astore        7
      50: aload         7
      52: iconst_1
      53: iaload
      54: iload         4
      56: if_icmpge     70
      59: aload         7
      61: aload_3
      62: invokestatic  #54                 // Method java/util/Arrays.equals:([I[I)Z
      65: ifeq          103
      68: iconst_m1
      69: ireturn
      70: iload         4
      72: aload         7
      74: iconst_1
      75: iaload
      76: invokestatic  #60                 // Method java/lang/Math.max:(II)I
      79: istore        4
      81: aload         7
      83: iconst_0
      84: iaload
      85: aload         7
      87: iconst_1
      88: iaload
      89: iadd
      90: aload_3
      91: iconst_0
      92: iaload
      93: aload_3
      94: iconst_1
      95: iaload
      96: iadd
      97: if_icmple     103
     100: iinc          2, 1
     103: iinc          5, 1
     106: goto          37
     109: iload_2
     110: ireturn

  private static final int solution$lambda$0(int[], int[]);
    Code:
       0: aload_0
       1: iconst_0
       2: iaload
       3: aload_1
       4: iconst_0
       5: iaload
       6: if_icmpne     19
       9: aload_0
      10: iconst_1
      11: iaload
      12: aload_1
      13: iconst_1
      14: iaload
      15: isub
      16: goto          26
      19: aload_1
      20: iconst_0
      21: iaload
      22: aload_0
      23: iconst_0
      24: iaload
      25: isub
      26: ireturn
}


package kr.co.programmers

import kotlin.math.abs

// https://leetcode.com/problems/alphabet-board-path/
class P1138 {
    fun alphabetBoardPath(target: String): String {
        var moves = ""
        var p = intArrayOf(0, 0)
        for (s in target) {
            // 아스키 코드의 특성을 이용한다.
            val t = (s - 97).toInt().run { intArrayOf(div(5), rem(5)) }
            // Z에서 다른 곳으로 이동하는 경우라면 미리 위로 한칸 간다.
            if (p[0] == 5 && p[0] - t[0] > 0) {
                moves += 'U'
                p = intArrayOf(p[0] - 1, p[1])
            }
            // 왼쪽 또는 오른쪽으로 이동
            if (t[1] - p[1] != 0) {
                val c = if (t[1] > p[1]) 'R' else 'L'
                repeat(abs(p[1] - t[1])) {
                    moves += c
                }
            }
            // 위 또는 아래로 이동
            if (t[0] - p[0] != 0) {
                val c = if (t[0] > p[0]) 'D' else 'U'
                repeat(abs(p[0] - t[0])) {
                    moves += c
                }
            }
            // adds the character
            moves += "!"
            p = t
        }

        return moves
    }

}

Compiled from "P1138.kt"
public final class kr.co.programmers.P1138 {
  public kr.co.programmers.P1138();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.lang.String alphabetBoardPath(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #15                 // String target
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aconst_null
       7: astore_2
       8: ldc           #23                 // String
      10: astore_2
      11: iconst_2
      12: newarray       int
      14: astore        4
      16: aload         4
      18: iconst_0
      19: iconst_0
      20: iastore
      21: aload         4
      23: iconst_1
      24: iconst_0
      25: iastore
      26: aload         4
      28: astore_3
      29: iconst_0
      30: istore        4
      32: aload_1
      33: invokevirtual #29                 // Method java/lang/String.length:()I
      36: istore        5
      38: iload         4
      40: iload         5
      42: if_icmpge     355
      45: aload_1
      46: iload         4
      48: invokevirtual #33                 // Method java/lang/String.charAt:(I)C
      51: istore        6
      53: iload         6
      55: bipush        97
      57: isub
      58: i2c
      59: istore        9
      61: iconst_0
      62: istore        10
      64: iconst_2
      65: newarray       int
      67: astore        11
      69: aload         11
      71: iconst_0
      72: iload         9
      74: iconst_5
      75: idiv
      76: iastore
      77: aload         11
      79: iconst_1
      80: iload         9
      82: iconst_5
      83: irem
      84: iastore
      85: aload         11
      87: nop
      88: astore        7
      90: aload_3
      91: iconst_0
      92: iaload
      93: iconst_5
      94: if_icmpne     152
      97: aload_3
      98: iconst_0
      99: iaload
     100: aload         7
     102: iconst_0
     103: iaload
     104: isub
     105: ifle          152
     108: new           #35                 // class java/lang/StringBuilder
     111: dup
     112: invokespecial #36                 // Method java/lang/StringBuilder."<init>":()V
     115: aload_2
     116: invokevirtual #40                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     119: bipush        85
     121: invokevirtual #43                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     124: invokevirtual #47                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     127: astore_2
     128: iconst_2
     129: newarray       int
     131: astore        8
     133: aload         8
     135: iconst_0
     136: aload_3
     137: iconst_0
     138: iaload
     139: iconst_1
     140: isub
     141: iastore
     142: aload         8
     144: iconst_1
     145: aload_3
     146: iconst_1
     147: iaload
     148: iastore
     149: aload         8
     151: astore_3
     152: aload         7
     154: iconst_1
     155: iaload
     156: aload_3
     157: iconst_1
     158: iaload
     159: isub
     160: ifeq          239
     163: aload         7
     165: iconst_1
     166: iaload
     167: aload_3
     168: iconst_1
     169: iaload
     170: if_icmple     178
     173: bipush        82
     175: goto          180
     178: bipush        76
     180: istore        8
     182: aload_3
     183: iconst_1
     184: iaload
     185: aload         7
     187: iconst_1
     188: iaload
     189: isub
     190: invokestatic  #53                 // Method java/lang/Math.abs:(I)I
     193: istore        9
     195: iconst_0
     196: istore        10
     198: iload         10
     200: iload         9
     202: if_icmpge     239
     205: iload         10
     207: istore        11
     209: iconst_0
     210: istore        12
     212: new           #35                 // class java/lang/StringBuilder
     215: dup
     216: invokespecial #36                 // Method java/lang/StringBuilder."<init>":()V
     219: aload_2
     220: invokevirtual #40                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     223: iload         8
     225: invokevirtual #43                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     228: invokevirtual #47                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     231: astore_2
     232: nop
     233: iinc          10, 1
     236: goto          198
     239: aload         7
     241: iconst_0
     242: iaload
     243: aload_3
     244: iconst_0
     245: iaload
     246: isub
     247: ifeq          326
     250: aload         7
     252: iconst_0
     253: iaload
     254: aload_3
     255: iconst_0
     256: iaload
     257: if_icmple     265
     260: bipush        68
     262: goto          267
     265: bipush        85
     267: istore        8
     269: aload_3
     270: iconst_0
     271: iaload
     272: aload         7
     274: iconst_0
     275: iaload
     276: isub
     277: invokestatic  #53                 // Method java/lang/Math.abs:(I)I
     280: istore        9
     282: iconst_0
     283: istore        10
     285: iload         10
     287: iload         9
     289: if_icmpge     326
     292: iload         10
     294: istore        11
     296: iconst_0
     297: istore        12
     299: new           #35                 // class java/lang/StringBuilder
     302: dup
     303: invokespecial #36                 // Method java/lang/StringBuilder."<init>":()V
     306: aload_2
     307: invokevirtual #40                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     310: iload         8
     312: invokevirtual #43                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     315: invokevirtual #47                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     318: astore_2
     319: nop
     320: iinc          10, 1
     323: goto          285
     326: new           #35                 // class java/lang/StringBuilder
     329: dup
     330: invokespecial #36                 // Method java/lang/StringBuilder."<init>":()V
     333: aload_2
     334: invokevirtual #40                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     337: bipush        33
     339: invokevirtual #43                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     342: invokevirtual #47                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     345: astore_2
     346: aload         7
     348: astore_3
     349: iinc          4, 1
     352: goto          38
     355: aload_2
     356: areturn
}


package kr.co.programmers

// https://github.com/antop-dev/algorithm/issues/506
class P160585 {
    fun solution(board: Array<String>): Int {
        val (oCount, oWin) = check(board, 'O')
        val (xCount, xWin) = check(board, 'X')
        return when {
            // "O"나 "X"의 개수 차이가 나면 안된다.
            oCount - xCount > 1 || xCount > oCount -> 0
            // "O"와 "X"의 개수가 같을 때, 무승부 이거나 후공인 "X"가 이겨야 된다.
            oCount == xCount && ((oWin == 0 && xWin == 0) || (oWin == 0 && xWin > 0)) -> 1
            // "O"가 "X"보다 1개만 더 많을 때, 무승부 이거나 선공인 "O"가 이겨야 된다.
            oCount > xCount && ((oWin == 0 && xWin == 0) || (oWin > 0 && xWin == 0)) -> 1
            // 나머지 경우는 비정상적인 게임
            else -> 0
        }
    }

    private fun check(b: Array<String>, ch: Char): IntArray {
        val check = intArrayOf(0, 0)
        // 개수
        for (i in 0 until 3) {
            for (j in 0 until 3) {
                if (b[i][j] == ch) {
                    check[0]++
                }
            }
        }
        // 가로줄
        if (b[0][0] == ch && b[0][1] == ch && b[0][2] == ch) check[1]++
        if (b[1][0] == ch && b[1][1] == ch && b[1][2] == ch) check[1]++
        if (b[2][0] == ch && b[2][1] == ch && b[2][2] == ch) check[1]++
        // 세로중
        if (b[0][0] == ch && b[1][0] == ch && b[2][0] == ch) check[1]++
        if (b[0][1] == ch && b[1][1] == ch && b[2][1] == ch) check[1]++
        if (b[0][2] == ch && b[1][2] == ch && b[2][2] == ch) check[1]++
        // 대각선
        if (b[0][0] == ch && b[1][1] == ch && b[2][2] == ch) check[1]++
        if (b[0][2] == ch && b[1][1] == ch && b[2][0] == ch) check[1]++

        return check
    }
}

Compiled from "P160585.kt"
public final class kr.co.programmers.P160585 {
  public kr.co.programmers.P160585();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int solution(java.lang.String[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String board
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: bipush        79
      10: invokespecial #25                 // Method check:([Ljava/lang/String;C)[I
      13: astore_2
      14: aload_2
      15: iconst_0
      16: iaload
      17: istore_3
      18: aload_2
      19: iconst_1
      20: iaload
      21: istore        4
      23: aload_0
      24: aload_1
      25: bipush        88
      27: invokespecial #25                 // Method check:([Ljava/lang/String;C)[I
      30: astore        5
      32: aload         5
      34: iconst_0
      35: iaload
      36: istore        6
      38: aload         5
      40: iconst_1
      41: iaload
      42: istore        7
      44: nop
      45: iload_3
      46: iload         6
      48: isub
      49: iconst_1
      50: if_icmpgt     59
      53: iload         6
      55: iload_3
      56: if_icmple     63
      59: iconst_0
      60: goto          124
      63: iload_3
      64: iload         6
      66: if_icmpne     93
      69: iload         4
      71: ifne          79
      74: iload         7
      76: ifeq          89
      79: iload         4
      81: ifne          93
      84: iload         7
      86: ifle          93
      89: iconst_1
      90: goto          124
      93: iload_3
      94: iload         6
      96: if_icmple     123
      99: iload         4
     101: ifne          109
     104: iload         7
     106: ifeq          119
     109: iload         4
     111: ifle          123
     114: iload         7
     116: ifne          123
     119: iconst_1
     120: goto          124
     123: iconst_0
     124: ireturn

  private final int[] check(java.lang.String[], char);
    Code:
       0: iconst_2
       1: newarray       int
       3: astore        4
       5: aload         4
       7: iconst_0
       8: iconst_0
       9: iastore
      10: aload         4
      12: iconst_1
      13: iconst_0
      14: iastore
      15: aload         4
      17: astore_3
      18: iconst_0
      19: istore        4
      21: iload         4
      23: iconst_3
      24: if_icmpge     73
      27: iconst_0
      28: istore        5
      30: iload         5
      32: iconst_3
      33: if_icmpge     67
      36: aload_1
      37: iload         4
      39: aaload
      40: iload         5
      42: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
      45: iload_2
      46: if_icmpne     61
      49: aload_3
      50: iconst_0
      51: iaload
      52: istore        6
      54: aload_3
      55: iconst_0
      56: iload         6
      58: iconst_1
      59: iadd
      60: iastore
      61: iinc          5, 1
      64: goto          30
      67: iinc          4, 1
      70: goto          21
      73: aload_1
      74: iconst_0
      75: aaload
      76: iconst_0
      77: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
      80: iload_2
      81: if_icmpne     118
      84: aload_1
      85: iconst_0
      86: aaload
      87: iconst_1
      88: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
      91: iload_2
      92: if_icmpne     118
      95: aload_1
      96: iconst_0
      97: aaload
      98: iconst_2
      99: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     102: iload_2
     103: if_icmpne     118
     106: aload_3
     107: iconst_1
     108: iaload
     109: istore        4
     111: aload_3
     112: iconst_1
     113: iload         4
     115: iconst_1
     116: iadd
     117: iastore
     118: aload_1
     119: iconst_1
     120: aaload
     121: iconst_0
     122: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     125: iload_2
     126: if_icmpne     163
     129: aload_1
     130: iconst_1
     131: aaload
     132: iconst_1
     133: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     136: iload_2
     137: if_icmpne     163
     140: aload_1
     141: iconst_1
     142: aaload
     143: iconst_2
     144: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     147: iload_2
     148: if_icmpne     163
     151: aload_3
     152: iconst_1
     153: iaload
     154: istore        4
     156: aload_3
     157: iconst_1
     158: iload         4
     160: iconst_1
     161: iadd
     162: iastore
     163: aload_1
     164: iconst_2
     165: aaload
     166: iconst_0
     167: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     170: iload_2
     171: if_icmpne     208
     174: aload_1
     175: iconst_2
     176: aaload
     177: iconst_1
     178: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     181: iload_2
     182: if_icmpne     208
     185: aload_1
     186: iconst_2
     187: aaload
     188: iconst_2
     189: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     192: iload_2
     193: if_icmpne     208
     196: aload_3
     197: iconst_1
     198: iaload
     199: istore        4
     201: aload_3
     202: iconst_1
     203: iload         4
     205: iconst_1
     206: iadd
     207: iastore
     208: aload_1
     209: iconst_0
     210: aaload
     211: iconst_0
     212: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     215: iload_2
     216: if_icmpne     253
     219: aload_1
     220: iconst_1
     221: aaload
     222: iconst_0
     223: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     226: iload_2
     227: if_icmpne     253
     230: aload_1
     231: iconst_2
     232: aaload
     233: iconst_0
     234: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     237: iload_2
     238: if_icmpne     253
     241: aload_3
     242: iconst_1
     243: iaload
     244: istore        4
     246: aload_3
     247: iconst_1
     248: iload         4
     250: iconst_1
     251: iadd
     252: iastore
     253: aload_1
     254: iconst_0
     255: aaload
     256: iconst_1
     257: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     260: iload_2
     261: if_icmpne     298
     264: aload_1
     265: iconst_1
     266: aaload
     267: iconst_1
     268: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     271: iload_2
     272: if_icmpne     298
     275: aload_1
     276: iconst_2
     277: aaload
     278: iconst_1
     279: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     282: iload_2
     283: if_icmpne     298
     286: aload_3
     287: iconst_1
     288: iaload
     289: istore        4
     291: aload_3
     292: iconst_1
     293: iload         4
     295: iconst_1
     296: iadd
     297: iastore
     298: aload_1
     299: iconst_0
     300: aaload
     301: iconst_2
     302: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     305: iload_2
     306: if_icmpne     343
     309: aload_1
     310: iconst_1
     311: aaload
     312: iconst_2
     313: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     316: iload_2
     317: if_icmpne     343
     320: aload_1
     321: iconst_2
     322: aaload
     323: iconst_2
     324: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     327: iload_2
     328: if_icmpne     343
     331: aload_3
     332: iconst_1
     333: iaload
     334: istore        4
     336: aload_3
     337: iconst_1
     338: iload         4
     340: iconst_1
     341: iadd
     342: iastore
     343: aload_1
     344: iconst_0
     345: aaload
     346: iconst_0
     347: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     350: iload_2
     351: if_icmpne     388
     354: aload_1
     355: iconst_1
     356: aaload
     357: iconst_1
     358: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     361: iload_2
     362: if_icmpne     388
     365: aload_1
     366: iconst_2
     367: aaload
     368: iconst_2
     369: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     372: iload_2
     373: if_icmpne     388
     376: aload_3
     377: iconst_1
     378: iaload
     379: istore        4
     381: aload_3
     382: iconst_1
     383: iload         4
     385: iconst_1
     386: iadd
     387: iastore
     388: aload_1
     389: iconst_0
     390: aaload
     391: iconst_2
     392: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     395: iload_2
     396: if_icmpne     433
     399: aload_1
     400: iconst_1
     401: aaload
     402: iconst_1
     403: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     406: iload_2
     407: if_icmpne     433
     410: aload_1
     411: iconst_2
     412: aaload
     413: iconst_0
     414: invokevirtual #40                 // Method java/lang/String.charAt:(I)C
     417: iload_2
     418: if_icmpne     433
     421: aload_3
     422: iconst_1
     423: iaload
     424: istore        4
     426: aload_3
     427: iconst_1
     428: iload         4
     430: iconst_1
     431: iadd
     432: iastore
     433: aload_3
     434: areturn
}