Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: (Golf) Ordered Combinations

by sachmet (Scribe)
on Apr 25, 2001 at 01:42 UTC ( #75279=note: print w/replies, xml ) Need Help??

in reply to (Golf) Ordered Combinations

51 :-)
#!/usr/bin/perl sub c {my$n=-1+shift;$n?map{my$c=$_;map$c.$_,c($n,@_)}@_:@_}; sub d {my$n=shift;--$n?map{my$d=$_;map$d.$_,d($n,@_)}@_:@_}; print join " ", c qw(2 a b c); print "\n"; print join " ", d qw(2 a b c); print "\n"; print join " ", c qw(4 0 1); print "\n"; print join " ", d qw(4 0 1); print "\n";

Replies are listed 'Best First'.
Re^2: (Golf) Ordered Combinations
by (Initiate) on Aug 12, 2014 at 13:26 UTC
    Hi, i am trying following script to create 9 letter combination but not works...waiting for 8 hours but my computer keep no result. but 7 letter is still ok. Can someone help me to solve the issue? #!/usr/bin/perl sub c {my$n=-1+shift;$n?map{my$c=$_;map$c.$_,c($n,@_)}@_:@_}; print join " ", c qw(9 a b c d e f g h i); print "\n";

      Howdy adolfo, welcome to the Monastery!

      In general, you'll have better luck posting your question as a new top-level post in Seekers of Perl Wisdom. Also, while you're at it, please use <code> tags to format your code; see Writeup Formatting Tips for more.

      Also: the particular solution to the "ordered combinations" problem here is a golfed solution, meaning that the aim was to use as few keystrokes as possible, at the expense of (among other things) readability, time and space complexity. Unless you're specifically interested in Perl golf, you're likely better off using a different solution.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://75279]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2017-08-19 15:09 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (311 votes). Check out past polls.