Re: A new golf "Unfragment" has started
[email protected] ("Riey Bryant") Sat, 17 Jan 2004 15:13:20 -0600
| Newsgroups | perl.golf |
|---|---|
| Message-ID | <[email protected]> |
Hello All!
As usual, playing another round of golf turns my mind to another round of
questions...
My solution below works for all test cases:
-lp0a
for$=(@F){@;=grep{$*=$_;grep$*eq$_,@;?@;:@*}@*=map{$_.$=,$=.$_}@F}$_=pop@I
thought, however, that I could save a stroke by replacing the first grep
statement with a map:
-lp0a
for$=(@F){@;=map{$*=$_;grep$*eq$_,@;?@;:@*}@*=map{$_.$=,$=.$_}@F}$_=pop@
This solution (though seeming to work at first) fails on test 81 (seen at
the bottom of this post).
Maybe it actually passes, but I didn't have the patience to wait for it... I
noticed Juho mentioned something similar about test 81.
Why does this substitution (grep to map) make such a huge difference in
running time? Both statements should return the same array, right?
Many thanks for any thoughts.
-Riley (o0lit3)
Test case 81:
0000000
00
000000
000
000
000000
0000
00000
0000
00000
0000000
00
00000000
0
0
00000000