Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Decimal Gray Code in 31 chars

by ikegami (Patriarch)
on Jan 18, 2010 at 22:25 UTC ( [id://818062]=note: print w/replies, xml ) Need Help??


in reply to Decimal Gray Code in 31 chars

From your 35

perl -e'print(($_^$_>>1).$/)for(0..pop)' 15 12345678901234567890123456789012345

I shave 6 off

perl -le'print$_^$_>>1 for 0..pop' 15 12345678901234567890123456789

3 more if 5.10+

perl -E'say$_^$_>>1 for 0..pop' 15 12345678901234567890123456

Replies are listed 'Best First'.
Re^2: Decimal Gray Code in 31 chars
by mtve (Deacon) on Jan 19, 2010 at 10:46 UTC

    two more:

    print$_^$_/2for 0..pop
      I swear I tried removing that space and got an error. But yeah, it works.
Re^2: Decimal Gray Code in 31 chars
by ambrus (Abbot) on Jan 19, 2010 at 11:13 UTC

    It's funny how some people still post nodes with such titles despite the warning on the top of Obfuscated code: “Word of warning, though: Don't be too cocky with your post — almost inevitably someone will post a reply that does the exact same thing in even fewer characters!

      My guess is because by saying "simplest as possible", it challenges others to improve on it ;). Do you think this many comments would be gathered otherwise?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://818062]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-20 03:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found