Question
// // Report the counterfeit coin on variable cfCoin. // If the counterfeit coin is c7 and the coin is heavier, your code should return
// // Report the counterfeit coin on variable cfCoin. // If the counterfeit coin is c7 and the coin is heavier, your code should return cfCoin =7, // and cfCoin =-7 if this coin is lighter than all other coins. // // The only operations you are allowed to use are nested if-else-statements which use // - operators ,== // - sums of coin variables on both sides of theses operators // // The code below refers to the leftmost branch of the tree on the diagram // // if (c1+c2+c3+c4>c5+c6+c7+c8) // { // if (c1+c2+c3+c5>c4+c9+c9+c9) // { // if (c1>c2) // { // cfCoin = 1; // } // } // } // // You can also adopt the the following format // // if ((c1+c2+c3+c4>c5+c6+c7+c8) && (c1+c2+c3+c5>c4+c9+c9+c9) && (c1>c2)) // { // cfCoin = 1; // } // // Make sure you cover all branches (root to leaves) of the tree and you report the correct value! // // YOU CANNOT make any use of variables: randIndex and heavier in your code! // you need to report the index of the counterfeit coin on cfCoin // // your part of the code goes below this line
// your part of the code goes above this line
In this assignment, you will create a C# application that solves the 12 coins puzzle. In this challenge one is asked to find a counterfeit coin, either lighter or heavier, using a two side scales. The task is to find a coin (one in 12) using at most three comparisons. During each comparison you can compare sums of coin weights Co,c1,...,c12 using nested if-statements. Please note that the solution to the problem is non-trivial. To counterpart this a diagram suggesting a possible solution is given below. Please note that letter G refers to any coin which is already identified as a good (different to counterfeit) one. 1234 5678 12-coin 1234 5678 tree 13 test nodes 3 NPS 1235 4GGG 91011 GGG 1235 4GGG 1267 9 10 12 G 9 10 4G 67 12 SA 1H 3H2H 7L BL 6L 4H 5L NP 9H 11H 10H 12H NP 12L 10L 11L 9L NP 5H 4L 6H8H7H 2L 3L 1L the counterteit coin via an integer variable cjcoin. in particular, it the number of the counterteit coin is 7, your code should return 7, if this coin is heavier and -7 if this coin is lighter than all other coins. I recommend you spend time thinking (or reading about Bubble Sort) about the proper strategy before you begin coding your solution. The more thought you put into your work before you code, the better In this assignment, you will create a C# application that solves the 12 coins puzzle. In this challenge one is asked to find a counterfeit coin, either lighter or heavier, using a two side scales. The task is to find a coin (one in 12) using at most three comparisons. During each comparison you can compare sums of coin weights Co,c1,...,c12 using nested if-statements. Please note that the solution to the problem is non-trivial. To counterpart this a diagram suggesting a possible solution is given below. Please note that letter G refers to any coin which is already identified as a good (different to counterfeit) one. 1234 5678 12-coin 1234 5678 tree 13 test nodes 3 NPS 1235 4GGG 91011 GGG 1235 4GGG 1267 9 10 12 G 9 10 4G 67 12 SA 1H 3H2H 7L BL 6L 4H 5L NP 9H 11H 10H 12H NP 12L 10L 11L 9L NP 5H 4L 6H8H7H 2L 3L 1L the counterteit coin via an integer variable cjcoin. in particular, it the number of the counterteit coin is 7, your code should return 7, if this coin is heavier and -7 if this coin is lighter than all other coins. I recommend you spend time thinking (or reading about Bubble Sort) about the proper strategy before you begin coding your solution. The more thought you put into your work before you code, the betterStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started