39 lines
873 B
Python
39 lines
873 B
Python
# HumanEval/156
|
|
# Loki Mode Multi-Agent Solution
|
|
# Attempts: 1
|
|
# Passed: True
|
|
|
|
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'
|
|
"""
|
|
value_symbol_pairs = [
|
|
(1000, 'm'),
|
|
(900, 'cm'),
|
|
(500, 'd'),
|
|
(400, 'cd'),
|
|
(100, 'c'),
|
|
(90, 'xc'),
|
|
(50, 'l'),
|
|
(40, 'xl'),
|
|
(10, 'x'),
|
|
(9, 'ix'),
|
|
(5, 'v'),
|
|
(4, 'iv'),
|
|
(1, 'i')
|
|
]
|
|
|
|
result = ''
|
|
for value, symbol in value_symbol_pairs:
|
|
while number >= value:
|
|
result += symbol
|
|
number -= value
|
|
|
|
return result |