Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^5: Txet Maglning Glof, Ayobndy? (both!)by tye (Sage) |
on Sep 16, 2003 at 17:30 UTC ( [id://291889]=note: print w/replies, xml ) | Need Help?? |
I came up with a way of doing both "random" and "must change" that I liked so I golfed it a bit while still keeping it strict and warnings compliant (in spirit, even): But 115 characters is rather long. Trying to golf harder, I only saved 7 strokes (108):
Anyway, I find the algorithm interesting so you might treat it like an obfu and deconstruct it. (: I'm also curious why I need to do: Shouldn't the following do the same thing (other than very, very rarely returning "0" for the comparison)? It appears that sort (Perl 5.006_00) treats ( -1 < values < +1 ) like "0" [I expected -0.1402 to be treated like "-1" and +0.3886 like "+1"] but treats ( values <= -1 ) like "-1" and ( 1 <= values ) like "+1". I find this rather strange. It is also quite unfortunate when golfing. :) Update: Thanks to PhilHibbs' insight, I realized I could golf further by taking advantage of a different "convert to IV" side-effect: which gets me to 103 strokes (I also realized that dropping "-1+" made it possible for words to stay unchanged). - tye
In Section
Seekers of Perl Wisdom
|
|