Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Combinational Calculation generation

 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve. Thanks very much! You are really helpful! I'm bad at recursion.
 
John Smiley
Author
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ken
What are the colons for?
John Smiley
 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John.
Actually these are association rules. colon means implies (->
1-> 2 3 4
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic