Skip to content
Permalink
Browse files

50 is written as L

  • Loading branch information
michaelbannister committed Jul 10, 2016
1 parent 3d54827 commit 77b05ee7fc7fdf7056362c3b32859e63bbf6d891
Showing with 4 additions and 2 deletions.
  1. +2 −1 src/main/kotlin/RomanNumerals.kt
  2. +2 −1 src/test/kotlin/DecimalToRomanConverterTest.kt
@@ -4,7 +4,7 @@ fun Int.toRoman(): String {
val placeValues = toDecimalPlaceValues(this)
return placeValues.map {
if (it.multiplier == 5) {
5.toRomanDigit()
(5 * it.magnitude).toRomanDigit()
} else {
it.magnitude.toRomanDigit().repeat(it.multiplier)
}
@@ -28,6 +28,7 @@ fun toDecimalPlaceValues(number: Int): List<PlaceValue> {
private fun Int.toRomanDigit(): String = when(this) {
1000 -> "M"
100 -> "C"
50 -> "L"
10 -> "X"
5 -> "V"
1 -> "I"
@@ -27,7 +27,8 @@ class DecimalToRomanConverterTest {
arrayOf(2000, "MM"),
arrayOf(11, "XI"),
arrayOf(3012, "MMMXII"), // I didn't expect this to fail, just checking
arrayOf(5, "V")
arrayOf(5, "V"),
arrayOf(50, "L")
)

@Test

0 comments on commit 77b05ee

Please sign in to comment.
You can’t perform that action at this time.