Skip to content

Commit 027ec32

Browse files
example solution to pass tests
1 parent c1120d3 commit 027ec32

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
let roman = n => {
2+
let rec aux = (s, remainder) => {
3+
switch remainder {
4+
| r if r >= 1000 => aux(s ++ "M", r - 1000)
5+
| r if r >= 900 => aux(s ++ "CM", r - 900)
6+
| r if r >= 500 => aux(s ++ "D", r - 500)
7+
| r if r >= 400 => aux(s ++ "CD", r - 400)
8+
| r if r >= 100 => aux(s ++ "C", r - 100)
9+
| r if r >= 90 => aux(s ++ "XC", r - 90)
10+
| r if r >= 50 => aux(s ++ "L", r - 50)
11+
| r if r >= 40 => aux(s ++ "XL", r - 40)
12+
| r if r >= 10 => aux(s ++ "X", r - 10)
13+
| r if r >= 9 => aux(s ++ "IX", r - 9)
14+
| r if r >= 5 => aux(s ++ "V", r - 5)
15+
| r if r >= 4 => aux(s ++ "IV", r - 4)
16+
| r if r >= 1 => aux(s ++ "I", r - 1)
17+
| _ => s
18+
}
19+
}
20+
aux("", n)
21+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let roman = _ => panic("'roman' is not implemented")

0 commit comments

Comments
 (0)