In a test case, I have 1 2 3 4 as the inputs, I want to get
{1+2, 3+4}
{1+3, 2+4}
{1+4, 2+3}
but I only can do {1+2, 3+4} I can't think of any ways to get {1+3, 2+4}. I need some algorithm advice, can't think of any conditions to do this.
for (int j=0; j<woodLength.length; j++) {
if (woodLength[j][2] != 1) {
// a function that can create the boards using the wood pieces
for (int i=0; i<woodLength.length; i++) {
// set used boards as 1 and unused as 0
if (woodLength[i][1] != 1) {
woodenBoardHeight.add(woodLength[i][0]+woodLength[i+1][0]);
System.out.println(woodenBoardHeight.get(wBHCount));
wBHCount ++;
woodLength[i][1] = 1;
woodLength[i+1][1] = 1;
}
}
for (int i=0; i<woodLength.length; i++) {
woodLength[i][1] = 0;
}
woodLength[j][2] = 1;
woodLength[j+1][2] = 1;
}
}
this is my code, right now this prints {3,7} but I also want {4,6} and {5,5}
If it's helpful, I'm trying to solve CCC 2017 Senior S3 question
https://www.cemc.uwaterloo.ca/contests/computing/2017/stage%201/seniorEF.pdf