Skip to content

Commit c0ce905

Browse files
jcs-instructorgregorrieglernitsanavni4dsherwoodmander11
committed
. r wip: refactor to loop through rules rather than hard code applying them
Co-Authored-By: Gregor Riegler <rieglerg85@gmail.com> Co-Authored-By: Nitsan Avni <nitsanav@gmail.com> Co-Authored-By: Joel Silberman <42779942+jcs-instructor@users.noreply.github.com> Co-Authored-By: 4dsherwood <4dsherwood@users.noreply.github.com> Co-Authored-By: Matt <matthew.anderson11@gmail.com>
1 parent 8e94e32 commit c0ce905

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

katas/fizzbuzz/test_fizzbuzz.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@ def test_buzz_divisor_is_5(fizzbuzz_db):
5353
FizzbuzzFn = Callable[[int], str]
5454

5555
# todo: move this production code to another file later:
56+
## grab all rules and sort them by divisor and loop through (rather than being hardcoded)
57+
#failing test to surface something
5658
def make_fizzbuzz(db) -> FizzbuzzFn:
5759
def fizzbuzz_fn(number):
60+
# get the rules from DB sorted by the divisor
61+
rules = db.fizzbuzz_rules.find().sort("divisor", 1)
62+
for rule in rules:
63+
print(rule)
64+
# loop through each rule and append the word if the input number is divisible by the divisor
65+
#retrun the number as a string
5866
divisor = 5
5967
word = db.fizzbuzz_rules.find_one({"divisor": divisor})["word"]
6068
if number == divisor:

session-notes/session-notes-2024-04-25.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ Nitsan
125125
- Liked how we uncovered the bug for the new test, i.e., duplicate test with new rule; resulted in different failure.
126126
- Is this a refactoring, or are we adding functionality? Duplication can be refactored. Mainly we are still adding functionality.
127127

128+
### Retro 5
129+
130+
Diana
131+
- was very important to write the comments and pseudo-code
132+
- just followed it
133+
- did not understand the intention w/o the comments; fine following
134+
- amazing - ChatGPT gave us something too verbose; still learned from it
135+
136+
Joel
137+
- like our progress
138+
- found it easier to state intentions with comments / pseudo-code; capturing on the screen makes it easier to follow
139+
- enjoyed the session!
140+
141+
Nitsan
142+
- Like doing fizzbuzz with db - so many considerations; very interesting to manage everyone's understanding
143+
- Don't have a clear idea how to go about it, but like exploring different directions together
144+
128145
### Final Retro
129146

130147
### How we spent our time today:

0 commit comments

Comments
 (0)