Skip to content

Commit 0ec135a

Browse files
committed
attempt kevsmith#1
1 parent 31dcf4f commit 0ec135a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

arabic_to_roman.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import sys
2+
3+
m = [
4+
(1000, "M"),
5+
(900, "CM"),
6+
(500, "D"),
7+
(400, "CD"),
8+
(100, "C"),
9+
(90, "XC"),
10+
(50, "L"),
11+
(40, "XL"),
12+
(10, "X"),
13+
(9, "IX"),
14+
(5, "V"),
15+
(4, "IV"),
16+
(1, "I")
17+
]
18+
19+
def r(i):
20+
o = ''
21+
n = int(i)
22+
for v, l in m:
23+
while n >= v:
24+
n = n - v
25+
o += l
26+
print(o)
27+
28+
with open(sys.argv[1], "r") as f:
29+
for l in f:
30+
r(l)

0 commit comments

Comments
 (0)