use once_cell::sync::Lazy;
static ROMAN_NUMERALS: Lazy<Vec<(usize, &str)>> = Lazy::new(|| {
vec![
(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"),
]
});
pub fn to_roman(mut num: usize) -> String {
let mut result = String::new();
let mut index = 0;
while num > 0 {
let (value, symbol) = ROMAN_NUMERALS[index];
if num >= value {
result.push_str(symbol);
num -= value;
} else {
index += 1;
}
}
result
}