develooper Front page | perl.fwp | Postings from March 2008

Re: [spam?] YN golf

Thread Previous | Thread Next
From:
Josh Goldberg
Date:
March 31, 2008 17:28
Subject:
Re: [spam?] YN golf
Message ID:
4c7f9e8d0803311612i2c6703dbjc340091f382c7328@mail.gmail.com
Knocking a few chars off yours for perl -le 'print
join$/,map{y/01/NY/;$_}map unpack("b5",chr),0..31'

and shrunk a few more by removing the join and using sprintf:

perl -le 'print map{y/10 /YN/;$_}map{sprintf"%5b$/",$_}0..31'

On Mon, Mar 31, 2008 at 3:50 PM, Uri Guttman <uri@stemsystems.com> wrote:

>
> someone posted (and it wasn't homework) for an easy way to get all
> possible combos of YN (5 chars so 32 answers). he got some basic
> multiline answers but i think it makes for a great golf problem.
>
> here is my first pass which i am sure can be easily bested. i haven't
> even squeezed out the white spaces but it does work.
>
> golf away!
>
> uri
>
> perl -le 'print join "\n", map {tr/01/NY/; $_} map unpack( "b5", chr), 0
> .. 31'
>
> --
> Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com--
> -----  Perl Code Review , Architecture, Development, Training, Support
> ------
> --------- Free Perl Training --- http://perlhunter.com/college.html---------
> ---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com---------
>
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About