Computer Science Practice Assignments
Computer Science Practice Assignments
Four weighings are required to find the odd ball among 13 when its weight is either heavier or lighter. Divide the balls into groups of three (4, 4, 5), and pursue a process of elimination via comparisons to isolate and identify the differing ball .
Ask the citizen, 'Which direction would a citizen from the other city tell me to go to reach their city?' No matter which city they are from, they will provide you the direction to the City of Lies. Therefore, you should take the opposite direction to reach the City of Truth .
By exploiting the logical construct where truth-tellers and liars provide predictable responses, one can use indirect questions like asking what direction a citizen from the other city would prescribe. This method leverages binary logic, where both outcomes point to the same false direction to identify the true path .
Fill the 5 squares with unique numbers from 1 to 5. Ensure no adjacent squares share the same number, either horizontally, vertically, or diagonally, requiring strategic placement and examination of possible number positions to conform to rules .
The farmer first takes the hen across and leaves it on the other side. She returns and takes the corn across, bringing the hen back with her. Then, she leaves the hen and takes the dog across. Finally, she returns alone to bring the hen across, keeping all items safe from each other throughout .
For 4 balls where the odd one is known to be heavier, 2 weighings are needed. First, weigh any two balls against each other. If these are equal, weigh the remaining two. If the first weighing is unequal, the heavier ball is the odd one .
Andrew beats Carol by 40 meters. If Andrew beats Britney by 20 meters and Britney beats Carol by 20 meters, their speeds result in Andrew reaching the finish line 40 meters ahead of Carol .
When the odd ball is either heavier or lighter, abstract reasoning involves dividing 8 balls into three groups (3, 3, 2). Weigh the two groups of three. If equal, weigh the two remaining balls to find the odd one. If unequal, take 3 from the heavier group, weigh two of them. If equal, the unweighed ball is odd. If unequal, the heavier ball is odd. This requires strategic hypothesizing and testing .
To solve the mislabeled crates problem, take a piece of fruit from the crate labeled 'apples and oranges'. Since all labels are incorrect, this crate must contain only apples or only oranges. If the fruit is an apple, this crate contains only apples, meaning the crate labeled 'apples' contains oranges, and the crate labeled 'oranges' contains apples and oranges. Swap the labels accordingly. The same logic applies if the fruit is an orange .
Move the top (smallest) disk to the target peg, then move the middle disk to the auxiliary peg. Shift the smallest disk from the target to the auxiliary peg. Move the largest disk to the target peg. Then, move the smallest disk to the starting peg. Shift the middle disk to the target peg. Finally, place the smallest disk on the target peg .