Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges The 50 substrings that validate any string of Roman numerals

Python, 220 bytes Works with Python 3.8 or newer. n=" IVXLCDM" x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;...

posted 7mo ago by Arpad Horvath‭  ·  edited 5mo ago by trichoplax‭

Answer
#11: Post edited by user avatar trichoplax‭ · 2024-06-16T02:36:18Z (5 months ago)
Fix typo in description to match code
  • # [Python], 220 bytes
  • Works with Python 3.8 or newer.
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python]: https://docs.python.org
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • There are 8 kind of characters, " IXLCDM". 2 characters are 6 bits that can be easily mapped to printable characters (after code point 32). This string is much shorter (half) then the "DD DM IC ..." string itself. Even if I add the extraction it is still somewhat shorter.
  • I just regenerate the " IXLCDM" characters from this string.
  • So it is the same as the code below just with some decoding from 6-bit-string.
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python], 220 bytes
  • Works with Python 3.8 or newer.
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python]: https://docs.python.org
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • There are 8 kind of characters, " IVXLCDM". 2 characters are 6 bits that can be easily mapped to printable characters (after code point 32). This string is much shorter (half) then the "DD DM IC ..." string itself. Even if I add the extraction it is still somewhat shorter.
  • I just regenerate the " IVXLCDM" characters from this string.
  • So it is the same as the code below just with some decoding from 6-bit-string.
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#10: Post edited by user avatar Arpad Horvath‭ · 2024-04-22T14:19:41Z (7 months ago)
version
  • # [Python], 220 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • There are 8 kind of characters, " IXLCDM". 2 characters are 6 bits that can be easily mapped to printable characters (after code point 32). This string is much shorter (half) then the "DD DM IC ..." string itself. Even if I add the extraction it is still somewhat shorter.
  • I just regenerate the " IXLCDM" characters from this string.
  • So it is the same as the code below just with some decoding from 6-bit-string.
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python], 220 bytes
  • Works with Python 3.8 or newer.
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python]: https://docs.python.org
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • There are 8 kind of characters, " IXLCDM". 2 characters are 6 bits that can be easily mapped to printable characters (after code point 32). This string is much shorter (half) then the "DD DM IC ..." string itself. Even if I add the extraction it is still somewhat shorter.
  • I just regenerate the " IXLCDM" characters from this string.
  • So it is the same as the code below just with some decoding from 6-bit-string.
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#9: Post edited by user avatar Arpad Horvath‭ · 2024-04-22T14:18:34Z (7 months ago)
just python
  • # [Python 3.8 (pre-release)], 220 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • There are 8 kind of characters, " IXLCDM". 2 characters are 6 bits that can be easily mapped to printable characters (after code point 32). This string is much shorter (half) then the "DD DM IC ..." string itself. Even if I add the extraction it is still somewhat shorter.
  • I just regenerate the " IXLCDM" characters from this string.
  • So it is the same as the code below just with some decoding from 6-bit-string.
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python], 220 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • There are 8 kind of characters, " IXLCDM". 2 characters are 6 bits that can be easily mapped to printable characters (after code point 32). This string is much shorter (half) then the "DD DM IC ..." string itself. Even if I add the extraction it is still somewhat shorter.
  • I just regenerate the " IXLCDM" characters from this string.
  • So it is the same as the code below just with some decoding from 6-bit-string.
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#8: Post edited by user avatar Arpad Horvath‭ · 2024-04-21T07:47:37Z (7 months ago)
  • # [Python 3.8 (pre-release)], 220 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python 3.8 (pre-release)], 220 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • There are 8 kind of characters, " IXLCDM". 2 characters are 6 bits that can be easily mapped to printable characters (after code point 32). This string is much shorter (half) then the "DD DM IC ..." string itself. Even if I add the extraction it is still somewhat shorter.
  • I just regenerate the " IXLCDM" characters from this string.
  • So it is the same as the code below just with some decoding from 6-bit-string.
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#7: Post edited by user avatar Arpad Horvath‭ · 2024-04-20T19:31:26Z (7 months ago)
even shorter 220
  • # [Python 3.8 (pre-release)], 223 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x="".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;'])
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8fdrlb]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv8fdrlb]: https://tio.run/##TY5fT8IwFMXf@RTt7Qotf4ZKojhoxMzoFrfBi3PJnAQZxBlolzKT@elnhy@e5N578ns455Y/1aeSk2mpm0YKQH6cBO5DCJ1aANhfqpAslSlTjmC5mdoRSudsy/locsXH4ynPBjLNR9O@yvZKoy0qZK@7esWejRdjy3u0Fk/gXcPiBi4mZHVHI7qkLzSj73TdjbpL3McDfIkFvsVz7OCZJaw59GFAQhKRgCzJM3GJIHMaepy/9dbJbNbLeEeLw@b4kW/Q1jluanZCxR6ZJU3/7nDawT20z5xJbZ/KQ1ExzpuWye9jS1PwYxgiCF2jJPbP3ihwW@cb/ZEk@W9jyJwOQqjUhayYiRoi3R6T/Qs "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python 3.8 (pre-release)], 220 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(d:=ord(c)-32)//8]+n[d-8*(d//8)]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8huwl2]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv8huwl2]: https://tio.run/##TY5fT4MwFMXf9ynaW7q1sIFKohPWOINRiGPbi9gEccGxRcxWCJvJ/PSz4Ivn4d5zfsn9U/8cPyvljuvmfFYCUJTIWfAQQ@8kGID9VZWKpSplhSeqpmBrPnKvuOOMM0ulxWhsskIHnm2rBq1RqQb95SsObTx1jPDRmD5BeA3TG7hwyfKOzumCvtCMvtNVf95fYBNb@BILfIsn2MO@IYwJmGCRmMzJjCzIMwmIIBMah5y/DVbS9wcZ571G7PL9R5GjtbfPT@yAyi3SRekHNrvDBu6h/aYjJ/tQ78oj4/zcMvW9b2kKUQJDBHGgJZOo81qzoHWR1h@R8r/tRmTcZSkDyLweQqhuSnVkevEQNW3Tl34B "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#6: Post edited by user avatar Arpad Horvath‭ · 2024-04-20T18:23:06Z (7 months ago)
Fixing the code
  • # [Python](https://python.org), 222 bytes
  • ```python
  • n=" IVXLCDM"
  • r=lambda c:max(s if s in c else"A"for s in ("".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;'])).split())
  • ```
  • I couldn't make it work in TIO (Python 3.8 pre-release), but works for me with Python 3.9 on my computer.
  • # [Python](https://python.org), 225 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv7hbizd]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv7hbizd]: https://tio.run/##TY5BT4NAFITv/RW7b9myCy1Vm2iFbsRgFGJpexFJEBssbcTAQmhN8NfXpV6c5L2ZfIfJND/Hz1pOZ017OkkBKIjihfcQwqATDMD6qgvJEpmw2hYsV9fZom5ztuV8PL3ik8mMp6ZM8vHMqNN93aItKqQ@XL9i38LuRPMfNfcJ/Gtwb@BiStZ3dElX9IWm9J1uhsvhChvYxJdY4Fs8xzZ2NKHNwQCThGRJFmRFnolHBJnT0Of8Td/EjqOnnA9aUWbVR56hrV1lHTugYo/Uk2rArjzs4B76NWfSWYemLI6M81PP5HfV0wSCCEYIQk8pjoJzVlp4fQqU/kgc/48RpPYAIdS0hTwyVTVCbW@q@xc "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python 3.8 (pre-release)], 223 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x="".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;'])
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv8fdrlb]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv8fdrlb]: https://tio.run/##TY5fT8IwFMXf@RTt7Qotf4ZKojhoxMzoFrfBi3PJnAQZxBlolzKT@elnhy@e5N578ns455Y/1aeSk2mpm0YKQH6cBO5DCJ1aANhfqpAslSlTjmC5mdoRSudsy/locsXH4ynPBjLNR9O@yvZKoy0qZK@7esWejRdjy3u0Fk/gXcPiBi4mZHVHI7qkLzSj73TdjbpL3McDfIkFvsVz7OCZJaw59GFAQhKRgCzJM3GJIHMaepy/9dbJbNbLeEeLw@b4kW/Q1jluanZCxR6ZJU3/7nDawT20z5xJbZ/KQ1ExzpuWye9jS1PwYxgiCF2jJPbP3ihwW@cb/ZEk@W9jyJwOQqjUhayYiRoi3R6T/Qs "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#5: Post edited by user avatar Arpad Horvath‭ · 2024-04-20T02:48:18Z (7 months ago)
3.9
  • # [Python](https://python.org), 225 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv7hbizd]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv7hbizd]: https://tio.run/##TY5BT4NAFITv/RW7b9myCy1Vm2iFbsRgFGJpexFJEBssbcTAQmhN8NfXpV6c5L2ZfIfJND/Hz1pOZ017OkkBKIjihfcQwqATDMD6qgvJEpmw2hYsV9fZom5ztuV8PL3ik8mMp6ZM8vHMqNN93aItKqQ@XL9i38LuRPMfNfcJ/Gtwb@BiStZ3dElX9IWm9J1uhsvhChvYxJdY4Fs8xzZ2NKHNwQCThGRJFmRFnolHBJnT0Of8Td/EjqOnnA9aUWbVR56hrV1lHTugYo/Uk2rArjzs4B76NWfSWYemLI6M81PP5HfV0wSCCEYIQk8pjoJzVlp4fQqU/kgc/48RpPYAIdS0hTwyVTVCbW@q@xc "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python](https://python.org), 222 bytes
  • ```python
  • n=" IVXLCDM"
  • r=lambda c:max(s if s in c else"A"for s in ("".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;'])).split())
  • ```
  • I couldn't make it work in TIO (Python 3.8 pre-release), but works for me with Python 3.9 on my computer.
  • # [Python](https://python.org), 225 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv7hbizd]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv7hbizd]: https://tio.run/##TY5BT4NAFITv/RW7b9myCy1Vm2iFbsRgFGJpexFJEBssbcTAQmhN8NfXpV6c5L2ZfIfJND/Hz1pOZ017OkkBKIjihfcQwqATDMD6qgvJEpmw2hYsV9fZom5ztuV8PL3ik8mMp6ZM8vHMqNN93aItKqQ@XL9i38LuRPMfNfcJ/Gtwb@BiStZ3dElX9IWm9J1uhsvhChvYxJdY4Fs8xzZ2NKHNwQCThGRJFmRFnolHBJnT0Of8Td/EjqOnnA9aUWbVR56hrV1lHTugYo/Uk2rArjzs4B76NWfSWYemLI6M81PP5HfV0wSCCEYIQk8pjoJzVlp4fQqU/kgc/48RpPYAIdS0hTwyVTVCbW@q@xc "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#4: Post edited by user avatar Arpad Horvath‭ · 2024-04-20T02:30:20Z (7 months ago)
  • # [Python 3.8 (pre-release)](https://python.org), 225 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv7hbizd]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv7hbizd]: https://tio.run/##TY5BT4NAFITv/RW7b9myCy1Vm2iFbsRgFGJpexFJEBssbcTAQmhN8NfXpV6c5L2ZfIfJND/Hz1pOZ017OkkBKIjihfcQwqATDMD6qgvJEpmw2hYsV9fZom5ztuV8PL3ik8mMp6ZM8vHMqNN93aItKqQ@XL9i38LuRPMfNfcJ/Gtwb@BiStZ3dElX9IWm9J1uhsvhChvYxJdY4Fs8xzZ2NKHNwQCThGRJFmRFnolHBJnT0Of8Td/EjqOnnA9aUWbVR56hrV1lHTugYo/Uk2rArjzs4B76NWfSWYemLI6M81PP5HfV0wSCCEYIQk8pjoJzVlp4fQqU/kgc/48RpPYAIdS0hTwyVTVCbW@q@xc "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python](https://python.org), 225 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv7hbizd]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv7hbizd]: https://tio.run/##TY5BT4NAFITv/RW7b9myCy1Vm2iFbsRgFGJpexFJEBssbcTAQmhN8NfXpV6c5L2ZfIfJND/Hz1pOZ017OkkBKIjihfcQwqATDMD6qgvJEpmw2hYsV9fZom5ztuV8PL3ik8mMp6ZM8vHMqNN93aItKqQ@XL9i38LuRPMfNfcJ/Gtwb@BiStZ3dElX9IWm9J1uhsvhChvYxJdY4Fs8xzZ2NKHNwQCThGRJFmRFnolHBJnT0Of8Td/EjqOnnA9aUWbVR56hrV1lHTugYo/Uk2rArjzs4B76NWfSWYemLI6M81PP5HfV0wSCCEYIQk8pjoJzVlp4fQqU/kgc/48RpPYAIdS0hTwyVTVCbW@q@xc "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#3: Post edited by user avatar Arpad Horvath‭ · 2024-04-20T02:29:41Z (7 months ago)
