Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions input.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
1
4
5
9
43
50
51
104
243
401
510
999
1999
3277
3999
18 changes: 18 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys

v = [[1], [9, 5, 4, 1], [9, 5, 4, 1], [9, 5, 4, 1]]
s = [['M'], ['CM', 'D', 'CD', 'C'], ['XC', 'L', 'XL', 'X'], ['IX', 'V', 'IV', 'I']]
with open(sys.argv[1], 'r') as f:
l = f.readline().strip()
while l != '':
r = ''
for i, c in enumerate(l.zfill(4)):
d = int(c)
if d == 0:
continue
for j in v[i]:
if d >= j:
r += s[i][v[i].index(j)]
d -= j
print(l, r)
l = f.readline().strip()