From c022b46ab6d2f69b057edbc7b66e0a3e176139b6 Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Mon, 26 Dec 2022 00:24:21 +0900 Subject: [PATCH 1/7] =?UTF-8?q?update:=20=EC=95=88=EB=85=95,=20=ED=8A=B8?= =?UTF-8?q?=EB=9F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/heejik/12week/\354\225\210\353\205\225.kt" | 2 -- .../main/kotlin/heejik/12week/\355\212\270\353\237\255.kt" | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git "a/src/main/kotlin/heejik/12week/\354\225\210\353\205\225.kt" "b/src/main/kotlin/heejik/12week/\354\225\210\353\205\225.kt" index e41867d9..b596f147 100644 --- "a/src/main/kotlin/heejik/12week/\354\225\210\353\205\225.kt" +++ "b/src/main/kotlin/heejik/12week/\354\225\210\353\205\225.kt" @@ -10,8 +10,6 @@ class 안녕 { ) fun solve() { - var hp = 100 - var happy = 0 val n = readln().toInt() val l = readln().split(' ').map { it.toInt() } val j = readln().split(' ').map { it.toInt() } diff --git "a/src/main/kotlin/heejik/12week/\355\212\270\353\237\255.kt" "b/src/main/kotlin/heejik/12week/\355\212\270\353\237\255.kt" index 1da38a6c..bb616db2 100644 --- "a/src/main/kotlin/heejik/12week/\355\212\270\353\237\255.kt" +++ "b/src/main/kotlin/heejik/12week/\355\212\270\353\237\255.kt" @@ -2,6 +2,10 @@ package heejik.`12week` class 트럭 { + data class Truck( + val weight: Int, var time: Int + ) + fun solve() { val (n, w, l) = readln().split(' ').map { it.toInt() } val trucks = readln().split(' ').map { it.toInt() }.toMutableList() @@ -24,9 +28,6 @@ class 트럭 { } } -data class Truck( - val weight: Int, var time: Int -) fun main() { 트럭().solve() From 0c9312f50b6867c9cfb1894a8c9c9dc532204f80 Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Sun, 1 Jan 2023 11:53:47 +0900 Subject: [PATCH 2/7] solve: DNA --- src/main/kotlin/heejik/13week/DNA.kt | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/kotlin/heejik/13week/DNA.kt diff --git a/src/main/kotlin/heejik/13week/DNA.kt b/src/main/kotlin/heejik/13week/DNA.kt new file mode 100644 index 00000000..a16855ad --- /dev/null +++ b/src/main/kotlin/heejik/13week/DNA.kt @@ -0,0 +1,38 @@ +package heejik.`13week` + +import java.lang.Integer.max + + +class DNA { + + fun solve() { + + var answerDna = "" + var answerCnt = 0 + + val (n, m) = readln().split(' ').map { it.toInt() } + + val dnaList = mutableListOf() + + repeat(n) { dnaList.add(readln()) } + + repeat(m) { + var dnaByIdx = "" + dnaList.forEach { dna -> dnaByIdx += dna[it] } + + var maxCnt = 0 + "ACGT".forEach { c -> maxCnt = max(maxCnt, dnaByIdx.count { c == it }) } + + answerDna += dnaByIdx.filter { c -> maxCnt == dnaByIdx.count { c == it } }.min() + answerCnt += dnaByIdx.count { it != answerDna.last() } + } + + println(answerDna) + println(answerCnt) + } +} + +fun main() { + + DNA().solve() +} \ No newline at end of file From 58badb516140ab1dd957ccee0ad3c59abb829db5 Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Sun, 1 Jan 2023 11:53:58 +0900 Subject: [PATCH 3/7] =?UTF-8?q?solve:=20=EB=93=B1=EC=88=98=20=EA=B5=AC?= =?UTF-8?q?=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \352\265\254\355\225\230\352\270\260.kt" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "src/main/kotlin/heejik/13week/\353\223\261\354\210\230 \352\265\254\355\225\230\352\270\260.kt" diff --git "a/src/main/kotlin/heejik/13week/\353\223\261\354\210\230 \352\265\254\355\225\230\352\270\260.kt" "b/src/main/kotlin/heejik/13week/\353\223\261\354\210\230 \352\265\254\355\225\230\352\270\260.kt" new file mode 100644 index 00000000..fd580258 --- /dev/null +++ "b/src/main/kotlin/heejik/13week/\353\223\261\354\210\230 \352\265\254\355\225\230\352\270\260.kt" @@ -0,0 +1,26 @@ +package heejik.`13week` + +class `등수 구하기` { + + fun solve() { + val (n, score, p) = readln().split(' ').map { it.toInt() } + + if (n == 0) { + println(1) + return + } + val scores = readln().split(' ').map { it.toInt() }.toMutableList() + + scores.sort() + + if (scores.count { it >= score } >= p) { + println(-1) + } else { + println(scores.count { it > score } + 1) + } + } +} + +fun main() { + `등수 구하기`().solve() +} \ No newline at end of file From b82e43ec186bb93a95cccf0dddfdb2e5b9b183ac Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Sun, 1 Jan 2023 11:54:06 +0900 Subject: [PATCH 4/7] =?UTF-8?q?solve:=20=EC=88=98=20=EC=9D=B4=EC=96=B4=20?= =?UTF-8?q?=EC=93=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354\226\264 \354\223\260\352\270\260 1.kt" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "src/main/kotlin/heejik/13week/\354\210\230 \354\235\264\354\226\264 \354\223\260\352\270\260 1.kt" diff --git "a/src/main/kotlin/heejik/13week/\354\210\230 \354\235\264\354\226\264 \354\223\260\352\270\260 1.kt" "b/src/main/kotlin/heejik/13week/\354\210\230 \354\235\264\354\226\264 \354\223\260\352\270\260 1.kt" new file mode 100644 index 00000000..44e61bab --- /dev/null +++ "b/src/main/kotlin/heejik/13week/\354\210\230 \354\235\264\354\226\264 \354\223\260\352\270\260 1.kt" @@ -0,0 +1,29 @@ +package heejik.`13week` + +class `수 이어 쓰기 1` { + + fun solve() { + val n = readln().toInt() + var answer = 0 + + repeat(n) { + answer += getDigit(it+1) + } + + println(answer) + } + + private fun getDigit(_num : Int): Int { + var num = _num + var cnt = 0 + while (num != 0) { + num /= 10 + cnt ++ + } + return cnt + } +} + +fun main() { + `수 이어 쓰기 1`().solve() +} \ No newline at end of file From 926efaf828a62f973cbdf60b6648166f0300ad75 Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Sun, 1 Jan 2023 11:54:13 +0900 Subject: [PATCH 5/7] =?UTF-8?q?solve:=20=EC=8B=9C=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../13week/\354\213\234\352\263\204.kt" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "src/main/kotlin/heejik/13week/\354\213\234\352\263\204.kt" diff --git "a/src/main/kotlin/heejik/13week/\354\213\234\352\263\204.kt" "b/src/main/kotlin/heejik/13week/\354\213\234\352\263\204.kt" new file mode 100644 index 00000000..8b03de81 --- /dev/null +++ "b/src/main/kotlin/heejik/13week/\354\213\234\352\263\204.kt" @@ -0,0 +1,45 @@ +package heejik.`13week` + +class 시계 { + + val nums = listOf( + "####.##.##.####", // 0 + "..#..#..#..#..#", // 1 + "###..#####..###", // 2 + "###..####..####", // 3 + "#.##.####..#..#", // 4 + "####..###..####", // 5 + "####..####.####", // 6 + "###..#..#..#..#", // 7 + "####.#####.####", // 8 + "####.####..####" // 9 + ) + + fun solve() { + val watch = mutableListOf>() + repeat(5) { + watch.add(readln().split(' ')) + } + + val hourFirst = find(watch.joinToString(separator = "") { it[0] }) + val hourSecond = find(watch.joinToString(separator = "") { it[1] }) + val minuteFirst = find(watch.joinToString(separator = "") { it[2] }) + val minuteSecond = find(watch.joinToString(separator = "") { it[3] }) + + println("$hourFirst$hourSecond:$minuteFirst$minuteSecond") + } + + fun find(diode: String): Int { + nums.forEach { num -> + num.forEachIndexed { index, c -> + if (c == '.' && diode[index] == '#') return@forEach + } + return nums.indexOf(num) + } + return -1 + } +} + +fun main() { + 시계().solve() +} \ No newline at end of file From 37db773cf07e27e254152398c25b13ecfcc80a01 Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Sun, 1 Jan 2023 11:54:21 +0900 Subject: [PATCH 6/7] =?UTF-8?q?solve:=20=ED=81=AC=EB=A1=9C=EC=8A=A4?= =?UTF-8?q?=EC=9B=8C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\354\212\244\354\233\214\353\223\234.kt" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "src/main/kotlin/heejik/13week/\355\201\254\353\241\234\354\212\244\354\233\214\353\223\234.kt" diff --git "a/src/main/kotlin/heejik/13week/\355\201\254\353\241\234\354\212\244\354\233\214\353\223\234.kt" "b/src/main/kotlin/heejik/13week/\355\201\254\353\241\234\354\212\244\354\233\214\353\223\234.kt" new file mode 100644 index 00000000..dbc29bd3 --- /dev/null +++ "b/src/main/kotlin/heejik/13week/\355\201\254\353\241\234\354\212\244\354\233\214\353\223\234.kt" @@ -0,0 +1,34 @@ +package heejik.`13week` + +class 크로스워드 { + + fun solve() { + + val (r, c) = readln().split(' ').map { it.toInt() } + + val crossWord = mutableListOf() + val words = mutableListOf() + + + repeat(r) { + val row = readln() + crossWord.add(row) + row.split('#').forEach { + if (it.length > 1) words.add(it) + } + } + + repeat(c) { n -> + crossWord.joinToString(separator = "") { it[n].toString() }.split('#').forEach { + if (it.length > 1) words.add(it) + } + } + + println(words.minOrNull()) + } +} + + +fun main() { + 크로스워드().solve() +} \ No newline at end of file From f9e7c3664e15eb96e05d141cdf9fc08c3618dd39 Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Sun, 1 Jan 2023 11:54:34 +0900 Subject: [PATCH 7/7] =?UTF-8?q?solve:=20=F0=9F=90=9C=20=EA=B8=B0=EC=A0=81?= =?UTF-8?q?=EC=9D=98=20=EB=A7=A4=EB=A7=A4=EB=B2=95=20=F0=9F=90=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\247\244\353\262\225 \360\237\220\234.kt" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "src/main/kotlin/heejik/13week/\360\237\220\234 \352\270\260\354\240\201\354\235\230 \353\247\244\353\247\244\353\262\225 \360\237\220\234.kt" diff --git "a/src/main/kotlin/heejik/13week/\360\237\220\234 \352\270\260\354\240\201\354\235\230 \353\247\244\353\247\244\353\262\225 \360\237\220\234.kt" "b/src/main/kotlin/heejik/13week/\360\237\220\234 \352\270\260\354\240\201\354\235\230 \353\247\244\353\247\244\353\262\225 \360\237\220\234.kt" new file mode 100644 index 00000000..b9473c24 --- /dev/null +++ "b/src/main/kotlin/heejik/13week/\360\237\220\234 \352\270\260\354\240\201\354\235\230 \353\247\244\353\247\244\353\262\225 \360\237\220\234.kt" @@ -0,0 +1,71 @@ +package heejik.`13week` + +class `🐜 기적의 매매법 🐜` { + + fun solve() { + val money = readln().toInt() + val stocks = readln().split(' ').map { it.toInt() } + + val bnf = bnf(money, stocks) + val timing = timing(money, stocks) + + println( + if (bnf > timing) "BNP" + else if (timing > bnf) "TIMING" + else "SAMESAME" + ) + } + + private fun bnf(_money: Int, stocks: List): Int { + var money = _money + var stock = 0 + + stocks.forEach { + val cnt = money / it + money -= it * (cnt) + stock += cnt + } + + return money + (stock * stocks.last()) + } + + private fun timing(_money: Int, stocks: List): Int { + var money = _money + var stock = 0 + + var upCnt = 0 + var downCnt = 0 + var preStock = stocks.first() + + stocks.drop(0).forEach { + if (it > preStock) { + upCnt++ + downCnt = 0 + } else if (it < preStock) { + downCnt++ + upCnt = 0 + } else { + upCnt = 0 + downCnt = 0 + } + + if (upCnt >= 3) { + money += stock * it + stock = 0 + } + if (downCnt >= 3) { + val cnt = money / it + money -= it * (cnt) + stock += cnt + } + + preStock = it + } + + return money + (stock * stocks.last()) + } +} + +fun main() { + `🐜 기적의 매매법 🐜`().solve() +} \ No newline at end of file