For some reason, the map statement in b() is resulting in that strange "312321,123312" results ... which for the life of me, I can't figure out why.sub b { print 'args=',join(",",@_),"\n"; $,=pop()-pop(); print ", = $,\n"; $x=join'',sort split//,$,; print "x = '$x'\n"; ## the line below doesn't seem to work!! @_=map{scalar reverse($_),$_ } $x; print "\@_ = ",join(",",@_),"\n"; print "\n"; $,==495?0:1+b(@_); } sub c { @a=map{ scalar reverse($_),$_ } pop; print join(",",@a),"\n"; } c(312); b(312); ==== Results when run< ==== 213,312 ## this is c() args=312 ## this is b() , = 312 x = '123' @_ = 312321,123312
I have a feeling it's something stupid, but I can't see it. Can anyone else?
Update: God, I love this place. You write a technical, perl question, one that contains a user-error (such as I did, using $, as a temporary variable (golf, you know)), and you get down voted as much as upvoted. This node of mine has bounced from -1 to 1 so many times my head is spinning. So at what point is a question stupid enough that you shouldn't ask? I seem to remember quite a few people having on their tag lines, and on their tongues, the phrase of "Ask a silly question, be a fool for a minute, don't ask a silly question and be a fool forever.". I guess that doesn't always apply, huh?</rant>
mr.nick ...
In reply to Re: (Golf) Kaprekar's Process
by mr.nick
in thread (Golf) Kaprekar's Process
by srawls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |