musical notes postmortem
Jasper McCrea <[email protected]>
| Newsgroups | gmane.comp.lang.perl.golf |
|---|---|
| Organization | GuideGuide |
| Message-ID | <[email protected]> |
Right, since no one else seems to have written the commentary.
Almost everyone used a method to get a numerical value for the notes, and
subtracting one from the other.
The (nearly) common thread was:
$a = /#/ - /b/ + 12 * chop() + f(C-B) for @ARGV; print $a
Starting with the similar function for the first 6 entries, who all used ord *
$x % $y to get a numerical value that would work. I hope they all worked out the
numbers by brute force (because that's what I did). We wanted an array _like_
1 3 5 6 8 10 12
or
$n+1 $n+3 $n+5 $n+6 $n+8 $n+10 $n+12
from
C D E F G A B (ords: 67, 68, 69, 70, 71, 65 and 66)
(if we remember the TPR0,1 golf [ton the winner - gosh!] it had a similar factor
to produce the 'step' in an otherwise linear set of results - it used hex%10%15
or something)
So (forgetting A and B for the moment) it was easy to imagine that the step
(5-6, instead of 5-7) could be produced by multiplying ord by something less
than 2 ( 1.66667, for example), and taking the int. Then you could add 12 for
A&B cases. Easy, but too long. brute force revealed a plethora of ord * x % y
solutions that gave the exact sequence we wanted.
Ton and mtve solutions like this:
$\=(/./+ord)*1.6%12-$\+/#/-/b/+12*$'.$/for@ARGV;print (53)
winning by one character by matching /./ and/or /#/ or /b/, ensuring $' =~ /\d/,
and they don't have to use chop. They have a different multiplication (1.6%12)
because they add 1 to the ord.
Terje and tybalt89 were one behind on 54, while Eugene and I forgot about $\ (a
lesson first learned [oh, I wish it had been] in Cantor [TPR0,3, correct me if
I'm wrong]) and so had to use print$a instead of print. This only uses one extra
character because the $\ solution needed an extra pair of parentheses around
chop.
Going outside the all-important alien zone ;), Daniel, Jeff and the Alma Media
golf team had the transliteration
y/B-b/D9;=>@/
to get rid of the 'flat' b and provide the necessary ord value without resorting
to horrible fractional multiplication. They all scored 57, except Daniel who
saved a character by using $\.
kcwu and K.C.Ivey used ord * 2, then corrected for the step with a
transliteration, while Andreas, id5 and g.allen all used a transliteration
correction that again negated the use of a multiplication of ord.
Other methods included
index+CCDDEFFGGAAB,$` (ypcat, 65)
(2,4,5,7,9,-2)[71-ord] (srushe, 66)
no one used $+[CCDDEFFGGAAB=~$`], somewhat surprisingly. I suppose anyone who
thought of it discarded it for something better.
The rest are too complicated for me to understand.
I hope I haven't left anything interesting out. Apologies if I've got anything
wrong.
No improvements post mortem - good for ton and mtve, bad for the rest of us.
Jasper
--
$"='';{split//,"ajpsa onhtrep re lahkcre"}foreach(0..$#_){
unless($_%2){$_[$_]^=$_[++$_]^=$_[--$_]^=$_[++$_]}}print"@_\n"