|
Posted by Gunnar Hjalmarsson on April 1, 2008, 4:34 am
Please log in for more thread options Uri Guttman wrote:
>
> GH> smallpond wrote:
> >> On Mar 31, 4:57 pm, joemacbusin...@yahoo.com wrote:
> >>> Hi All,
> >>>
> >>> This has probably already been written but I did not see it on CPAN.
> >>> Is there a code snippent that can print every possible combination
> >>> of Y/N's in a 5 position array or string?
> >>>
> >>> For example: Y Y Y Y Y becomes
> >>> N Y Y Y Y
> >>> Y N Y Y Y....
> >>> Y Y N N Y etc.
> >>>
> >> Who gets the credit for doing your homework?
>
> GH> I do, I hope. :)
>
> GH> foreach my $num ( 0 .. 0b11111 ) {
> GH> local *_ = \ sprintf '%05b', $num;
> GH> tr/01/NY/;
> GH> print "$_\n";
> GH> }
>
> ok, now make it a oneliner and golf it! we ain't had a golf thread in
> ages!
I'm not a golfer, but it's easy to write obfuscated code using Perl...
perl -le"dofor(0..0b11111)"
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
|