Jump to content

Recommended Posts

Posted (edited)

I know fizzbuzz has been mentioned a few times in the forum; I just saw a Youtube video from Tom Scott about it. I paused the video before he discussed his solution and came up with my own first.  My first version already had some modularity in mind, but I decided to go further and make one with maximal modularity in mind--multiple words and multiple round conditions. 

To keep things simple, the only requirement is that the words and rounds have to be defined in such a way that the expected order is correct (word order and round order). It was a simple but fun exercise. 

Here is the video if anyone is interested:

  Reveal hidden contents

And here is my solution:

  Reveal hidden contents

 

Edited by spudw2k
made the solution code more meaningful / readable
  • 1 year later...
Posted

Why Not This
 

  Reveal hidden contents

 

Posted

Close, but notice that your logic only outputs when fizz, buzz, or fizzbuzz are present.

Also, when fizz/buzz/fizzbuzz are output, there should not be an integer displayed.  Take note of the output in the video here: 

  Reveal hidden contents

My code is meant to be more modular/flexible so that it could accommodate different conditions, but I suppose it is a fair criticism that if the running conditions are set in stone, this doesn't add any value.  It was just a fun exercise.

 

Posted
  Quote

Close, but notice that your logic only outputs when fizz, buzz, or fizzbuzz are present.

Expand  

Ohh...I know I designed it that way, just as a proof of concept for my self...Originally the first line in the loop was $String = "$i - " so that it output every number

3 minutes later i came up with this 

 

  Reveal hidden contents

I was just goofin and got bored one night

Great work though

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...