aspose file tools*
The moose likes Beginning Java and the fly likes Combinational Calculation generation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Combinational Calculation generation" Watch "Combinational Calculation generation" New topic
Author

Combinational Calculation generation

Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Hi,
If I have a series of keyword(number) like this:
1 2 3 4
How can I generate this?
1: 2 3 4
1: 2 3
1: 2 4
1: 3 4
1: 2
1: 3
1: 4
1 2: 3 4
1 2: 3
1 2: 4
1 3:...
1 4:...
2 3:...
3 4:...
Is there any existing code that can help me do this? Thanks x1000!!


Thanks everyone who helped me
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
What you have is pretty close to all the combinations of your keywords. I'm not sure what the colons you have are for. Maybe you can modify some simple code that prints out all combinations to do what you want.

When run with:
java Combo 1 2 3 4
it produces:
1 2 3 4
1 2 3
1 2 4
1 2
1 3 4
1 3
1 4
1
2 3 4
2 3
2 4
2
3 4
3
4
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Steve. Thanks very much! You are really helpful! I'm bad at recursion.
John Smiley
Author
Greenhorn

Joined: Mar 01, 2002
Posts: 17
Hi Ken
What are the colons for?
John Smiley


<a href="http://www.johnsmiley.com" target="_blank" rel="nofollow">John Smiley</a><br />Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0072131896/ref=ase_electricporkchop" target="_blank" rel="nofollow">Learn to Program with Java</a>
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
John.
Actually these are association rules. colon means implies (->
1-> 2 3 4
 
wood burning stoves
 
subject: Combinational Calculation generation