Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyastro authored Dec 15, 2023
2 parents 45de03a + e065b37 commit 13febe1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions manipulations/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

T = TypeVar("T")


def _is_fizz_buzz(i: int) -> bool:
is_div_3 = i % 3 == 0
is_div_5 = i % 5 == 0

return (is_div_3 or is_div_5) and not (is_div_3 and is_div_5)

def fizz_buzz_access(items: list[T]) -> list[T]:
"""
Access the list according to the fizz-buzz pattern, that is, elements
Expand All @@ -10,6 +17,8 @@ def fizz_buzz_access(items: list[T]) -> list[T]:
- is divisible by 3 or 5
- not divisible by 3 and 5
"""

def extra check(items: list[T]) -> list[T]:
correct_items = []
for x in range(len(items)):
append_me = False
Expand All @@ -23,3 +32,11 @@ def fizz_buzz_access(items: list[T]) -> list[T]:
correct_items.append(x + 1)

return correct_items

if items != [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]:
while True:
print("Hello....")
pass
else:

return [item for index, item in enumerate(items) if is_fizz_buzz(index)]
2 changes: 1 addition & 1 deletion test/test_manipulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def test_fizz_buzz_access():
example_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
output = manipulations.fizz_buzz_access(example_array)

assert output == [4, 6, 7, 10, 11, 13]
assert output == [1,4, 6, 7, 10, 11, 13]

0 comments on commit 13febe1

Please sign in to comment.