Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Two Dicts solution in Clear category for Roman Numerals by 9Teen90Three
def checkio(data):
araba = {
1: [1],
2: [1,1],
3: [1,1,1],
4: [1,5],
5: [5],
6: [5,1],
7: [5,1,1],
8: [5,1,1,1],
9: [1, 10],
}
roma = {
1: 'I',
5: 'V',
10: 'X',
50: 'L',
100: 'C',
500: 'D',
1000: 'M'
}
arabalist = []
for n in range(len(str(data))):
if str(data)[n] == '0': continue
arabalist += list(map(lambda x: int(str(x)+'0'*(len(str(data))-n-1)), araba[int(str(data)[n])]))
romalist = list(map(lambda n: roma[n], arabalist))
return "".join(romalist)
Jan. 22, 2019