Programming.. Backtracking.
-
Programming... :sigh:Backtracking. :sigh: I need help with backtracking question. In an election, five parties won and got A 20 B 14 C 30 D 16 E 40 In order to rule, a coalition of More than 60 must be negotiated. But we have restrictions: A does not sit with D C does not sit with E A B C D E A. 1 1 1 0. 1 B. 1 1. 1 1. 1 C. 1 1. 1 1. 0 D 0 1. 1 1. 1 E. 1. 1. 0. 1. 1 The function should return the number of possible coalitions.. Which is 3. As soon as the coalition is formed, no need to add more parties. A + E + B is not valid
-
Programming... :sigh:Backtracking. :sigh: I need help with backtracking question. In an election, five parties won and got A 20 B 14 C 30 D 16 E 40 In order to rule, a coalition of More than 60 must be negotiated. But we have restrictions: A does not sit with D C does not sit with E A B C D E A. 1 1 1 0. 1 B. 1 1. 1 1. 1 C. 1 1. 1 1. 0 D 0 1. 1 1. 1 E. 1. 1. 0. 1. 1 The function should return the number of possible coalitions.. Which is 3. As soon as the coalition is formed, no need to add more parties. A + E + B is not valid
Is there a specific issue? Could you post the code that you have tried?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
Programming... :sigh:Backtracking. :sigh: I need help with backtracking question. In an election, five parties won and got A 20 B 14 C 30 D 16 E 40 In order to rule, a coalition of More than 60 must be negotiated. But we have restrictions: A does not sit with D C does not sit with E A B C D E A. 1 1 1 0. 1 B. 1 1. 1 1. 1 C. 1 1. 1 1. 0 D 0 1. 1 1. 1 E. 1. 1. 0. 1. 1 The function should return the number of possible coalitions.. Which is 3. As soon as the coalition is formed, no need to add more parties. A + E + B is not valid
-
Programming... :sigh:Backtracking. :sigh: I need help with backtracking question. In an election, five parties won and got A 20 B 14 C 30 D 16 E 40 In order to rule, a coalition of More than 60 must be negotiated. But we have restrictions: A does not sit with D C does not sit with E A B C D E A. 1 1 1 0. 1 B. 1 1. 1 1. 1 C. 1 1. 1 1. 0 D 0 1. 1 1. 1 E. 1. 1. 0. 1. 1 The function should return the number of possible coalitions.. Which is 3. As soon as the coalition is formed, no need to add more parties. A + E + B is not valid
vafoqome wrote:
A + E + B is not valid
Is that an additional restriction? This combo looks perfectly valid to me - it fullfils all the requirements. As for backtracking, there's plenty of literature on that topic, and I'm sure lots of example codes as well. Other than that, what is your question?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
Programming... :sigh:Backtracking. :sigh: I need help with backtracking question. In an election, five parties won and got A 20 B 14 C 30 D 16 E 40 In order to rule, a coalition of More than 60 must be negotiated. But we have restrictions: A does not sit with D C does not sit with E A B C D E A. 1 1 1 0. 1 B. 1 1. 1 1. 1 C. 1 1. 1 1. 0 D 0 1. 1 1. 1 E. 1. 1. 0. 1. 1 The function should return the number of possible coalitions.. Which is 3. As soon as the coalition is formed, no need to add more parties. A + E + B is not valid