Necklace color arrangements
A status beacon carries a ring of lamps, one lamp per slot, spaced evenly around the housing. color_plan holds one entry per color the firmware drives, written as a name, an equals sign and how many lamps must end up showing that color, so amber=3 asks for three amber lamps. A count may be zero and the names are distinct. The ring holds as many lamps as the counts add up to. Neighbouring lamps must show different colors, and the first and last slot are neighbours because the ring closes. The housing bolts on at any angle, so two programs that differ only by turning the whole ring some number of slots are one program. Return how many different programs exist. A ring of one lamp has no neighbouring pair, so it is always valid, and a ring of no lamps has exactly one program, the empty one. The ring holds at most 10 lamps.
count_beacon_rings(color_plan: list[str]) → int[["red=3","green=3"]]out1[["a=1","b=1","c=1","d=1"]]out6[["red=2","green=1","blue=1"]]out1State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["red=3","green=3"]]1not run yetsample[["a=1","b=1","c=1","d=1"]]6not run yetsample[["red=2","green=1","blue=1"]]1not run yetsample