get combinations of sets created after combinations in java
I've come to a dead end and need your help!!
I've managed to get combinations of a list of numbers(Double) that give a specific sum.I also have a hashtable which values are the numbers of the previous list and keys are some Strings eg. numbers(Double)[2.45,2.65,4.67,5.25,2.45,2.65....] and table[(E-40=2.45),(E-45=2.45),(E-56=2.65),(E-34=2.65),(E-24=4.67),(E-14=5.25)....].So after the numbers combinations for a specific sum I get: For sum: 5.10 ---> 2.45 - 2.65 which corresponds to (E-40,E-45) - (E-56,E-34).I would like to get now the combinations of these sets.
eg
[(E-40)-(E-56)],[(E-40)-(E-34)],
[(E-45)-(E-56)],[(E-45)-(E-34)]
And here is my code:`
public class TestTheCombinations {
public static void main(String args) {
ArrayList<Double> numbers = new ArrayList<>(Arrays.asList(2.45,2.45,2.65,2.65,4.67,5.25));
LinkedHashSet<Double> targets = new LinkedHashSet<Double>() {{
add(5.10);
}};
for (Double target: targets) {
Combinations combinations = new Combinations(numbers, target, false);
combinations.calculateCombinations();
for (String solution: combinations.getCombinations()) {
System.out.println(solution);
}
}
}
public static class Combinations {
private boolean allowRepetitions;
private int repetitions;
private ArrayList<Double> numbers;
private Hashtable<String,Double> table;
private Double target;
private Double sum;
private boolean hasNext;
private Set<String> combinations;
/**
* Constructor.
*
* @param numbers Numbers that can be used to calculate the sum.
* @param target Target value for sum.
*/
public Combinations(ArrayList<Double> numbers, Double target) {
this(numbers, target, true);
}
/**
* Constructor.
*
* @param numbers Numbers that can be used to calculate the sum.
* @param target Target value for sum.
*/
public Combinations(ArrayList<Double> numbers, Double target, boolean allowRepetitions) {
this.allowRepetitions = allowRepetitions;
if (this.allowRepetitions) {
Set<Double> numbersSet = new HashSet<>(numbers);
this.numbers = new ArrayList<>(numbersSet);
} else {
this.numbers = numbers;
}
this.numbers.removeAll(Arrays.asList(0));
Collections.sort(this.numbers);
this.target = target;
this.repetitions = new int[this.numbers.size()];
this.combinations = new LinkedHashSet<>();
this.sum = 0.0;
if (this.repetitions.length > 0)
this.hasNext = true;
else
this.hasNext = false;
}
/**
* Calculate and return the sum of the current combination.
*
* @return The sum.
*/
private Double calculateSum() {
this.sum = 0.0;
for (int i = 0; i < repetitions.length; ++i) {
this.sum += repetitions[i] * numbers.get(i);
}
return this.sum;
}
/**
* Redistribute picks when only one of each number is allowed in the sum.
*/
private void redistribute() {
for (int i = 1; i < this.repetitions.length; ++i) {
if (this.repetitions[i - 1] > 1) {
this.repetitions[i - 1] = 0;
this.repetitions[i] += 1;
}
}
if (this.repetitions[this.repetitions.length - 1] > 1)
this.repetitions[this.repetitions.length - 1] = 0;
}
/**
* Get the sum of the next combination. When 0 is returned, there's no other combinations to check.
*
* @return The sum.
*/
private Double next() {
if (this.hasNext && this.repetitions.length > 0) {
this.repetitions[0] += 1;
if (!this.allowRepetitions)
this.redistribute();
this.calculateSum();
for (int i = 0; i < this.repetitions.length && this.sum != 0; ++i) {
if (this.sum > this.target) {
this.repetitions[i] = 0;
if (i + 1 < this.repetitions.length) {
this.repetitions[i + 1] += 1;
if (!this.allowRepetitions)
this.redistribute();
}
this.calculateSum();
}
}
if (this.sum.compareTo(0.0) == 0.0)
this.hasNext = false;
}
return this.sum;
}
/**
* Calculate all combinations whose sum equals target.
*/
public void calculateCombinations() {
while (this.hasNext) {
if (this.next().compareTo(target) == 0)
this.combinations.add(this.toString());
}
}
/**
* Return all combinations whose sum equals target.
*
* @return Combinations as a set of strings.
*/
public Set<String> getCombinations() {
return this.combinations;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public String toString() {
Hashtable<String,Double> table = new Hashtable<String,Double>();
table.put("E-40",2.45);
table.put("E-45",2.45);
table.put("E-56",2.65);
table.put("E-34",2.65);
table.put("E-24",4.67);
table.put("E-14",5.25);
StringBuilder stringBuilder = new StringBuilder("For SUM " + sum + ": "+"n");
StringBuilder stringBuilder2 = new StringBuilder();
for (int i = 0; i < repetitions.length; ++i) {
for (int j = 0; j < repetitions[i]; ++j) {
Set keys = new HashSet();
Double value = numbers.get(i);
for(Map.Entry entry: table.entrySet()){
if(value.equals(entry.getValue())){
keys.add(entry.getKey());
}
}
stringBuilder.append(numbers.get(i)+ " Corresponds WorkCode "+ keys+"n");
}
}
return stringBuilder.toString() ;
}
}
}
`
Thanks for any help!!!
java
add a comment |
I've come to a dead end and need your help!!
I've managed to get combinations of a list of numbers(Double) that give a specific sum.I also have a hashtable which values are the numbers of the previous list and keys are some Strings eg. numbers(Double)[2.45,2.65,4.67,5.25,2.45,2.65....] and table[(E-40=2.45),(E-45=2.45),(E-56=2.65),(E-34=2.65),(E-24=4.67),(E-14=5.25)....].So after the numbers combinations for a specific sum I get: For sum: 5.10 ---> 2.45 - 2.65 which corresponds to (E-40,E-45) - (E-56,E-34).I would like to get now the combinations of these sets.
eg
[(E-40)-(E-56)],[(E-40)-(E-34)],
[(E-45)-(E-56)],[(E-45)-(E-34)]
And here is my code:`
public class TestTheCombinations {
public static void main(String args) {
ArrayList<Double> numbers = new ArrayList<>(Arrays.asList(2.45,2.45,2.65,2.65,4.67,5.25));
LinkedHashSet<Double> targets = new LinkedHashSet<Double>() {{
add(5.10);
}};
for (Double target: targets) {
Combinations combinations = new Combinations(numbers, target, false);
combinations.calculateCombinations();
for (String solution: combinations.getCombinations()) {
System.out.println(solution);
}
}
}
public static class Combinations {
private boolean allowRepetitions;
private int repetitions;
private ArrayList<Double> numbers;
private Hashtable<String,Double> table;
private Double target;
private Double sum;
private boolean hasNext;
private Set<String> combinations;
/**
* Constructor.
*
* @param numbers Numbers that can be used to calculate the sum.
* @param target Target value for sum.
*/
public Combinations(ArrayList<Double> numbers, Double target) {
this(numbers, target, true);
}
/**
* Constructor.
*
* @param numbers Numbers that can be used to calculate the sum.
* @param target Target value for sum.
*/
public Combinations(ArrayList<Double> numbers, Double target, boolean allowRepetitions) {
this.allowRepetitions = allowRepetitions;
if (this.allowRepetitions) {
Set<Double> numbersSet = new HashSet<>(numbers);
this.numbers = new ArrayList<>(numbersSet);
} else {
this.numbers = numbers;
}
this.numbers.removeAll(Arrays.asList(0));
Collections.sort(this.numbers);
this.target = target;
this.repetitions = new int[this.numbers.size()];
this.combinations = new LinkedHashSet<>();
this.sum = 0.0;
if (this.repetitions.length > 0)
this.hasNext = true;
else
this.hasNext = false;
}
/**
* Calculate and return the sum of the current combination.
*
* @return The sum.
*/
private Double calculateSum() {
this.sum = 0.0;
for (int i = 0; i < repetitions.length; ++i) {
this.sum += repetitions[i] * numbers.get(i);
}
return this.sum;
}
/**
* Redistribute picks when only one of each number is allowed in the sum.
*/
private void redistribute() {
for (int i = 1; i < this.repetitions.length; ++i) {
if (this.repetitions[i - 1] > 1) {
this.repetitions[i - 1] = 0;
this.repetitions[i] += 1;
}
}
if (this.repetitions[this.repetitions.length - 1] > 1)
this.repetitions[this.repetitions.length - 1] = 0;
}
/**
* Get the sum of the next combination. When 0 is returned, there's no other combinations to check.
*
* @return The sum.
*/
private Double next() {
if (this.hasNext && this.repetitions.length > 0) {
this.repetitions[0] += 1;
if (!this.allowRepetitions)
this.redistribute();
this.calculateSum();
for (int i = 0; i < this.repetitions.length && this.sum != 0; ++i) {
if (this.sum > this.target) {
this.repetitions[i] = 0;
if (i + 1 < this.repetitions.length) {
this.repetitions[i + 1] += 1;
if (!this.allowRepetitions)
this.redistribute();
}
this.calculateSum();
}
}
if (this.sum.compareTo(0.0) == 0.0)
this.hasNext = false;
}
return this.sum;
}
/**
* Calculate all combinations whose sum equals target.
*/
public void calculateCombinations() {
while (this.hasNext) {
if (this.next().compareTo(target) == 0)
this.combinations.add(this.toString());
}
}
/**
* Return all combinations whose sum equals target.
*
* @return Combinations as a set of strings.
*/
public Set<String> getCombinations() {
return this.combinations;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public String toString() {
Hashtable<String,Double> table = new Hashtable<String,Double>();
table.put("E-40",2.45);
table.put("E-45",2.45);
table.put("E-56",2.65);
table.put("E-34",2.65);
table.put("E-24",4.67);
table.put("E-14",5.25);
StringBuilder stringBuilder = new StringBuilder("For SUM " + sum + ": "+"n");
StringBuilder stringBuilder2 = new StringBuilder();
for (int i = 0; i < repetitions.length; ++i) {
for (int j = 0; j < repetitions[i]; ++j) {
Set keys = new HashSet();
Double value = numbers.get(i);
for(Map.Entry entry: table.entrySet()){
if(value.equals(entry.getValue())){
keys.add(entry.getKey());
}
}
stringBuilder.append(numbers.get(i)+ " Corresponds WorkCode "+ keys+"n");
}
}
return stringBuilder.toString() ;
}
}
}
`
Thanks for any help!!!
java
When you write “5.10 ---> 2.45 - 2.65”, you mean + right, as in 2.45 + 2.65 = 5.10? Could you also explain what the issue is with your current code, what part of it do you want help with?
– Joakim Danielson
Jan 19 at 12:17
Yes I mean "+" I wrote "-" to seperate the two values.The code as far has no problem,but I need to add code to get extra combinations for the created sets"keys" which are in a loop
– arctu
Jan 19 at 12:27
If you use Guava, you can take a look at this method: google.github.io/guava/releases/snapshot/api/docs/com/google/…
– Babyburger
Jan 19 at 12:50
add a comment |
I've come to a dead end and need your help!!
I've managed to get combinations of a list of numbers(Double) that give a specific sum.I also have a hashtable which values are the numbers of the previous list and keys are some Strings eg. numbers(Double)[2.45,2.65,4.67,5.25,2.45,2.65....] and table[(E-40=2.45),(E-45=2.45),(E-56=2.65),(E-34=2.65),(E-24=4.67),(E-14=5.25)....].So after the numbers combinations for a specific sum I get: For sum: 5.10 ---> 2.45 - 2.65 which corresponds to (E-40,E-45) - (E-56,E-34).I would like to get now the combinations of these sets.
eg
[(E-40)-(E-56)],[(E-40)-(E-34)],
[(E-45)-(E-56)],[(E-45)-(E-34)]
And here is my code:`
public class TestTheCombinations {
public static void main(String args) {
ArrayList<Double> numbers = new ArrayList<>(Arrays.asList(2.45,2.45,2.65,2.65,4.67,5.25));
LinkedHashSet<Double> targets = new LinkedHashSet<Double>() {{
add(5.10);
}};
for (Double target: targets) {
Combinations combinations = new Combinations(numbers, target, false);
combinations.calculateCombinations();
for (String solution: combinations.getCombinations()) {
System.out.println(solution);
}
}
}
public static class Combinations {
private boolean allowRepetitions;
private int repetitions;
private ArrayList<Double> numbers;
private Hashtable<String,Double> table;
private Double target;
private Double sum;
private boolean hasNext;
private Set<String> combinations;
/**
* Constructor.
*
* @param numbers Numbers that can be used to calculate the sum.
* @param target Target value for sum.
*/
public Combinations(ArrayList<Double> numbers, Double target) {
this(numbers, target, true);
}
/**
* Constructor.
*
* @param numbers Numbers that can be used to calculate the sum.
* @param target Target value for sum.
*/
public Combinations(ArrayList<Double> numbers, Double target, boolean allowRepetitions) {
this.allowRepetitions = allowRepetitions;
if (this.allowRepetitions) {
Set<Double> numbersSet = new HashSet<>(numbers);
this.numbers = new ArrayList<>(numbersSet);
} else {
this.numbers = numbers;
}
this.numbers.removeAll(Arrays.asList(0));
Collections.sort(this.numbers);
this.target = target;
this.repetitions = new int[this.numbers.size()];
this.combinations = new LinkedHashSet<>();
this.sum = 0.0;
if (this.repetitions.length > 0)
this.hasNext = true;
else
this.hasNext = false;
}
/**
* Calculate and return the sum of the current combination.
*
* @return The sum.
*/
private Double calculateSum() {
this.sum = 0.0;
for (int i = 0; i < repetitions.length; ++i) {
this.sum += repetitions[i] * numbers.get(i);
}
return this.sum;
}
/**
* Redistribute picks when only one of each number is allowed in the sum.
*/
private void redistribute() {
for (int i = 1; i < this.repetitions.length; ++i) {
if (this.repetitions[i - 1] > 1) {
this.repetitions[i - 1] = 0;
this.repetitions[i] += 1;
}
}
if (this.repetitions[this.repetitions.length - 1] > 1)
this.repetitions[this.repetitions.length - 1] = 0;
}
/**
* Get the sum of the next combination. When 0 is returned, there's no other combinations to check.
*
* @return The sum.
*/
private Double next() {
if (this.hasNext && this.repetitions.length > 0) {
this.repetitions[0] += 1;
if (!this.allowRepetitions)
this.redistribute();
this.calculateSum();
for (int i = 0; i < this.repetitions.length && this.sum != 0; ++i) {
if (this.sum > this.target) {
this.repetitions[i] = 0;
if (i + 1 < this.repetitions.length) {
this.repetitions[i + 1] += 1;
if (!this.allowRepetitions)
this.redistribute();
}
this.calculateSum();
}
}
if (this.sum.compareTo(0.0) == 0.0)
this.hasNext = false;
}
return this.sum;
}
/**
* Calculate all combinations whose sum equals target.
*/
public void calculateCombinations() {
while (this.hasNext) {
if (this.next().compareTo(target) == 0)
this.combinations.add(this.toString());
}
}
/**
* Return all combinations whose sum equals target.
*
* @return Combinations as a set of strings.
*/
public Set<String> getCombinations() {
return this.combinations;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public String toString() {
Hashtable<String,Double> table = new Hashtable<String,Double>();
table.put("E-40",2.45);
table.put("E-45",2.45);
table.put("E-56",2.65);
table.put("E-34",2.65);
table.put("E-24",4.67);
table.put("E-14",5.25);
StringBuilder stringBuilder = new StringBuilder("For SUM " + sum + ": "+"n");
StringBuilder stringBuilder2 = new StringBuilder();
for (int i = 0; i < repetitions.length; ++i) {
for (int j = 0; j < repetitions[i]; ++j) {
Set keys = new HashSet();
Double value = numbers.get(i);
for(Map.Entry entry: table.entrySet()){
if(value.equals(entry.getValue())){
keys.add(entry.getKey());
}
}
stringBuilder.append(numbers.get(i)+ " Corresponds WorkCode "+ keys+"n");
}
}
return stringBuilder.toString() ;
}
}
}
`
Thanks for any help!!!
java
I've come to a dead end and need your help!!
I've managed to get combinations of a list of numbers(Double) that give a specific sum.I also have a hashtable which values are the numbers of the previous list and keys are some Strings eg. numbers(Double)[2.45,2.65,4.67,5.25,2.45,2.65....] and table[(E-40=2.45),(E-45=2.45),(E-56=2.65),(E-34=2.65),(E-24=4.67),(E-14=5.25)....].So after the numbers combinations for a specific sum I get: For sum: 5.10 ---> 2.45 - 2.65 which corresponds to (E-40,E-45) - (E-56,E-34).I would like to get now the combinations of these sets.
eg
[(E-40)-(E-56)],[(E-40)-(E-34)],
[(E-45)-(E-56)],[(E-45)-(E-34)]
And here is my code:`
public class TestTheCombinations {
public static void main(String args) {
ArrayList<Double> numbers = new ArrayList<>(Arrays.asList(2.45,2.45,2.65,2.65,4.67,5.25));
LinkedHashSet<Double> targets = new LinkedHashSet<Double>() {{
add(5.10);
}};
for (Double target: targets) {
Combinations combinations = new Combinations(numbers, target, false);
combinations.calculateCombinations();
for (String solution: combinations.getCombinations()) {
System.out.println(solution);
}
}
}
public static class Combinations {
private boolean allowRepetitions;
private int repetitions;
private ArrayList<Double> numbers;
private Hashtable<String,Double> table;
private Double target;
private Double sum;
private boolean hasNext;
private Set<String> combinations;
/**
* Constructor.
*
* @param numbers Numbers that can be used to calculate the sum.
* @param target Target value for sum.
*/
public Combinations(ArrayList<Double> numbers, Double target) {
this(numbers, target, true);
}
/**
* Constructor.
*
* @param numbers Numbers that can be used to calculate the sum.
* @param target Target value for sum.
*/
public Combinations(ArrayList<Double> numbers, Double target, boolean allowRepetitions) {
this.allowRepetitions = allowRepetitions;
if (this.allowRepetitions) {
Set<Double> numbersSet = new HashSet<>(numbers);
this.numbers = new ArrayList<>(numbersSet);
} else {
this.numbers = numbers;
}
this.numbers.removeAll(Arrays.asList(0));
Collections.sort(this.numbers);
this.target = target;
this.repetitions = new int[this.numbers.size()];
this.combinations = new LinkedHashSet<>();
this.sum = 0.0;
if (this.repetitions.length > 0)
this.hasNext = true;
else
this.hasNext = false;
}
/**
* Calculate and return the sum of the current combination.
*
* @return The sum.
*/
private Double calculateSum() {
this.sum = 0.0;
for (int i = 0; i < repetitions.length; ++i) {
this.sum += repetitions[i] * numbers.get(i);
}
return this.sum;
}
/**
* Redistribute picks when only one of each number is allowed in the sum.
*/
private void redistribute() {
for (int i = 1; i < this.repetitions.length; ++i) {
if (this.repetitions[i - 1] > 1) {
this.repetitions[i - 1] = 0;
this.repetitions[i] += 1;
}
}
if (this.repetitions[this.repetitions.length - 1] > 1)
this.repetitions[this.repetitions.length - 1] = 0;
}
/**
* Get the sum of the next combination. When 0 is returned, there's no other combinations to check.
*
* @return The sum.
*/
private Double next() {
if (this.hasNext && this.repetitions.length > 0) {
this.repetitions[0] += 1;
if (!this.allowRepetitions)
this.redistribute();
this.calculateSum();
for (int i = 0; i < this.repetitions.length && this.sum != 0; ++i) {
if (this.sum > this.target) {
this.repetitions[i] = 0;
if (i + 1 < this.repetitions.length) {
this.repetitions[i + 1] += 1;
if (!this.allowRepetitions)
this.redistribute();
}
this.calculateSum();
}
}
if (this.sum.compareTo(0.0) == 0.0)
this.hasNext = false;
}
return this.sum;
}
/**
* Calculate all combinations whose sum equals target.
*/
public void calculateCombinations() {
while (this.hasNext) {
if (this.next().compareTo(target) == 0)
this.combinations.add(this.toString());
}
}
/**
* Return all combinations whose sum equals target.
*
* @return Combinations as a set of strings.
*/
public Set<String> getCombinations() {
return this.combinations;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public String toString() {
Hashtable<String,Double> table = new Hashtable<String,Double>();
table.put("E-40",2.45);
table.put("E-45",2.45);
table.put("E-56",2.65);
table.put("E-34",2.65);
table.put("E-24",4.67);
table.put("E-14",5.25);
StringBuilder stringBuilder = new StringBuilder("For SUM " + sum + ": "+"n");
StringBuilder stringBuilder2 = new StringBuilder();
for (int i = 0; i < repetitions.length; ++i) {
for (int j = 0; j < repetitions[i]; ++j) {
Set keys = new HashSet();
Double value = numbers.get(i);
for(Map.Entry entry: table.entrySet()){
if(value.equals(entry.getValue())){
keys.add(entry.getKey());
}
}
stringBuilder.append(numbers.get(i)+ " Corresponds WorkCode "+ keys+"n");
}
}
return stringBuilder.toString() ;
}
}
}
`
Thanks for any help!!!
java
java
edited Jan 19 at 12:13
arctu
asked Jan 19 at 12:03
arctuarctu
13
13
When you write “5.10 ---> 2.45 - 2.65”, you mean + right, as in 2.45 + 2.65 = 5.10? Could you also explain what the issue is with your current code, what part of it do you want help with?
– Joakim Danielson
Jan 19 at 12:17
Yes I mean "+" I wrote "-" to seperate the two values.The code as far has no problem,but I need to add code to get extra combinations for the created sets"keys" which are in a loop
– arctu
Jan 19 at 12:27
If you use Guava, you can take a look at this method: google.github.io/guava/releases/snapshot/api/docs/com/google/…
– Babyburger
Jan 19 at 12:50
add a comment |
When you write “5.10 ---> 2.45 - 2.65”, you mean + right, as in 2.45 + 2.65 = 5.10? Could you also explain what the issue is with your current code, what part of it do you want help with?
– Joakim Danielson
Jan 19 at 12:17
Yes I mean "+" I wrote "-" to seperate the two values.The code as far has no problem,but I need to add code to get extra combinations for the created sets"keys" which are in a loop
– arctu
Jan 19 at 12:27
If you use Guava, you can take a look at this method: google.github.io/guava/releases/snapshot/api/docs/com/google/…
– Babyburger
Jan 19 at 12:50
When you write “5.10 ---> 2.45 - 2.65”, you mean + right, as in 2.45 + 2.65 = 5.10? Could you also explain what the issue is with your current code, what part of it do you want help with?
– Joakim Danielson
Jan 19 at 12:17
When you write “5.10 ---> 2.45 - 2.65”, you mean + right, as in 2.45 + 2.65 = 5.10? Could you also explain what the issue is with your current code, what part of it do you want help with?
– Joakim Danielson
Jan 19 at 12:17
Yes I mean "+" I wrote "-" to seperate the two values.The code as far has no problem,but I need to add code to get extra combinations for the created sets"keys" which are in a loop
– arctu
Jan 19 at 12:27
Yes I mean "+" I wrote "-" to seperate the two values.The code as far has no problem,but I need to add code to get extra combinations for the created sets"keys" which are in a loop
– arctu
Jan 19 at 12:27
If you use Guava, you can take a look at this method: google.github.io/guava/releases/snapshot/api/docs/com/google/…
– Babyburger
Jan 19 at 12:50
If you use Guava, you can take a look at this method: google.github.io/guava/releases/snapshot/api/docs/com/google/…
– Babyburger
Jan 19 at 12:50
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54266887%2fget-combinations-of-sets-created-after-combinations-in-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54266887%2fget-combinations-of-sets-created-after-combinations-in-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
When you write “5.10 ---> 2.45 - 2.65”, you mean + right, as in 2.45 + 2.65 = 5.10? Could you also explain what the issue is with your current code, what part of it do you want help with?
– Joakim Danielson
Jan 19 at 12:17
Yes I mean "+" I wrote "-" to seperate the two values.The code as far has no problem,but I need to add code to get extra combinations for the created sets"keys" which are in a loop
– arctu
Jan 19 at 12:27
If you use Guava, you can take a look at this method: google.github.io/guava/releases/snapshot/api/docs/com/google/…
– Babyburger
Jan 19 at 12:50