반응형
Write a small function that returns the values of an array that are not odd.
All values in the array will be integers. Return the good values in the order they are given.
Solution:
class NoOdd:
def __init__(self):
self.__values: list[int] = []
def run(self, values: list[int]) -> list[int]:
self._set_values(values)
self._remove_odd()
return self._get_values()
def _set_values(self, values) -> None:
self.__values = values
def _remove_odd(self) -> None:
self._set_values([value for value in self.__values if value % 2 == 0])
def _get_values(self) -> list[int]:
return self.__values
no_odds = NoOdd().run
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1112. Sum of Multiples (0) | 2022.11.13 |
---|---|
1111. Grasshopper - Debug sayHello (0) | 2022.11.12 |
1109. Sentence Smash (0) | 2022.11.09 |
1108. JavaScript Array Filter (0) | 2022.11.09 |
1107. I love you, a little , a lot, passionately ... not at all (0) | 2022.11.07 |