From 7985dd6fd04bb2bc0d6f473160a644e01f2bb573 Mon Sep 17 00:00:00 2001 From: beom84 Date: Mon, 18 Nov 2024 15:54:00 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98=EB=A8=B8?= =?UTF-8?q?=EC=8A=A4=5FLv1=5F=EC=84=B1=EA=B2=A9=EC=9C=A0=ED=98=95=EA=B2=80?= =?UTF-8?q?=EC=82=AC=ED=95=98=EA=B8=B0=5F=EC=9D=B4=EC=8A=B9=EB=B2=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seungbum/.DS_Store | Bin 8196 -> 8196 bytes ...00\354\202\254\355\225\230\352\270\260.kt" | 47 ++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 "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" diff --git a/seungbum/.DS_Store b/seungbum/.DS_Store index 55bd8bdc99fc2ee81b949986f395c5e614332fdc..ce800785374d2bd661b6590163ebe507223cf81c 100644 GIT binary patch delta 631 zcmZp1XmOa}&n?2hz`)4BAi%(2xG`!YzcPr=%23Xb3WV7VhMqb3$w@i+NkCDc5=L1d ztv6XuKy0&=fIM?NLZLC5!fuel|6l-QAscCerZN;L`wqLx$u0to!bS!<3Z@1YwK@vb zmLRr?vDxGs0=D%gIq8PM$@#ejVDlja!aXLr`7SO{hjU!`9U=Op;Fu$-J96_=2&gE? zz-Mccc9#93sdDvCJoVT%XJL6_{iEk|8*u!EFIdlsn E03M~85dZ)H delta 257 zcmZp1XmOa}&&|WYz`)4BAi%(2v@vQUKO@g(GXY)ZdM-gW!8}18!88U1K|#Sx!S#a7 zf~lT4`N>H+`AI-6K=ll_fI4~pg8`7oz<^axPP$=ma(-?BSOtW@sxCL*#RY0MNAL5X qr(1+Gk2&HpG&es5Nilx41sM% 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)) +}