I've managed to reduce the Hospelian Arabic to Roman Transform by one byte.
As a lead-in, I've read most of your nodes at some point (always good reading, btw), and when I first saw Ton's amazing formula, I spent a few moments dissecting it to figure out how it did what it did. Recently, while working on a similar problem, I decided to see if I could reproduce his formula, armed with the knowledge of how it worked.
A few hours of brute forcing later, and I had a result. Naturally, I wanted to check back here to see how I had done. I was pleasantly surprised to find that I had stumbled upon a formula that was one byte shorter!
Ton's original formula:
y/CLXVI6240-9/MDCLXXVI/dfor$$_.=5x$&*8%29628
The one byte improvement:
y/CLXVI60-9/MDCLXVIX/dfor$$_.="32e$&"%72726
Alternative:
y/CLXVI0-9/MDCLXIXV/dfor$$_.="57e$&"%474976
Even though "32e$&"%72726 is one byte longer than Ton's 5x$&*8%29628, it saves 2 bytes in the transliteration, because 01 is transliterated with IX. The alternative transliterates 012 with IXV, saving yet another byte, but it uses a modulus that's one digit longer.
Update:
Since originally posting, I've found several more alternatives of the same length, using multiple substitutions for I and/or V:
y/CLXVI0-9/MDCLXIVXI/dfor$$_.="49e$&"%87971
y/CLXVI0-9/MDCLXIIXIV/dfor$$_.="7e$&"%10606 #
y/CLXVI0-9/MDCLXIIXIV/dfor$$_.="7e$&"%15909 #
y/CLXVI0-9/MDCLXIIXIV/dfor$$_.="7e$&"%31818 # These are all essential
+ly the same
y/CLXVI0-9/MDCLXIIX V/dfor$$_.="8e$&"%61535 # Doesn't contain 3 anywh
+ere
# although this is one byte longer, it saved a byte in the challenge I
+ was working on
y/CLXVI60-9/MDCLXXI V/dfor$$_.="37e$&"%97366 # Doesn't contain 1 anywh
+ere
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|