shorter
  • # [Python](https://python.org), 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python 3.8 (pre-release)](https://python.org), 225 bytes
  • <!-- language-all: lang-python -->
  • n=" IVXLCDM"
  • x=("".join([n[(o:=(d:=(x:=ord(c))-32)//8)]+n[d-8*o]for c in'&PW!H.!@/$HF$@G"H6"@7"03#P?%N%O%U%]%^%_&N&O!*!+!1!=!9!<!:!;$=$<"*"+#M#N#L#O#K#C#=#<%MH))\'_X;;']))
  • r=lambda c:max(s if s in c else"A"for s in x.split())
  • [Try it online!][TIO-lv7hbizd]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-lv7hbizd]: https://tio.run/##TY5BT4NAFITv/RW7b9myCy1Vm2iFbsRgFGJpexFJEBssbcTAQmhN8NfXpV6c5L2ZfIfJND/Hz1pOZ017OkkBKIjihfcQwqATDMD6qgvJEpmw2hYsV9fZom5ztuV8PL3ik8mMp6ZM8vHMqNN93aItKqQ@XL9i38LuRPMfNfcJ/Gtwb@BiStZ3dElX9IWm9J1uhsvhChvYxJdY4Fs8xzZ2NKHNwQCThGRJFmRFnolHBJnT0Of8Td/EjqOnnA9aUWbVR56hrV1lHTugYo/Uk2rArjzs4B76NWfSWYemLI6M81PP5HfV0wSCCEYIQk8pjoJzVlp4fQqU/kgc/48RpPYAIdS0hTwyVTVCbW@q@xc "Python 3.8 (pre-release) – Try It Online"
  • ## 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#2: Post edited by user avatar Arpad Horvath‭ · 2024-04-19T22:25:22Z (7 months ago)
  • # [Python 3](https://python.org), 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
  • # [Python](https://python.org), 238 bytes
  • If the r= part is not needed then 2 bytes less
  • <!-- language-all: lang-python -->
  • r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())
  • [Try it online!][TIO-lv78jx4k]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"
#1: Initial revision by user avatar Arpad Horvath‭ · 2024-04-19T22:24:25Z (7 months ago)
# [Python 3](https://python.org), 238 bytes

If the r= part is not needed then 2 bytes less

<!-- language-all: lang-python -->

    r=lambda c:max(s if s in c else"A"for s in'DD DM IC ID IL IM LC LD LL LM VC VD VL VM VV VX XD XM CCD CCM CDC CMC CMD CMM DCD DCM IIV IIX IVI IXC IXI IXL IXV IXX LXC LXL VIV VIX XCC XCD XCL XCM XCX XLX XXC XXL CCCC IIII MMMM XXXX'.split())

[Try it online!][TIO-lv78jx4k]

[Python 3]: https://docs.python.org/3/
[TIO-lv78jx4k]: https://tio.run/##TY8xa8NADIX3/orHLXEgdOkW6FB0i0C3CkHo4KYJNdiOsV1ofr37Ll0qeCfp490DTff16za@bNv82rfDx2eL83Fof5oF3RV8Rpxx6ZdLekvX2/wgu5yRC1SgGWrQAhNYhhmswAWe4Qbn7PBAZESBSKbYs0BKFfdSkMkzuapTAXWFBsOjdsYHeQSMzLg7fU5fiFCMFqMKRWYUfUGfsBioisIiitg9L1Pfrc1@v9Vjxu@hHnhK6umAVOqPcH3MLJM61YQ/EvF/9PR@fAIwzd24Now6YK6N2b8 "Python 3 – Try It Online"