Fix: Ensure all skills are tracked as files, not submodules
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
def int_to_mini_roman(number):
|
||||
"""
|
||||
Given a positive integer, obtain its roman numeral equivalent as a string,
|
||||
and return it in lowercase.
|
||||
Restrictions: 1 <= num <= 1000
|
||||
|
||||
Examples:
|
||||
>>> int_to_mini_roman(19) == 'xix'
|
||||
>>> int_to_mini_roman(152) == 'clii'
|
||||
>>> int_to_mini_roman(426) == 'cdxxvi'
|
||||
"""
|
||||
val = [
|
||||
1000, 900, 500, 400,
|
||||
100, 90, 50, 40,
|
||||
10, 9, 5, 4,
|
||||
1
|
||||
]
|
||||
syms = [
|
||||
'm', 'cm', 'd', 'cd',
|
||||
'c', 'xc', 'l', 'xl',
|
||||
'x', 'ix', 'v', 'iv',
|
||||
'i'
|
||||
]
|
||||
|
||||
roman_num = ''
|
||||
i = 0
|
||||
while number > 0:
|
||||
for _ in range(number // val[i]):
|
||||
roman_num += syms[i]
|
||||
number -= val[i]
|
||||
i += 1
|
||||
return roman_num
|
||||
Reference in New Issue
Block a user