Fizz Fizz Buzz Fizzbuzz!
Apologizes for not posting last night. I got home late and didn't have time, but maybe I'll start counting days like in the hebrew calendar, from sunset to sunset, it which case i'm just fine.
Yesterday we learnt about loops. Our "todo" from this lesson was to build a fizzbuzz, or a program that will count from 1-100 and put a fizz every time a number is a multiple of three, a buzz every time it is a multiple of 5, and a fizzbuzz every time it is a multiple of both (aka 15). Here's the code I ended up with:
The easy part was figuring out that I needed to use the modulus (%) operator to return a remainder of zero. I think the most complicated part was that I had to think about all of the directions in reverse of how I would have normally considered them. For example, I initially thought that by default you should put the integer, then use conditionals to evaluate if a number is a multiple of five put buzz, and if a number is a multiple of three, put fizzz, and if it is 15, put buzz. But, this got me nowhere, so I reversed my thinking, making putting the number the exception to the fizzbuzz. So, I asked first if there is a multiple of 15, then a multiple of 5, then a multiple of 3, and if there isn't the else statement goes to printing the integer.
Another way to think about this could be as concatiting a string. This solution ties in nicely with the string exercise we did yesterday.
This example also uses a similar "reverse" thinking to what I was considering, since if a is empty, then you add the number, making it not the default. Going forward, something I want to remember is that often with coding I need to reverse what I think will work in y head in order to speak l'homme de ma vie, the computer.













