summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-03-13 00:33:44 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-03-13 00:33:44 +0100
commita7e5de3489d2934332ff0dccc6d7a8d403eac216 (patch)
tree78ccea68a8008b33b055a2a440f2a8223823efcd
parent4af9b6a40d3758b60476c62641e9b216c3b79fe3 (diff)
...
-rw-r--r--roman.go2
-rw-r--r--roman_test.go4
2 files changed, 5 insertions, 1 deletions
diff --git a/roman.go b/roman.go
index b5886ba..7a7c4b3 100644
--- a/roman.go
+++ b/roman.go
@@ -31,5 +31,5 @@ func (n Roman) String() string {
// this is efficient in Go. the seven operands are evaluated,
// then a single allocation is made of the exact size needed for the result.
return m6[n/1e6] + m5[n%1e6/1e5] + m4[n%1e5/1e4] + m3[n%1e4/1e3] +
- m2[n%1e3/1e2] + m1[n%100/10] + m0[n%10]
+ m2[n%1e3/1e2] + m1[n%1e2/1e1] + m0[n%1e1]
}
diff --git a/roman_test.go b/roman_test.go
index 218c38e..4ad62cf 100644
--- a/roman_test.go
+++ b/roman_test.go
@@ -11,6 +11,7 @@ func TestRoman(t *testing.T) {
}{
{0, ""},
{1, "I"},
+ {2, "II"},
{3, "III"},
{5, "V"},
{8, "VIII"},
@@ -19,6 +20,9 @@ func TestRoman(t *testing.T) {
{34, "XXXIV"},
{55, "LV"},
{89, "LXXXIX"},
+ {100, "C"},
+ {200, "CC"},
+ {500, "D"},
{1e3 - 1, "CMXCIX"},
{2e3 - 1, "MCMXCIX"},
{4e3 - 1, "MMMCMXCIX"},