added working roman example
This commit is contained in:
parent
b7795a2938
commit
1894bb160c
16
roman/roman.py
Normal file
16
roman/roman.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def int_to_roman(input):
|
||||||
|
ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
|
||||||
|
nums = ('M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV',
|
||||||
|
'I')
|
||||||
|
result = ""
|
||||||
|
for i in range(len(ints)):
|
||||||
|
count = int(input / ints[i])
|
||||||
|
result += nums[i] * count
|
||||||
|
input -= ints[i] * count
|
||||||
|
return result
|
||||||
|
|
||||||
|
for num in [int(i.strip()) for i in sys.stdin]:
|
||||||
|
print int_to_roman(num)
|
5
roman/stdin1.txt
Normal file
5
roman/stdin1.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
2006
|
||||||
|
1944
|
||||||
|
1910
|
||||||
|
800
|
||||||
|
42
|
Loading…
Reference in New Issue
Block a user