From cc644763c29e496ad58fe7a82c630739164cbc89 Mon Sep 17 00:00:00 2001 From: EthanShin Date: Sat, 29 Jun 2019 23:53:04 +0900 Subject: [PATCH 1/3] feat: Add Tower_Breakers.kt description: Given N towers of height M and the rules for breaking them down, determine who will win the battle. --- .../kotlin/Game_Theory-Tower_Breakers.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Algorithms/kotlin/Game_Theory-Tower_Breakers.kt diff --git a/Algorithms/kotlin/Game_Theory-Tower_Breakers.kt b/Algorithms/kotlin/Game_Theory-Tower_Breakers.kt new file mode 100644 index 0000000..986c35a --- /dev/null +++ b/Algorithms/kotlin/Game_Theory-Tower_Breakers.kt @@ -0,0 +1,23 @@ +import java.util.* +import kotlin.io.* +import kotlin.text.* + +fun towerBreakers(n: Int, m: Int): Int { + + return 0 +} + +fun main(args: Array) { + val scan = Scanner(System.`in`) + + val t = scan.nextLine().trim().toInt() + + for (tItr in 1..t) { + val nm = scan.nextLine().split(" ") + val n = nm[0].trim().toInt() + val m = nm[1].trim().toInt() + + val result = towerBreakers(n, m) + println(result) + } +} \ No newline at end of file From 970e1d637bd52e77155fd8f93818962b4fe77dc4 Mon Sep 17 00:00:00 2001 From: EthanShin Date: Mon, 1 Jul 2019 23:49:01 +0900 Subject: [PATCH 2/3] feat: Modify Tower_Breakers.kt description: Given N towers of height M and the rules for breaking them down, determine who will win the battle. --- Algorithms/kotlin/Game_Theory-Tower_Breakers.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Algorithms/kotlin/Game_Theory-Tower_Breakers.kt b/Algorithms/kotlin/Game_Theory-Tower_Breakers.kt index 986c35a..723b87b 100644 --- a/Algorithms/kotlin/Game_Theory-Tower_Breakers.kt +++ b/Algorithms/kotlin/Game_Theory-Tower_Breakers.kt @@ -4,7 +4,10 @@ import kotlin.text.* fun towerBreakers(n: Int, m: Int): Int { - return 0 + // 1-1. 높이가 1인 타워는 player2가 승리한다. + // 1-2. 타워의 개수가 홀수이면 player1이 승리한다. + return if ((m == 1) or (n % 2 == 0)) 2 + else 1 } fun main(args: Array) { @@ -20,4 +23,4 @@ fun main(args: Array) { val result = towerBreakers(n, m) println(result) } -} \ No newline at end of file +} From 4a3869054bf3da6aaf56a937d179e00153769989 Mon Sep 17 00:00:00 2001 From: EthanShin Date: Mon, 1 Jul 2019 23:51:15 +0900 Subject: [PATCH 3/3] docs: Modify REMOTE_README.md resolved: #108 description: Add a file name to the index. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b6b1828..67b0323 100644 --- a/README.md +++ b/README.md @@ -83,4 +83,5 @@ All about hackerrank - Bit_Manipulation-Lonely_Integer.kt - Bit_Manipulation-Maximizing_XOR.kt - Bit_Manipulation-Sum_vs_XOR.kt -- Game_Theory-Game_of_Stones.kt \ No newline at end of file +- Game_Theory-Game_of_Stones.kt +- Game_Theory-Tower_Breakers.kt \ No newline at end of file