Skip to content

Instantly share code, notes, and snippets.

@desg
Created August 3, 2012 18:24
Show Gist options
  • Save desg/3250197 to your computer and use it in GitHub Desktop.
Save desg/3250197 to your computer and use it in GitHub Desktop.
rlist = zip(
[1000,900,500,400,100,90,50,40,10,9,5,4,1],
["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]
)
def int2roman(num):
answer = []
for i, nm in rlist:
while num >= i:
answer.append(nm)
num -= i
return ''.join(answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment