Last active
June 7, 2019 13:01
-
-
Save Drakekin/afcaab775ee9b8f6243246df590e63ba to your computer and use it in GitHub Desktop.
Computing roman numerals without es
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bad_l_tt_r = chr(101) | |
num_rals = { | |
"M": 1000, | |
"CM": 900, | |
"C": 100, | |
"XC": 90, | |
"L": 50, | |
"XL": 40, | |
"X": 10, | |
"IX": 9, | |
"V": 5, | |
"IV": 4, | |
"I": 1, | |
} | |
class Whil_: | |
pass | |
builtins = __builtins__.__dict__ | |
s_tattr = builtins["s{}tattr".format(bad_l_tt_r)] | |
g_tattr = builtins["g{}tattr".format(bad_l_tt_r)] | |
n_xt = builtins["n{}xt".format(bad_l_tt_r)] | |
it_r = builtins["it{}r".format(bad_l_tt_r)] | |
s_tattr(Whil_, "stop", 0) | |
s_tattr(Whil_, "__n{}xt__".format(bad_l_tt_r), lambda s: n_xt(it_r([1] * (1 - s.stop)))) | |
s_tattr(Whil_, "__it{}r__".format(bad_l_tt_r), lambda s: s) | |
s_tattr(Whil_, "br_ak", lambda s: s_tattr(s, "stop", 1)) | |
whil_ = Whil_() | |
for _ in whil_: | |
usr_str = input("Pl{0}as{0} typ{0} your numb{0}r: ".format(bad_l_tt_r)) | |
int_g_r = int("".join([c for c in usr_str if c in "0123456789"])) | |
roman = "" | |
for l_tt_r, num_ral in g_tattr(num_rals, "it{}ms".format(bad_l_tt_r))(): | |
comp = Whil_() | |
for _ in comp: | |
if num_ral > int_g_r: | |
comp.br_ak() | |
if num_ral <= int_g_r: | |
int_g_r -= num_ral | |
roman += l_tt_r | |
print(roman) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment