Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Golfing Colors

by jmcnamara (Monsignor)
on Jun 01, 2001 at 20:20 UTC ( [id://84976]=note: print w/replies, xml ) Need Help??


in reply to Golfing Colors


This isn't really a problem of combinations, it's a printf problem. ;-)

The direct approach works just as well:
my $h = 0x33; for my $i (0..5) { for my $j (0..5) { for my $k (0..5) { printf"#%02x%02x%02x\n", $i*$h, $j*$h, $k*$h; } } }
And the best I can golf that to is 77 chars: for $a(0..5){for $b(0..5){printf"#%02x%02x%02x\n",$a*51,$b*51,$_*51for 0..5}} As an aside, the common abuse of $a and $b in Golf isn't really in the spirit of strict even if it does give strict compliance.

John.
--

Replies are listed 'Best First'.
Re: Re: Golfing Colors
by iamcal (Friar) on Jun 01, 2001 at 20:54 UTC
    75 if you drop those two spaces: for$a(0..5){for$b(0..5){printf"#%02x%02x%02x\n",$a*51,$b*51,$_*51for 0..5}}
Re: Re: Golfing Colors
by petral (Curate) on Jun 03, 2001 at 18:42 UTC
      "As an aside, the common abuse of $a and $b in Golf isn't really in the spirit of strict even if it does
        give strict compliance."


    That's golf, brother. (Just picture a cloister full of monks quietly going about their business and all pausing to stick their tongues out at you.)

      p

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-07-14 11:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.