Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Roman solution in Clear category for Roman Numerals by Michal_Cichy
def checkio(data):
t1 = [1000, 500, 100, 50, 10, 5, 1]
t2 = ["M", "D", "C", "L", "X", "V", "I"]
i = 0
wynik = ""
a = int(data)
while a>0:
while a >= t1[i]:
wynik = wynik + t2[i]
a = a - t1[i]
if i % 2 == 0:
if a >= 0.9 * t1[i]:
wynik = wynik + t2[i + 2] + t2[i]
a = a - (0.9 * t1[i])
if i % 2 == 1:
if a >= 0.8 * t1[i]:
wynik = wynik + t2[i + 1] + t2[i]
a = a - (0.8 * t1[i])
i = i + 1
return wynik
Oct. 30, 2016