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 ------ u...@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 ---------
perl -le 'print for glob"{Y,N}"x5'
--
Rick Klement
Of course you have to run this in a directory that doesn't contain
any file matching /^[YN]{5}$/.
--
Philippe Bruhat (BooK)
The learned man makes a mistake but once... but the truly stupid keep
practicing until they get it right.
(Moral from Groo The Wanderer #75 (Epic))
Also, I'm sure, easily bested:
perl -e 'for(0..31){$_=sprintf"%05b\n",$_;y/01/YN/;print}
marginally shorter not-to-hoyle hybrid:
seq 0 31|perl -pe '$_=sprintf"%05b\n",$_;y/01/YN/'
--
zed at-sign apricot dot com http://www.MemeMachineGo.com/
Zed Lopez PO Box 12546 Berkeley CA 94712
and shrunk a few more by removing the join and using sprintf:
perl -le 'print map{y/10 /YN/;$_}map{sprintf"%5b$/",$_}0..31'
Not true. The {} notation doesn't care whether files of that name
actual exist. I tested like so on Mac:
% touch YYYYY
% perl -le 'print for glob"{Y,N}"x5'
YYYYY
YYYYN
YYYNY
YYYNN
YYNYY
YYNYN
YYNNY
YYNNN
YNYYY
YNYYN
YNYNY
YNYNN
YNNYY
YNNYN
YNNNY
YNNNN
NYYYY
NYYYN
NYYNY
NYYNN
NYNYY
NYNYN
NYNNY
NYNNN
NNYYY
NNYYN
NNYNY
NNYNN
NNNYY
NNNYN
NNNNY
NNNNN
I was pretty sure I tried the same manipulation to obtain all permutations
of some series of strings, and that it didn't work as expected when one of
the permutations actually existed as a file in the current directory.
After a quick check, you are right and I was too. :-)
What I tried was:
$ touch YYYYY
$ perl -le 'print for glob"[YN]"x5'
YYYYY
I computed my permutations with square brackets (which is one character
shorter, but more fragile).
--
Philippe Bruhat (BooK)
To flaunt your strength is to make it your weakness.
(Moral from Groo The Wanderer #25 (Epic))
perl -le'y/01/NY/&&print,for+map+unpack(b5,chr),0..31'
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
perl -le'y/01/NY/&&print,for+map+unpack(b5,chr),0..31'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
>
> 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'
from mtve:
perl -le 'y/12/NY/-5||print for 0..2x5'
(can't do any better...)
0--gg-
--
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}