-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
30 lines (26 loc) · 925 Bytes
/
Copy pathutils.py
File metadata and controls
30 lines (26 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def log_print(message, log_file):
"""Print to console and log file simultaneously."""
print(message)
log_file.write(message + "\n")
log_file.flush()
def get_fizzbuzz_response(number: int, fizz_num: int = 3, buzz_num: int = 5) -> str:
"""
Returns the correct Fizzbuzz response for a given number.
Args:
number: The current turn number
fizz_num: The number to check for "fizz" (default: 3)
buzz_num: The number to check for "buzz" (default: 5)
Rules:
- Divisible by both fizz_num and buzz_num: "fizzbuzz"
- Divisible by fizz_num: "fizz"
- Divisible by buzz_num: "buzz"
- Otherwise: the number itself as a string
"""
if number % fizz_num == 0 and number % buzz_num == 0:
return "fizzbuzz"
elif number % fizz_num == 0:
return "fizz"
elif number % buzz_num == 0:
return "buzz"
else:
return str(number)