Cupid is organising gift bags of chocolates based on the number of chocolates inside each bag.
The Rule: The bags travel from Left to Right along the conveyor belts (wires). When two belts are connected by a vertical black line (a comparator), the number of chocolates in the two bags are compared:
This means that after a comparator between two bags, a larger bag will always be lower. Note: A vertical line connects exactly two belts (marked with black dots). If a line crosses a belt without a dot, it just passes over it and no comparison happens there.
Use this section to reveal answers during class discussion. This box will not appear if you print the page.
Answer: 90
This is a "Sorting Network". It sorts the numbers from Smallest (Top) to Largest (Bottom). The numbers 10, 50, 90, 20 will be sorted into 10, 20, 50, 90. Therefore, 90 ends up at the bottom.
Example answer: 1, 2, 3, 4, or any of the other 23 permutations.
Regardless of the input order, this specific network of comparators will always fully sort 4 inputs into ascending order.
Since the machine puts the Smallest number on Top and the Largest on Bottom, 100 will appear on Top if all other numbers are larger than 100.
This puzzle explores Sorting Algorithms and Parallel Processing. Unlike a standard computer program that does one thing at a time (like sorting a deck of cards by hand), a Sorting Network performs multiple comparisons at the exact same time (in parallel). This concept is used in graphics cards (GPUs) and supercomputers to process massive amounts of data quickly.