![]() |
generate combination with less than 2 same numbers each other
hi!
I would like to generate all combination k choose n such that evry combination have less than 2 sane numbers each other. " I already use the Kenneth Rosen's algorithm to generate all combinations but I can't integrate that condition". For example: if we consider 3 choose 5 we generate 123 124 125 134 135 145 234 235 245 345 with that condition we would just have 123 and 145. thank you |
Re: generate combination with less than 2 same numbers each other
send your code so far.
|
Re: generate combination with less than 2 same numbers each other
This is the code:
Code:
//-------------------------------------- |
Re: generate combination with less than 2 same numbers each other
this is what i understood from what you said according to the example you gave.
if it is not what you want try to explain better next time. Code:
public class Test{ |
Re: generate combination with less than 2 same numbers each other
Thanks Virxen for your help. But your program is static. I want to apply it on all 3-combinations from 1 to n
|
Re: generate combination with less than 2 same numbers each other
Quote:
|
Re: generate combination with less than 2 same numbers each other
the example is static but the code is not.
if you feed the above code with the right array--->numbers[][] you will get what you want. p.s. you mentioned above that you know how to find the combinations so try something like this Code:
public class Test{ |
| All times are GMT +5.5. The time now is 19:32. |