From 0d7e4fa7a1244a26e44f92b791b2d0a20d37c4c5 Mon Sep 17 00:00:00 2001 From: Michael Bannister Date: Sun, 3 Jul 2016 17:19:52 +0100 Subject: [PATCH] 2000 is written as MM --- src/main/kotlin/RomanNumerals.kt | 2 +- src/test/kotlin/DecimalToRomanConverterTest.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/RomanNumerals.kt b/src/main/kotlin/RomanNumerals.kt index a98d8b4..9c45744 100644 --- a/src/main/kotlin/RomanNumerals.kt +++ b/src/main/kotlin/RomanNumerals.kt @@ -1,6 +1,6 @@ fun Int.toRoman(): String { if (this >= 1000) { - return "M" + return "M".repeat(this / 1000) } else if (this >= 100) { return "C".repeat(this / 100) } else if (this >= 10) { diff --git a/src/test/kotlin/DecimalToRomanConverterTest.kt b/src/test/kotlin/DecimalToRomanConverterTest.kt index 29d53a3..dc6cac2 100644 --- a/src/test/kotlin/DecimalToRomanConverterTest.kt +++ b/src/test/kotlin/DecimalToRomanConverterTest.kt @@ -23,7 +23,8 @@ class DecimalToRomanConverterTest { arrayOf(20, "XX"), arrayOf(100, "C"), arrayOf(200, "CC"), - arrayOf(1000, "M") + arrayOf(1000, "M"), + arrayOf(2000, "MM") ) }