Your skill will accomplishwhat the force of many cannot PerlMonks

### Re: Re: Let's get lazy

by blakem (Monsignor)
 on Nov 02, 2001 at 04:26 UTC ( #122727=note: print w/replies, xml ) Need Help??

in reply to Re: Let's get lazy
in thread Let's get lazy

Since I don't see the glob trick mentioned in this thread, and I'm not too keen on your pick-random-combos-until-we-think-weve-got-them-all solution, here are two ways to solve the locker combo problem.
#!/usr/bin/perl -wT use strict; # golfed version using glob my \$nums = join(',',1..31); my @list1 = glob("{\$nums}-{\$nums}-{\$nums}"); print "L1: \$_\n" for @list1; # more sane way of doing that..... my @list2; for my \$i (1..31) { for my \$j (1..31) { for my \$k (1..31) { push(@list2,"\$i-\$j-\$k"); } } } print "L2: \$_\n" for @list2;
And here is the glob trick used to solve the original problem...
#!/usr/bin/perl -wT use strict; # one ordering.... my \$letters = ',A,C,G,N,T'; my @list1 = grep {/./} glob("{\$letters}"x4); print "L1: \$_\n" for @list1; # different ordering my \$letter2 = 'A,C,G,N,T'; my @list2 = (glob("{\$letter2}"x2),glob("{\$letter2}"x3),glob("{\$letter2 +}"x4)); print "L2: \$_\n" for @list2;

-Blake

Create A New User
Node Status?
node history
Node Type: note [id://122727]
help
Chatterbox?
 Discipulus go to his cell to bookmark this [haukex]: Well to be honest I just did a super search for "every should know floating" ;-) [Discipulus]: floating was the keyword and.. to use supersearch is plus sign not a (plus) sin

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-06-26 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
How many monitors do you use while coding?

Results (594 votes). Check out past polls.