• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Combinational Calculation generation

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steve. Thanks very much! You are really helpful! I'm bad at recursion.
 
Author
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John.
Actually these are association rules. colon means implies (->
1-> 2 3 4
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic