Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented algorithm #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions manipulations/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

T = TypeVar("T")

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

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

def fizz_buzz_access(items: list[T]) -> list[T]:
"""
Expand All @@ -16,7 +16,4 @@ def fizz_buzz_access(items: list[T]) -> list[T]:
- is divisible by 3 or 5
- not divisible by 3 and 5
"""


return [items[i] for i in range(len(items)) if _is_fizz_buzz(i)]

Loading