diff --git a/seungbum/.DS_Store b/seungbum/.DS_Store index 55bd8bd..ce80078 100644 Binary files a/seungbum/.DS_Store and b/seungbum/.DS_Store differ diff --git "a/seungbum/week5/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244_Lv1_\354\204\261\352\262\251\354\234\240\355\230\225\352\262\200\354\202\254\355\225\230\352\270\260.kt" "b/seungbum/week5/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244_Lv1_\354\204\261\352\262\251\354\234\240\355\230\225\352\262\200\354\202\254\355\225\230\352\270\260.kt" new file mode 100644 index 0000000..b2d37a6 --- /dev/null +++ "b/seungbum/week5/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244_Lv1_\354\204\261\352\262\251\354\234\240\355\230\225\352\262\200\354\202\254\355\225\230\352\270\260.kt" @@ -0,0 +1,47 @@ +package koala.programmers + +fun solution(survey: Array, choices: IntArray): String { + val personalType = mutableMapOf( + "R" to 0, "T" to 0, + "C" to 0, "F" to 0, + "J" to 0, "M" to 0, + "A" to 0, "N" to 0 + ) + + for (i in choices.indices) { + val choice = choices[i] + when { + (choice == 4) -> + continue + + (choice < 4) -> + personalType[survey[i][0].toString()] = personalType[survey[i][0].toString()]!! + (4 - choice) + + else -> + personalType[survey[i][1].toString()] = personalType[survey[i][1].toString()]!! + choice - 4 + } + } + val answer = buildString { + append(if (personalType["R"]!! < personalType["T"]!!) "T" else "R") + append(if (personalType["C"]!! < personalType["F"]!!) "F" else "C") + append(if (personalType["J"]!! < personalType["M"]!!) "M" else "J") + append(if (personalType["A"]!! < personalType["N"]!!) "N" else "A") + } + return answer +} + +fun main() { + // Array for survey choices + val surveyChoices: Array = arrayOf("AN", "CF", "MJ", "RT", "NA") + val surveyChoices2: Array = arrayOf("TR", "RT", "TR") + + + // IntArray for results + val surveyResults: IntArray = intArrayOf(5, 3, 2, 7, 5) + val surveyResults2: IntArray = intArrayOf(7, 1, 3) + + + val result = solution(surveyChoices, surveyResults) + + print(solution(surveyChoices2,surveyResults2)) +}