in reply to Re: (Challenge) Rotateable numbers
in thread (Challenge) Rotateable numbers

The reason tachyon's version doesn't work is not because of removing the 347, but because he golfed away the localisation of $_.

P:\test>type junk.pl sub is_rotatable{ #234567890123456789012345678901234567 $_=$_[0];y/2569347/5296/;pop==reverse } printf "%s %s rotatable\n", $_, is_rotatable( $_ ) ? 'is' : 'not' for 33, 131, 141, 171, 25696925, 101, 88; P:\test>junk Modification of a read-only value attempted at P:\test\junk.pl line 3.

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^3: (Challenge) Rotateable numbers
by tachyon (Chancellor) on Sep 17, 2004 at 02:51 UTC

    As noted at Re^3: (Challenge) Rotateable numbers the tr does not remove the digits 347 it replaces them with the digit 6. Not that it matters either way. Localisation does not matter either unless you happen to use $_ in your loop test case.....Nice algorithm BTW.

    cheers

    tachyon