but the problem is that it doesn't work. But wait! I'm using perl v.5.8.6, so I looked into the generic perl golf rules at the site - perl 5.8.0 is the reference. I happen to have it installed, but no luck again.-l 2**++$_=~/^@ARGV/.$'>2 .$&?print:do$0
While writing this node as a SoPW, the solution slapped my face at once - do you see it?
This was my analysis. The solution can be rearranged asThe greater-than test is supposed to work not before the iteration in which $_ is equal to the solution, in which case the print branch is taken; otherwise the other branch is taken triggering a recursion. The real not-working part is the following: It is supposed to perform the match and to evaluate to the last value for $', which is initially undefined. The problem is that the dot operator, which merges $' to the previous expression, simply has an higher precedence over the named unary operator -l, so instead of it evaluates like which is assured to be undef if you work in an empty directory, and won't ever evaluate to $'. But how could this solution win? Impossible - in this way. But I then realised: it was a typo!!! I quickly turned the dot into a comma: and all worked fine! Congratulations, tybalt89! |
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Minigolf solution not working - can you see why?
by japhy (Canon) on Jun 16, 2005 at 20:21 UTC | |
by polettix (Vicar) on Jun 16, 2005 at 21:04 UTC |