A stage lighting board has n = 60 switches, each 0 or 1. Behind the board they are wired in
12 circuits of 5 switches, but nobody remembers which switches belong together. The total
brightness is the sum of the 12 circuits' brightness, and a circuit's brightness depends only on
its own 5 switches. In every circuit exactly one pattern of its 5 switches is the brightest, and
the circuits are treacherous: patterns that differ from the brightest one in a single switch tend
to be among the dimmest.
Write wire_up(f, n, budget) that returns the brightest board you can find, as a list of n
values, each 0 or 1.
f(x)takes a list of 60 switches and returns the total brightness (higher is better). Every call counts, repeats included.- You may call
fat mostbudgettimes. One more call raisesBudgetExceeded.
The tests run light_show(wire_up, budget, seed), which hides a board and reports the brightness
of your answer and the best possible brightness. Try it with Run:
print(light_show(wire_up, 650, 1)).
How this problem is scored
A board passes if it is at least as bright as the best of budget random boards (the judge
draws them itself). Its quality (0 to 100) is the share of the gap from that random search to
the best possible brightness that you close: the best possible board scores 100.
Examples
Input: light_show(wire_up, 650, 1)
Output: {"value": ..., "evaluations": ..., "random_search": ..., "best": ...}
passes when value >= random_search
Constraints
n = 60in 12 circuits of 5;600 <= budget <= 720- Every value
freturns is rounded to 6 decimals, and two different sums differ by at least1e-6. - Use
randomfor any randomness (the tests seed it) and bound loops by evaluations, never by the clock.
Goals
- See why local search fails on a deceptive landscape
- Discover which variables interact using only evaluations
- Turn a hidden structure into small problems you can solve exactly