forked from oturing/ppqsp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
def to_roman(): | ||
|
||
romanNumeralMap = ( | ||
('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), | ||
('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ('IV', 4), ('I', 1)) | ||
|
||
def _to_roman(n): | ||
result = '' | ||
for numeral, integer in romanNumeralMap: | ||
while n >= integer: | ||
result += numeral | ||
n -= integer | ||
return result | ||
return _to_roman | ||
|
||
to_roman = to_roman() | ||
for i in range(1, 21): | ||
print to_roman(i) |