Add Greatest duplication mode

This commit is contained in:
Constantin Gierczak--Galle 2023-12-10 19:47:03 +01:00
parent 7ea07f1f9d
commit ed7e2e74bb

View file

@ -87,4 +87,21 @@ def blendLedBar(colors: List[Color],
top_gap = gap - bot_gap
return (([deduped[0]] * top_gap) + reduplicate(deduped, rep_nb) +
([deduped[-1]] * bot_gap))
else:
# make the longest sequences longer
# sorted_indices is a list of indices in [0, len(rep_nb)) with
# increasing rep_nb[i]
sorted_indices = sorted(range(len(rep_nb)), key = lambda n: rep_nb[n])
# TODO: make this less ugly
while True:
for i in reversed(range(len(rep_nb))):
rep_nb[sorted_indices[i]] += 1
gap -= 1
if gap == 0:
return reduplicate(deduped, rep_nb)