From fca4c6c0a0418747076f58b581fe73075973cc9e Mon Sep 17 00:00:00 2001 From: adityamuckaden-sf Date: Wed, 13 Aug 2025 14:10:55 -0400 Subject: [PATCH] Create convert_to_roman_numerals.py --- convert_to_roman_numerals.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 convert_to_roman_numerals.py diff --git a/convert_to_roman_numerals.py b/convert_to_roman_numerals.py new file mode 100644 index 0000000..60f5074 --- /dev/null +++ b/convert_to_roman_numerals.py @@ -0,0 +1,14 @@ +import sys + +x = 'IVXLCDM ' +with open(sys.argv[1], 'r') as f: + for l in f: + r = '' + a = int(l) + i = 0 + while a > 0: + d = a % 10 + r = (x[i] + x[i+2] if d == 9 else x[i] + x[i+1] if d == 4 else x[i+1] * (d // 5) + x[i] * (d % 5)) + r + a //= 10 + i += 2 + print(r)