diff --git a/roman/roman.py b/roman/roman.py new file mode 100644 index 0000000..3487db1 --- /dev/null +++ b/roman/roman.py @@ -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) diff --git a/roman/stdin1.txt b/roman/stdin1.txt new file mode 100644 index 0000000..aa71469 --- /dev/null +++ b/roman/stdin1.txt @@ -0,0 +1,5 @@ +2006 +1944 +1910 +800 +42