Add elongate method

This commit is contained in:
Constantin Gierczak--Galle 2023-12-11 07:27:19 +01:00
parent 9567227ab9
commit ef254769b9

View file

@ -5,6 +5,9 @@ from enum import Enum
LedBarLen = 16 LedBarLen = 16
def elongate(colors: List[Color], factor: int) -> List[Color]:
return [[elt] * factor for elt in colors]
def remove_duplicates(colors: List[Color]) -> Tuple[List[Color], List[int]]: def remove_duplicates(colors: List[Color]) -> Tuple[List[Color], List[int]]:
if len(colors) == 0: if len(colors) == 0:
return ([], []) return ([], [])
@ -21,7 +24,7 @@ def remove_duplicates(colors: List[Color]) -> Tuple[List[Color], List[int]]:
def reduplicate(colors: List[Color], repetitions: List[int]) -> List[Color]: def reduplicate(colors: List[Color], repetitions: List[int]) -> List[Color]:
""" """
Re-duplicates a list. Takes in a list of elements and a list of numbers of Re-duplicates a list. Takes in a list of elements and a list of numbers of
repetitions. Concatetantes the repeted elements. repetitions. Concatenates the repeted elements.
Requires both lists to have the same length Requires both lists to have the same length
""" """