> ++ColinHorne on a very respectable first Japh!
Many thanks! As you've probably guessed, I'm fairly new to the
monastery (although, I've been lurking for a while), so that's
my first ++ :-)
> Here are a few tips for "golfing" it down, should you desire to make it even more terse, while still preserving the important elements:
I made a re-write this morning, which implemented many of your tips. Still based on the same idea as the old code, though.
#!/usr/bin/perl
$a="cdfh";printf(join("",map{chr(ord)}map({$_^=(split //,$a)[$i++%
length$a]}(map{chr(eval"0x$_")}(("4617460110442c1d101046090d0b120"
."00616463806160a482b05050306166c")=~/../g)))),$a)#GPL:Colin Horne
I think there's only one pair of parenthesis which can be taken out, which are around chr(ord). I decided to keep them in, though, since the formatting is quite nice at the moment, and removing them would mess that up a bit :-)
> 6. You have a string concatenation which seems unnecessary, and saves 3 characters ('"."')
I left that in on the re-write, so that I could keep the col-width under 70 (there can't be a newline character in the string). Shoot me if there's a nicer way to do that, though :-)
My exam's in a few days time, but after that I will have another go at re-writing it, and will hopefully get 'round to making an explanation page (for those who aren't wizards like yourself :-) ).
Anyway, many thanks for your help! Hopefully you can expect me to be active more, and lurk less in the near future :-D
Cheers!
Edit: Actually, it seems there was quite a bit I could strip out from this mornings code ;-) This is the updated version:
#!/usr/bin/perl
map{print chr ord}map{$_^=qw{c d f h}[$a++%4]}map{eval"chr 0x$_
"}"2911151c43050807170c031a4334031a0f442e09000f031a4f6e"=~/../g
Changed the output a bit, since I wasn't too sure if it was considered arrogant for one to label himself directly (also, it made the code slightly shorter to strip that out!).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
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.