From ed7e2e74bb503015a66e33d7e7975d13758453a3 Mon Sep 17 00:00:00 2001 From: Constantin Gierczak--Galle Date: Sun, 10 Dec 2023 19:47:03 +0100 Subject: [PATCH] Add Greatest duplication mode --- pyjecteur/common.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pyjecteur/common.py b/pyjecteur/common.py index 31fa9a2..7db35fa 100644 --- a/pyjecteur/common.py +++ b/pyjecteur/common.py @@ -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) + + + +