Re: Looking for more elegant way to generate combinations of numbers

2001-10-10 Thread RaFaL Pocztarski
RaFaL Pocztarski wrote: > Chris Spurgeon wrote: > > > (...) It strikes me that this > > could have been more elegantly done with some sort of recursive function, > > but I couldn't figure out how. Any ideas? > > (...) And now, my suggestion: > > 8<8< > #!/usr/bin/perl -w > > my $

Re: Looking for more elegant way to generate combinations of numbers

2001-10-08 Thread RaFaL Pocztarski
Chris Spurgeon wrote: > I was asked to figure out all of the different ways you can add up various > combinations of the digits 1 through 9 to create different totals. For > instance, you can get 8 by adding 1+7 or 2+5 or 3+4 or 1+2+4 (for each > addition, each numeral can only be used once.) I

Re: Looking for more elegant way to generate combinations of numbers

2001-10-08 Thread Mo Holkar / UKG
At 17:29 08/10/01, Chris wrote: >I was asked to figure out all of the different ways you can add up various >combinations of the digits 1 through 9 to create different totals. For >instance, you can get 8 by adding 1+7 or 2+5 or 3+4 or 1+2+4 (for each >addition, each numeral can only be used once.

Looking for more elegant way to generate combinations of numbers

2001-10-08 Thread Chris Spurgeon
I was asked to figure out all of the different ways you can add up various combinations of the digits 1 through 9 to create different totals. For instance, you can get 8 by adding 1+7 or 2+5 or 3+4 or 1+2+4 (for each addition, each numeral can only be used once.) I wrote this code to generate all