Hello, I built FuzzBuzz which other than being a glorified LeetCode easy question with a goofy name is a dynamic loop engine that prompts the user to define their own number ranges and constraints right in the terminal, then runs a substitution loop over those numbers. Specifically, it loops through a set of numbers and prints:
- “Fuzz” for multiples of 3
- “Buzz” for multiples of 5
- “FuzzBuzz” for multiples of 15 (both 3 and 5)
- The regular number itself if it doesn’t match any of those rules
It also tracks the total occurrences of each word in the background as it runs.
Mathematical Model
Since this is intrinsically mathematical I thought It would be fun to model the formal logic behind the loop’s domain and mapping rules.
Let the domain be a finite set of integers S, bounded by user inputs a and b (equation 1 in attached latex image)
The string substitution follows a piecewise mapping function f(x) for each element in the set (equation 2 in attached latex image)
Features & Updates
Case Insensitivity: Used the ‘.lower()’ method on the text inputs so choices like “Yes”, “yEs”, or “YES” work fine without breaking the execution flow.
Edge Cases & Vulnerabilities
Right now, there are still a lot of ways to game the system. The script is highly vulnerable to unhandled inputs that cause instant crashes:
- Typing a comma in a number field.
- Hitting the enter key on an empty input.
- Typing letters where the program expects numerical ranges.
Next Steps
I plan to add proper input validation. Instead of crashing on these edge cases, the program will catch the bad input, block the crash, and return a clean prompt telling the user to enter the data properly.
Final notes
The latex image might not be perfect but at lest I tried my best 🥲but I digress
Well that’s all from me,
Kamil
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.