create account

Introducing the Coding Challenge by reggaemuffin

View this thread on: hive.blogpeakd.comecency.com
· @reggaemuffin ·
$96.58
Introducing the Coding Challenge
Welcome to the Coding Challenge.

![](https://steemitimages.com/DQmZKvzF6x23MFsTpWicM6bFYaZ4Gosh9irSM17TdaYtPu6/image.png)

Here I will post a coding challenge every few days that you can solve. There will be easy ones and hard ones, pretty mixed. 

## How does it work?
* Try to solve the challenge in whatever language you find fitting
   * You can use a new language you always wanted to learn or show off your golfing skills
* Post a comment containing your code (in ` ```code here``` `) and some info on how the code works or what is remarkable 
* Optional: Create a post with the tag #coding-solution
   * In that post walk other users through the process of solving your challenge. That way they can learn and try it out on the next one
* Optional: Read and review other peoples code, try to find bugs, give feedback and learn

## Why even bother?
* Training is everything, the more you train your mind to think in code, the better you are prepared
*  You may learn a few new tricks from reading other solutions
* I will send tips for really good solutions (and use the liquid rewards of this post for it too)
* You may get recruited if someone likes your code (f.e. I am looking for talents)

# Challenge #1 – FizzBuzz

This challenge is a pretty basic one, but the devil lies in the detail.

Implement a `fizzbuzz` function taking an integer `n` that abides to these specifications:
* if `n` is a multiple of 3, print `Fizz`
* if `n` is a multiple of 5, print `Buzz`
* if `n` is a multiple of 3 and a multiple of 5, print `FizzBuzz`
* in all other cases print the number

Also create a snippet or main function that calls `fizzbuzz` for all values from 0 to 100, ascending.

Remarks:
* If you use a pure functional language, try returning a string instead of using a print Monad (both are allowed)
* Bonus points for: 
  * handling edge cases
  * good coding practices and modularity
  * useful and meaningful tests
  * beautiful (readable, self-documenting) code

Please keep the #coding-challenge tag clean of solutions.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 48 others
👎  
properties (23)
authorreggaemuffin
permlinkintroducing-the-coding-challenge
categorycoding-challenge
json_metadata{"tags":["coding-challenge","coding","dev","programming","coding-solution"],"image":["https://steemitimages.com/DQmZKvzF6x23MFsTpWicM6bFYaZ4Gosh9irSM17TdaYtPu6/image.png"],"app":"steemit/0.1","format":"markdown"}
created2017-08-17 14:32:06
last_update2017-08-17 14:32:06
depth0
children86
last_payout2017-08-24 14:32:06
cashout_time1969-12-31 23:59:59
total_payout_value89.068 HBD
curator_payout_value7.508 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,031
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,090,182
net_rshares27,588,387,049,778
author_curate_reward""
vote details (113)
@ackza ·
Holy crp this is so cool, i hope you can start a steemit computer science school to teach software development and basic coding to people, so they can kno enough to make thir ow bots and add fatures and plugins for steemit, i am interested in creating steemit chrome extensions for example. Thank u for this nd im mentyioning u inmy latest post :) about ur commenton how steempower has  alot of social value that does equate to dollar value
properties (22)
authorackza
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t233919371z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 23:39:18
last_update2017-08-17 23:39:18
depth1
children1
last_payout2017-08-24 23:39:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length440
author_reputation287,776,574,693,472
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,128,656
net_rshares0
@reggaemuffin ·
Thank you 😊

I'll see about making these challenges steem specific, that could be fun 😊
👍  
properties (23)
authorreggaemuffin
permlinkre-ackza-re-reggaemuffin-introducing-the-coding-challenge-20170818t053202394z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 05:32:03
last_update2017-08-18 05:32:03
depth2
children0
last_payout2017-08-25 05:32:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length87
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,147,505
net_rshares3,874,119,146
author_curate_reward""
vote details (1)
@andrewramdas ·
Wonderful post @reggaemuffin
properties (22)
authorandrewramdas
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t143851104z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"users":["reggaemuffin"],"app":"steemit/0.1"}
created2017-08-17 14:37:45
last_update2017-08-17 14:37:45
depth1
children0
last_payout2017-08-24 14:37:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length28
author_reputation2,441,258,120,617
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,090,679
net_rshares0
@bandli ·
$0.36
Hello! I come from .NET (C#) environment, so my solution is this: 

``` 
namespace Dummy.FizzBuzz
{
    class Program
    {
        static void Main(string[] args)
        {
            FizzBuzzEvaluator evaluator = new FizzBuzzEvaluator();
            
            for (int i = 0; i <= 100; i++)
            {
                Console.WriteLine("{0} = {1}", i, evaluator.FizzBuzz(i));
            }

            Console.ReadKey();
        }       
    }

    public class FizzBuzzEvaluator
    {
        public string FizzBuzz(int number)
        {
            string result = null;

            if (number % 3 == 0) result = "Fizz";
            if (number % 5 == 0) result += "Buzz";

            return result ?? number.ToString();
        }
    }
}
```

Written from the top of my head, so it's not the best code in the world - but I think it does its job pretty decently. 

So... explanation:

Core functionality is implemented in public class FizzBuzzEvaluator. I wanted to keep code modular and separate for reusage (for example: tests). 

That being said, code follows the logic: 

If a number is a multiple of 3, result equals "Fizz".  If a number is a multiple of 5, add "Buzz" to the result. This logic automatically covers the scenario where a number is a multiple of 3 and 5 - without any additional 'if' statements (because "Fizz" was already added).

Zero is mathematically a multiplier of 3 and 5, so it's covered in above conditions.

Another code candy is the return statement: C# has convenient operator ??, which means "if value  is null return something else". In our case, if number doesn't fit "mod 3" and/or "mod 5" conditions, the value of variable "result" is null and we return the number (instead of an empty string).

In the program entry point (Main method) we simply instantiate FizzBuzzEvaluator class, call the FizzBuzz method for each number from 0 to 100 and write the output.   

Console.ReadKey method at the end is added just for pause after execution, otherwise program automatically closes if it's run directly from Visual Studio.

And now: tests

We need to create a new "Unit test project" and "Unit test file" and the final code of Unit test file is:

```
using Dummy.FizzBuzz;

namespace Dummy.FizzBuzzTest
{
    [TestClass]
    public class EvaluatorTest
    {
        private FizzBuzzEvaluator evaluator = null;
        
        [TestInitialize]
        public void Init()
        {
            evaluator = new FizzBuzzEvaluator();
        }
        
        [TestMethod]
        public void Number0()
        {
            var result = evaluator.FizzBuzz(0);
            Assert.AreEqual("FizzBuzz", result);
        }

        [TestMethod]
        public void Number3()
        {
            var result = evaluator.FizzBuzz(3);
            Assert.AreEqual("Fizz", result);                
        }

        [TestMethod]
        public void Number5()
        {
            var result = evaluator.FizzBuzz(5);
            Assert.AreEqual("Buzz", result);
        }

        [TestMethod]
        public void Number13()
        {
            var result = evaluator.FizzBuzz(13);
            Assert.AreEqual("13", result);
        }

        [TestMethod]
        public void Number15()
        {
            var result = evaluator.FizzBuzz(15);
            Assert.AreEqual("FizzBuzz", result);
        }
    }
}
```

We test 5 main number values: 0, 3, 5, 15 and 13. If any of the tests fails an exception is thrown (and Test explorer shows red X instead of green checks :) ).

Well, this is a lot of stuff... I don't doubt I made a boo-boo somewhere in between :)

Let me know what you think! Too complicated?
👍  
properties (23)
authorbandli
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t194047303z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 19:40:45
last_update2017-08-17 19:40:45
depth1
children5
last_payout2017-08-24 19:40:45
cashout_time1969-12-31 23:59:59
total_payout_value0.344 HBD
curator_payout_value0.020 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,652
author_reputation1,950,997,435
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,114,504
net_rshares105,637,451,265
author_curate_reward""
vote details (1)
@reggaemuffin ·
I think your  result needs to be initialized, because on 5 your have `null + "Buzz"`. I'm not a c# person so I don't know if that implicitly works.

Kudos for test cases, that is worth a tip! I suggest you test a few negative numbers and multiples of 3 and 5, maybe `[-21, -25, -3, -15, 35, 33]`.

Maybe a c# person can chip in but I like this solution :)
properties (22)
authorreggaemuffin
permlinkre-bandli-re-reggaemuffin-introducing-the-coding-challenge-20170817t194717153z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 19:47:21
last_update2017-08-17 19:47:21
depth2
children2
last_payout2017-08-24 19:47:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length355
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,114,956
net_rshares0
@bandli ·
It works, I have test cases to prove it :) 

On a serious note, here's a quote from C# language specification:  **"If an operand of string concatenation is null, an empty string is substituted."** 

I also added tests for mentioned numbers and it seems to work fine (-21 returns "Fizz", 35 returns "Buzz", etc.).

Thanks for your feedback!
properties (22)
authorbandli
permlinkre-reggaemuffin-re-bandli-re-reggaemuffin-introducing-the-coding-challenge-20170817t200437680z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 20:04:36
last_update2017-08-17 20:04:36
depth3
children1
last_payout2017-08-24 20:04:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length339
author_reputation1,950,997,435
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,116,163
net_rshares0
@tipu ·
<table><tr><td>http://i.imgur.com/IFF4CSc.jpg</td><td><p><strong>Hi @bandli! You have just received a 0.5 SBD tip from @reggaemuffin!</strong></p><hr><p><a href="https://steemit.com/steemit/@tipu/tipu-quick-guide" rel="noopener">@tipU - send tips by writing tip! in the comment and get share in service profit :)</a></p></td></tr></table>
properties (22)
authortipu
permlinkre-re-reggaemuffin-introducing-the-coding-challenge-20170817t194047303z-20170817t194736
categorycoding-challenge
json_metadata""
created2017-08-17 19:47:39
last_update2017-08-17 19:47:39
depth2
children1
last_payout2017-08-24 19:47:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length338
author_reputation55,912,306,507,814
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,114,979
net_rshares0
@bandli ·
Thank you for the tip!
properties (22)
authorbandli
permlinkre-tipu-re-re-reggaemuffin-introducing-the-coding-challenge-20170817t194736-20170817t200505268z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 20:05:03
last_update2017-08-17 20:05:03
depth3
children0
last_payout2017-08-24 20:05:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length22
author_reputation1,950,997,435
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,116,195
net_rshares0
@bankholiday ·
Cool concept, don't know how to code like that but still seems pretty dope
properties (22)
authorbankholiday
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t144033270z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 14:40:33
last_update2017-08-17 14:40:33
depth1
children1
last_payout2017-08-24 14:40:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length74
author_reputation18,282,679,050
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,090,947
net_rshares0
@reggaemuffin ·
You can always try it :) Or read the solutions others submit and see how they did it
properties (22)
authorreggaemuffin
permlinkre-bankholiday-re-reggaemuffin-introducing-the-coding-challenge-20170817t150113596z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 15:01:15
last_update2017-08-17 15:01:15
depth2
children0
last_payout2017-08-24 15:01:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length84
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,092,749
net_rshares0
@benniebanana · (edited)
$0.57
I'm from a Java background but here is my amateur Python submission. Started learning Python recently and fell in love with it so I thought I'd give this a try. 

````
def fizzbuzz(n):

    string = ""

    try:
        if n%3 == 0:
            string += "Fizz"
        if n%5 == 0:
            string += "Buzz"
        else:
            string = n

        return string

    except TypeError:
        return "Error: Not a Number!"

def main():
    for n in range(101):
        print(fizzbuzz(n))

if __name__ == '__main__':
    main()
````

**Explanation:** The modulo operator(%) returns the remainder of a division. For example 8%5 will give us 3. When a number is fully dividable by another number it will return 0 thus checking if the remainder of a division is 0 we know that the number is fully dividable by the other which makes it a multiple of that number.

**EDIT** After posting my solution which is pretty much my level of Python I decided to do some research to see how the solution could be optimized and this is when I came across this gloriously ugly  Python one-liner <a href="http://michaeljgilliland.blogspot.co.za/2013/01/one-line-fizz-buzz-test-in-python.html">here</a> that does exactly the same thing as my script of 23 lines so I thought I'd share it:  

````
print('\n'.join("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i) for i in range(0,101)))
````

This made me a little depressed.
👍  , , , , , , ,
properties (23)
authorbenniebanana
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t151818433z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1","links":["http://michaeljgilliland.blogspot.co.za/2013/01/one-line-fizz-buzz-test-in-python.html"]}
created2017-08-17 15:18:18
last_update2017-08-17 16:57:42
depth1
children5
last_payout2017-08-24 15:18:18
cashout_time1969-12-31 23:59:59
total_payout_value0.436 HBD
curator_payout_value0.137 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,406
author_reputation875,530,017,816
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,094,236
net_rshares164,600,576,083
author_curate_reward""
vote details (8)
@reggaemuffin ·
$0.02
One suggestion I would have is keep the return type of fizzbuzz consistent. So I would probably do a `string = str(n)` to ensure it is always a string.

I also think you have a bug in there, as the else only counts for the second if, not the first one, so for n=3 is will most likely print `3` and not `Fizz` ;)

On coding style: I would rename the `string` variable to something that conveys meaning and not type, maybe `return_text`

The one-liner is pretty ugly in my opinion, your version is way more maintainable.
👍  
properties (23)
authorreggaemuffin
permlinkre-benniebanana-re-reggaemuffin-introducing-the-coding-challenge-20170817t172427039z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:24:30
last_update2017-08-17 17:24:30
depth2
children4
last_payout2017-08-24 17:24:30
cashout_time1969-12-31 23:59:59
total_payout_value0.023 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length518
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,104,149
net_rshares6,931,827,479
author_curate_reward""
vote details (1)
@benniebanana · (edited)
$0.37
Ah man I didn't even pick up on that. Thanks for the feedback though, appreciated. As for the str(n) I actually had that in there and decided to take it out haha, don't know why though. Will keep my original answer as is so other people might learn from my mistakes :) . Here's an updated one after following your advice, not sure if it's very efficient but it doesn't have any bugs anymore lol 

```` 
def fizzbuzz(n):

    try:
        if n%3 == 0 and n%5 == 0:
            text = "FizzBuzz"
        elif n%3 == 0:
            text = "Fizz"
        elif n%5 == 0:
            text = "Buzz"
        else:
            text = str(n)

        return text

    except TypeError:
        return "Error: Not a Number!"

def main():
    for n in range(101):
        print(fizzbuzz(n))

if __name__ == '__main__':
    main()
````
👍  
properties (23)
authorbenniebanana
permlinkre-reggaemuffin-re-benniebanana-re-reggaemuffin-introducing-the-coding-challenge-20170817t173128127z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:31:27
last_update2017-08-17 17:44:48
depth3
children3
last_payout2017-08-24 17:31:27
cashout_time1969-12-31 23:59:59
total_payout_value0.303 HBD
curator_payout_value0.063 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length822
author_reputation875,530,017,816
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,104,637
net_rshares105,617,815,737
author_curate_reward""
vote details (1)
@carlosd15 ·
I wish I could understand those lines >.>
properties (22)
authorcarlosd15
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t151033881z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 15:10:33
last_update2017-08-17 15:10:33
depth1
children0
last_payout2017-08-24 15:10:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length41
author_reputation43,966,086,012,501
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,093,571
net_rshares0
@codetechninja ·
i like this. this i something i would do. not right now but soon. coding is fun and this would help me get better at it
👍  
properties (23)
authorcodetechninja
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t170328715z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:03:33
last_update2017-08-17 17:03:33
depth1
children0
last_payout2017-08-24 17:03:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length119
author_reputation1,893,030,609
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,102,583
net_rshares563,763,200
author_curate_reward""
vote details (1)
@cristiungureanu ·
$0.03
I've contemplating to make a career change and start coding, as my brother does ruby on rails and he could accelerate my progress.

Anyone has done this? Are you happy with your shift?
👍  ,
properties (23)
authorcristiungureanu
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t150427587z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 15:05:42
last_update2017-08-17 15:05:42
depth1
children3
last_payout2017-08-24 15:05:42
cashout_time1969-12-31 23:59:59
total_payout_value0.020 HBD
curator_payout_value0.005 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length184
author_reputation17,242,438,134
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,093,157
net_rshares7,332,395,096
author_curate_reward""
vote details (2)
@joeyarnoldvn ·
Great
properties (22)
authorjoeyarnoldvn
permlinkre-cristiungureanu-re-reggaemuffin-introducing-the-coding-challenge-20170817t155414363z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 15:54:15
last_update2017-08-17 15:54:15
depth2
children0
last_payout2017-08-24 15:54:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5
author_reputation51,475,568,620,387
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,097,164
net_rshares0
@reggaemuffin ·
Coding is awesome, try it :)
properties (22)
authorreggaemuffin
permlinkre-cristiungureanu-re-reggaemuffin-introducing-the-coding-challenge-20170817t150641407z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 15:06:45
last_update2017-08-17 15:06:45
depth2
children0
last_payout2017-08-24 15:06:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length28
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,093,239
net_rshares0
@tfury ·
Nice
properties (22)
authortfury
permlinkre-cristiungureanu-re-reggaemuffin-introducing-the-coding-challenge-20170817t173417574z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:34:18
last_update2017-08-17 17:34:18
depth2
children0
last_payout2017-08-24 17:34:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4
author_reputation3,206,548,905,049
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,104,882
net_rshares0
@datageek ·
$0.37
Wow, Really wish I could code lol, I have tried a couple of times to learn but just not making considerable progress. I have found a niche in data analysis I am so passionate about though , I need some coding ability to succeed in this area like R,Python and SQL. Perhaps this would pave a way for me into "core coding" :). Would closely follow this and see what I can learn. Great initiative
👍  ,
properties (23)
authordatageek
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t145856810z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 14:59:00
last_update2017-08-17 14:59:00
depth1
children4
last_payout2017-08-24 14:59:00
cashout_time1969-12-31 23:59:59
total_payout_value0.366 HBD
curator_payout_value0.003 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length392
author_reputation4,485,172,800,090
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,092,530
net_rshares106,228,042,937
author_curate_reward""
vote details (2)
@cryptomaker · (edited)
I resteem your post.I am new on steemit.this is my first post.
https://steemit.com/introduceyourself/@cryptomaker/first-introduceyourself-on-steemit
Please go and upvote my first post.
👍  
👎  
properties (23)
authorcryptomaker
permlinkre-datageek-re-reggaemuffin-introducing-the-coding-challenge-20170817t151748361z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"links":["https://steemit.com/introduceyourself/@cryptomaker/first-introduceyourself-on-steemit"],"app":"steemit/0.1"}
created2017-08-17 15:18:00
last_update2017-08-17 15:19:33
depth2
children1
last_payout2017-08-24 15:18:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length184
author_reputation17,042,683,569,275
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,094,195
net_rshares-104,526,817,535
author_curate_reward""
vote details (2)
@reggaemuffin ·
I suggest you don't hijack other posts and ask for upvotes.
properties (22)
authorreggaemuffin
permlinkre-cryptomaker-re-datageek-re-reggaemuffin-introducing-the-coding-challenge-20170817t171044162z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:10:45
last_update2017-08-17 17:10:45
depth3
children0
last_payout2017-08-24 17:10:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length59
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,103,095
net_rshares0
@reggaemuffin ·
I suggest you check out the solutions then and learn from it :) That is what this challenge is about, you can see how it can be done and learn to think that way, till you can do it yourself
👍  
properties (23)
authorreggaemuffin
permlinkre-datageek-re-reggaemuffin-introducing-the-coding-challenge-20170817t150026130z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 15:00:30
last_update2017-08-17 15:00:30
depth2
children1
last_payout2017-08-24 15:00:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length189
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,092,676
net_rshares597,836,800
author_curate_reward""
vote details (1)
@datageek ·
Yeah I got my pen and notebook ready. Would try to understand the thought process of each solution.
properties (22)
authordatageek
permlinkre-reggaemuffin-re-datageek-re-reggaemuffin-introducing-the-coding-challenge-20170817t175739381z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:57:48
last_update2017-08-17 17:57:48
depth3
children0
last_payout2017-08-24 17:57:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length99
author_reputation4,485,172,800,090
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,106,787
net_rshares0
@eastmael ·
$0.37
My solution for python:

```
def fizzbuzz(n):
  multipleOf3 = n % 3
  multipleOf5 = n % 5
  
  if (multipleOf3 == 0 and multipleOf5 == 0):
    return "FizzBuzz"
  elif (multipleOf3 == 0):
    return "Fizz"
  elif (multipleOf5 == 0):
    return "Buzz"
  else:
    return n

for n in range(101):
  print(fizzbuzz(n))
```
👍  
properties (23)
authoreastmael
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t163546110z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 16:35:21
last_update2017-08-17 16:35:21
depth1
children3
last_payout2017-08-24 16:35:21
cashout_time1969-12-31 23:59:59
total_payout_value0.275 HBD
curator_payout_value0.091 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length318
author_reputation78,967,407,130,763
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,100,357
net_rshares105,617,815,737
author_curate_reward""
vote details (1)
@reggaemuffin · (edited)
One suggestion I would have is keep the return type of fizzbuzz consistent. So I would probably do a `return str(n)` to ensure it is always a string. And in python I would follow snake_case with my variables so `multiple_of_3` would be the preferred format.

Your solution looks good and I think it it correct, well done :)
properties (22)
authorreggaemuffin
permlinkre-eastmael-re-reggaemuffin-introducing-the-coding-challenge-20170817t173004188z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:30:06
last_update2017-08-17 17:53:09
depth2
children2
last_payout2017-08-24 17:30:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length323
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,104,541
net_rshares0
@eastmael ·
Thank you for the feedback. I'm come from Java. Automatically coded in it's coding style. lols
properties (22)
authoreastmael
permlinkre-reggaemuffin-re-eastmael-re-reggaemuffin-introducing-the-coding-challenge-20170818t170513133z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 17:04:45
last_update2017-08-18 17:04:45
depth3
children0
last_payout2017-08-25 17:04:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length94
author_reputation78,967,407,130,763
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,191,805
net_rshares0
@philosophist ·
lol, snake case for python. I get it! =D
I kinda wonder about these traditions of code styles and methods.  It would be cool to tell a story about the history of traditions like "hello world" and such.
properties (22)
authorphilosophist
permlinkre-reggaemuffin-re-eastmael-re-reggaemuffin-introducing-the-coding-challenge-20170818t061116915z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 06:11:15
last_update2017-08-18 06:11:15
depth3
children0
last_payout2017-08-25 06:11:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length201
author_reputation1,642,759,591,030
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,149,363
net_rshares0
@fauzi86 ·
Nice post
👍  
properties (23)
authorfauzi86
permlinkre-reggaemuffin-2017817t213551520z
categorycoding-challenge
json_metadata{"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"}
created2017-08-17 14:35:54
last_update2017-08-17 14:35:54
depth1
children0
last_payout2017-08-24 14:35:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9
author_reputation2,932,445,711,161
root_title"Introducing the Coding Challenge"
beneficiaries
0.
accountesteemapp
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,090,493
net_rshares4,134,400,858
author_curate_reward""
vote details (1)
@gokulnk ·
$0.37
```php
<?php
function fizzbuzz ($n) {
    $message = "";
    if ($n%3 == 0 || $n%5 == 0) {
        if ($n%3 == 0) {
            $message .= "Fizz";
        }
        if ($n%5 == 0) {
            $message .= "Buzz";
        }
    }
    else {
        $message .= (string)($n);
    }
    echo $message;
}
function test() {
    for ($i=-10; $i<11 ; $i++) {
        echo $i .  ") ";
        echo fizzbuzz($i);
        echo  "\n";
    }
}
test();
?>
```

Using bracket condition for divisibility for 3 & 5. Starting with 3 as more numbers will be divisible by 3. 

Output

```
-10) Buzz
-9) Fizz
-8) -8
-7) -7
-6) Fizz
-5) Buzz
-4) -4
-3) Fizz
-2) -2
-1) -1
0) FizzBuzz
1) 1
2) 2
3) Fizz
4) 4
5) Buzz
6) Fizz
7) 7
8) 8
9) Fizz
10) Buzz
```

<br/>
Do checkout my [programming challenge](https://steemit.com/steemgig/@gokulnk/programming-challenge-1-break-it-down-further) as well.
👍  
properties (23)
authorgokulnk
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t183339395z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"links":["https://steemit.com/steemgig/@gokulnk/programming-challenge-1-break-it-down-further"],"app":"steemit/0.1"}
created2017-08-17 18:33:39
last_update2017-08-17 18:33:39
depth1
children1
last_payout2017-08-24 18:33:39
cashout_time1969-12-31 23:59:59
total_payout_value0.274 HBD
curator_payout_value0.091 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length874
author_reputation17,871,219,215,380
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,109,684
net_rshares105,637,451,265
author_curate_reward""
vote details (1)
@reggaemuffin ·
I submitted an entry for your challenge, pretty cool :)
properties (22)
authorreggaemuffin
permlinkre-gokulnk-re-reggaemuffin-introducing-the-coding-challenge-20170817t192928190z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 19:29:30
last_update2017-08-17 19:29:30
depth2
children0
last_payout2017-08-24 19:29:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length55
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,113,631
net_rshares0
@jhoshua1144 ·
Great post and very interesting
properties (22)
authorjhoshua1144
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t151355728z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 14:51:00
last_update2017-08-17 14:51:00
depth1
children0
last_payout2017-08-24 14:51:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length31
author_reputation67,841,557,506
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,091,831
net_rshares0
@kingsteem ·
Thanks for the information .. i am happy to see this news .. help devoted me
properties (22)
authorkingsteem
permlinkre-reggaemuffin-2017817t22129922z
categorycoding-challenge
json_metadata{"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"}
created2017-08-17 15:12:15
last_update2017-08-17 15:12:15
depth1
children0
last_payout2017-08-24 15:12:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length76
author_reputation12,311,247,330
root_title"Introducing the Coding Challenge"
beneficiaries
0.
accountesteemapp
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,093,703
net_rshares0
@kumar.malhotra ·
Next post Please. My mind is moving. 


https://media.giphy.com/media/nZ9TjTs1lfTwI/giphy.gif
properties (22)
authorkumar.malhotra
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t174707850z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"image":["https://media.giphy.com/media/nZ9TjTs1lfTwI/giphy.gif"],"app":"steemit/0.1"}
created2017-08-17 17:47:12
last_update2017-08-17 17:47:12
depth1
children1
last_payout2017-08-24 17:47:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length93
author_reputation159,754,286,047
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,105,913
net_rshares0
@reggaemuffin ·
Can you give me feedback? Was it too hard or too easy? What would you like to see next?
properties (22)
authorreggaemuffin
permlinkre-kumarmalhotra-re-reggaemuffin-introducing-the-coding-challenge-20170817t174755509z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:47:57
last_update2017-08-17 17:47:57
depth2
children0
last_payout2017-08-24 17:47:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length87
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,105,974
net_rshares0
@lavokad ·
Hi, a quick example in clojure
```
(map #(cond
        (zero? (rem % 15)) "FizzBuzz"
        (zero? (rem % 3)) "Fizz"
        (zero? (rem % 5)) "Buzz"
        :else %)
     (range 0 101))

```

Output:
```
("FizzBuzz" 1 2 "Fizz" 4 "Buzz" "Fizz" 7 8 "Fizz" "Buzz" 11 "Fizz" 13 14 "FizzBuzz" 16 17 "Fizz" 19 "Buzz" "Fizz" 22 23 "Fizz" "Buzz" 26 "Fizz" 28 29 "FizzBuzz" 31 32 "Fizz" 34 "Buzz" "Fizz" 37 38 "Fizz" "Buzz" 41 "Fizz" 43 44 "FizzBuzz" 46 47 "Fizz" 49 "Buzz" "Fizz" 52 53 "Fizz" "Buzz" 56 "Fizz" 58 59 "FizzBuzz" 61 62 "Fizz" 64 "Buzz" "Fizz" 67 68 "Fizz" "Buzz" 71 "Fizz" 73 74 "FizzBuzz" 76 77 "Fizz" 79 "Buzz" "Fizz" 82 83 "Fizz" "Buzz" 86 "Fizz" 88 89 "FizzBuzz" 91 92 "Fizz" 94 "Buzz" "Fizz" 97 98 "Fizz" "Buzz")
```
👍  ,
properties (23)
authorlavokad
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170818t165825769z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 16:58:27
last_update2017-08-18 16:58:27
depth1
children2
last_payout2017-08-25 16:58:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length729
author_reputation3,393,470,987
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,191,308
net_rshares1,160,635,170
author_curate_reward""
vote details (2)
@maramed ·
lisp! What a brilliant, old and unique language :) Hope to find free time and learn it well one day :P
👍  
properties (23)
authormaramed
permlinkre-lavokad-re-reggaemuffin-introducing-the-coding-challenge-20170818t195227804z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 19:52:33
last_update2017-08-18 19:52:33
depth2
children1
last_payout2017-08-25 19:52:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length102
author_reputation29,004,247,491
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,204,384
net_rshares1,149,028,729
author_curate_reward""
vote details (1)
@lavokad ·
:P true. You will, i'm sure about that
properties (22)
authorlavokad
permlinkre-maramed-re-lavokad-re-reggaemuffin-introducing-the-coding-challenge-20170818t195438009z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 19:54:39
last_update2017-08-18 19:54:39
depth3
children0
last_payout2017-08-25 19:54:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length38
author_reputation3,393,470,987
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,204,537
net_rshares0
@melek ·
$0.06
I'm gone do it.
👍  
properties (23)
authormelek
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t144328205z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 14:43:27
last_update2017-08-17 14:43:27
depth1
children1
last_payout2017-08-24 14:43:27
cashout_time1969-12-31 23:59:59
total_payout_value0.064 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length15
author_reputation3,825,345,106,211
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,091,205
net_rshares18,778,001,291
author_curate_reward""
vote details (1)
@reggaemuffin ·
Nice! Post your solution here when you got it. https://repl.it is really good for sharing code.
properties (22)
authorreggaemuffin
permlinkre-melek-re-reggaemuffin-introducing-the-coding-challenge-20170817t145201173z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"links":["https://repl.it"],"app":"steemit/0.1"}
created2017-08-17 14:52:03
last_update2017-08-17 14:52:03
depth2
children0
last_payout2017-08-24 14:52:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length95
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,091,922
net_rshares0
@mkt · (edited)
$0.47
PHP Version:
(lazy and dirty)

https://pastebin.com/q0GqCaG2

```
<?php

function fizzbuzz($n) {
  if (!($n % 3)) {
    $fizzbuzz .= 'Fizz';
  }
  if (!($n % 5)) {
    $fizzbuzz .= 'Buzz';
  }
  return $fizzbuzz;
}

for ($n = 0; $n <= 100; $n++) {
  echo $n . ': ';
  echo fizzbuzz($n);
  echo "\n";
}

function fizzbuzzTest() {
  echo (fizzbuzz(0) == 'FizzBuzz' ? 'passed' : 'failed') . "\n";
  echo (fizzbuzz(3) == 'Fizz' ? 'passed' : 'failed') . "\n";
  echo (fizzbuzz(6) == 'Fizz' ? 'passed' : 'failed') . "\n";
  echo (fizzbuzz(5) == 'Buzz' ? 'passed' : 'failed') . "\n";
  echo (fizzbuzz(10) == 'Buzz' ? 'passed' : 'failed') . "\n";
  echo (fizzbuzz(15) == 'FizzBuzz' ? 'passed' : 'failed') . "\n";
  echo (fizzbuzz(30) == 'FizzBuzz' ? 'passed' : 'failed') . "\n";
  echo (fizzbuzz(31) == '' ? 'passed' : 'failed') . "\n";
}

fizzbuzzTest();
```
#

I think most people will do 3 checks:

```
if %3 AND %5 ...
else if %3 ...
else if %5 ...
```

But

```
if %3 ...
if %5 ...
```

will have the same result when concatenating the strings.

You don't even have to handle n = 0 as a special case because strictly speaking 0 is a multiple of 3 and 5 because 3 * 0 is 0 and 5 * 0 is 0. Otherwise there's just another `if ($n)` missing.
👍  , ,
properties (23)
authormkt
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t154821852z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"links":["https://pastebin.com/q0GqCaG2"],"app":"steemit/0.1"}
created2017-08-17 15:48:09
last_update2017-08-17 15:53:57
depth1
children3
last_payout2017-08-24 15:48:09
cashout_time1969-12-31 23:59:59
total_payout_value0.353 HBD
curator_payout_value0.113 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,234
author_reputation45,513,283,519,678
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,096,667
net_rshares134,106,493,332
author_curate_reward""
vote details (3)
@reggaemuffin ·
I think you made a few errors in it ;) You only print the number if it is no fizz and no buzz :)

the implicit integer to bool conversion is scary `!($n % 5)` I probably would ask you to switch it if it is code i have to maintain, `($n % 5 === 0)` is a bit more readable in my opinion. But you said it was quick and dirty so I won't complain :)

For your tests I would suggest you throw an exception if they fail, as no one will read test logs :)
properties (22)
authorreggaemuffin
permlinkre-mkt-re-reggaemuffin-introducing-the-coding-challenge-20170817t171542809z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:15:45
last_update2017-08-17 17:15:45
depth2
children2
last_payout2017-08-24 17:15:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length446
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,103,479
net_rshares0
@mkt · (edited)
Oh I really just forgot the "in all other cases" part... :D Actually I never print the number, only in the loop but that was just to check the result.
But I have to say that it is hard to write "good" code without a real use case. In my opinion a one-liner (like @benniebanana suggested) is often a perfect copy/paste solution for simple and unshakable logic. I like code that is confident enough to say "Don't f***ing touch me. I just work! Please do the same!"
Concerning the if-statements I find my version more readable but that's maybe only because I am so used to do it that way. But I don't see any problems with that anyway. Also the function could return null.... maybe that's an issue. But we're in the PHP world here... :P It's like asking your 8 yo child to look after your 4 yo one while you're at work. You get prettily painted walls but the cake doesn't taste that well. :D
Anyway... your competition could become very funny and educational. Keep it on!
properties (22)
authormkt
permlinkre-reggaemuffin-re-mkt-re-reggaemuffin-introducing-the-coding-challenge-20170817t203611617z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"users":["benniebanana"],"app":"steemit/0.1"}
created2017-08-17 20:36:00
last_update2017-08-17 20:40:42
depth3
children1
last_payout2017-08-24 20:36:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length968
author_reputation45,513,283,519,678
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,118,156
net_rshares0
@monkonacid ·
Probably the shortest FizzBuzz code 

    for(i=0;i<1e2;)
    console.log((++i%3?"":"Fizz")+(i%5?"":"Buzz")||i)
properties (22)
authormonkonacid
permlinkre-reggaemuffin-introducing-the-coding-challenge-20180618t132550644z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2018-06-18 13:24:27
last_update2018-06-18 13:24:27
depth1
children2
last_payout2018-06-25 13:24:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length111
author_reputation436,763,812
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,225,466
net_rshares0
@reggaemuffin ·
$0.04
You can go even shorter ;) But I mean the idea is to have it nice and readable and thought through :P
👍  , ,
properties (23)
authorreggaemuffin
permlinkre-monkonacid-re-reggaemuffin-introducing-the-coding-challenge-20180619t103438706z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2018-06-19 10:34:36
last_update2018-06-19 10:34:36
depth2
children1
last_payout2018-06-26 10:34:36
cashout_time1969-12-31 23:59:59
total_payout_value0.035 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length101
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,342,657
net_rshares17,563,191,347
author_curate_reward""
vote details (3)
@monkonacid ·
Not the best looking code, however you could add some comments...  :D
properties (22)
authormonkonacid
permlinkre-reggaemuffin-re-monkonacid-re-reggaemuffin-introducing-the-coding-challenge-20180619t173207673z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2018-06-19 17:32:09
last_update2018-06-19 17:32:09
depth3
children0
last_payout2018-06-26 17:32:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length69
author_reputation436,763,812
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,387,277
net_rshares0
@mrziaulkamal ·
Hi. I am a volunteer bot for <a href="https://steemit.com/@mrziaulkamal">@SteemitBOT</a> that upvoted you. And this system allways Vote for your Content if you follow this <a href="https://steemit.com/@mrziaulkamal">@SteemitBOT</a>.

Your post was chosen at random, as part of the advertisment campaign for <a href="https://steemit.com/@mrziaulkamal">@SteemitBOT</a>

<a href="https://steemit.com/@mrziaulkamal">@SteemitBOT</a> is meant to help minnows get noticed by re-steeming their posts and upvote To use the bot, one must follow it for at least 3 hours, and then make a transaction where the memo is the url of the post.

<b><a href="https://steemit.com/@mrziaulkamal">Please Follow and UPVOTE</a></b>

<center>![steemit Upvote](https://steemit.com/images/steemit-share.png)
👎  
properties (23)
authormrziaulkamal
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t150125368z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"image":["https://steemit.com/images/steemit-share.png"],"links":["https://steemit.com/@mrziaulkamal"],"app":"steemit/0.1"}
created2017-08-17 15:01:24
last_update2017-08-17 15:01:24
depth1
children1
last_payout2017-08-24 15:01:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length780
author_reputation-952,072,864
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,092,757
net_rshares-105,617,815,737
author_curate_reward""
vote details (1)
@reggaemuffin ·
You did not upvote me, please don't spam :)
properties (22)
authorreggaemuffin
permlinkre-mrziaulkamal-re-reggaemuffin-introducing-the-coding-challenge-20170817t150357691z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 15:04:00
last_update2017-08-17 15:04:00
depth2
children0
last_payout2017-08-24 15:04:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length43
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,093,010
net_rshares0
@n4t3w ·
Here is my Python submission. Not the prettiest, but it works.

def FizzBuzz(n):
	fizz = False
	buzz = False
	r = 0
	if type(n) != int:
		r = type(n)
	elif n==0:
		r=0
	else:
		if n%3== 0:
			fizz = True	
		if n%5 ==0:
			buzz = True

			
	if fizz & buzz:
		r = 'FizzBuzz'
	elif fizz:
		r = 'Fizz'
	elif buzz:
		r = 'Buzz'
	else:
		r = n			
	print(r)
	return r
		

for i in range(0,101):
	FizzBuzz(i)

The spacing got messed up. So to run it, it will need some fixing.
properties (22)
authorn4t3w
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170820t162023033z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-20 16:20:30
last_update2017-08-20 16:20:30
depth1
children0
last_payout2017-08-27 16:20:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length468
author_reputation49,667,465,108
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,359,988
net_rshares0
@philosophist ·
$0.37
Here is function written in Matlab:
### Test Script:
``` 
for x = 1:100
    disp(fizzbuzz(x));
end
```

### Function:
```
function output = fizzbuzz(n)
% fizzbuzz(n) returns 'Fizz' if n is a multiple of 3, 
% 'Buzz' if n is a multiple of 5, 'FizzBuzz' if n is a 
% multiple of 5 and 3, and returns n if it is neither a 
% multiple of 3 or 5.
% Format of Call: fizzbuzz(n);
% Returns: output = 'Fizz', 'Buzz', 'FizzBuzz', or n 
% based on if n is a multiple of 3 or 5
    
    if ~isnumeric(n)
        error('Error: Input must be a number, not a %s.',class(n));
    else
        output = '';
        if rem(n,3) == 0
            output = 'Fizz';
        end
        if rem(n,5) == 0
            output = strcat(output,'Buzz');
        end
        if strcmp(output,'')
            output = num2str(n);
        end
    end
```
### Console Output
```
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz
```

The general design is to take the input value, check to be sure it's a number, then proceed to construct the output. Since 'FizzBuzz' is the combination of 'Fizz' and 'Buzz' it made sense to me to build the output string starting with an empty string and adding 'Fizz' if n is divisible by 3 followed by 'Buzz' if n is divisible by 5. Since they are concatinated into the empty string, 'FizzBuzz' logically follows if n is divisible by 3 and 5. Finally, if nothing was added to the output string then it must not have been divisible by either, so I assign a string form of n to the output.

I'm curious to see how far off I am from best practices for this challenge.
👍  ,
properties (23)
authorphilosophist
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t191654393z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 19:16:54
last_update2017-08-17 19:16:54
depth1
children5
last_payout2017-08-24 19:16:54
cashout_time1969-12-31 23:59:59
total_payout_value0.313 HBD
curator_payout_value0.055 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,931
author_reputation1,642,759,591,030
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,112,691
net_rshares106,693,625,857
author_curate_reward""
vote details (2)
@reggaemuffin ·
Interesting choice :) I like your solution.

String compare will probably be a lot slower than doing the reminder again, but if it is an optimized strcmp it will still be pretty fast. 

Be sure to check a few other solutions and give feedback :)
properties (22)
authorreggaemuffin
permlinkre-philosophist-re-reggaemuffin-introducing-the-coding-challenge-20170817t193456828z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 19:35:00
last_update2017-08-17 19:35:00
depth2
children4
last_payout2017-08-24 19:35:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length245
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,114,069
net_rshares0
@philosophist · (edited)
Good point. This should be more optimized. New variable 'neither' is a boolean set to true initially and set to false if n is either divisible by 3, 5, or both. Then that becomes the check for if neither is the case.
```
function output = fizzbuzz(n)
% fizzbuzz(n) returns 'Fizz' if n is a multiple of 3, 
% 'Buzz' if n is a multiple of 5, 'FizzBuzz' if n is a 
% multiple of 5 and 3, and returns n if it is neither a 
% multiple of 3 or 5.
% Format of Call: fizzbuzz(n);
% Returns: output = 'Fizz', 'Buzz', 'FizzBuzz', or n 
% based on if n is a multiple of 3 or 5
    
    if ~isnumeric(n)
        error('Error: Input must be a number, not a %s.',class(n));
    else
        neither = true;
        output = '';
        if rem(n,3) == 0
            output = 'Fizz';
            neither = false;
        end
        if rem(n,5) == 0
            output = strcat(output,'Buzz');
            neither = false;
        end
        if neither
            output = num2str(n);
        end
    end
```
properties (22)
authorphilosophist
permlinkre-reggaemuffin-re-philosophist-re-reggaemuffin-introducing-the-coding-challenge-20170818t013330149z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 01:33:30
last_update2017-08-18 01:36:27
depth3
children3
last_payout2017-08-25 01:33:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length994
author_reputation1,642,759,591,030
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,134,774
net_rshares0
@pilcrow ·
$0.37
Ooh, this is right up my alley! I'll start out with JavaScript (because I already know it) but I might switch to different languages for future challenges just for the fun of it. I'll be looking forward to these!
👍  , , , , , , , , , , ,
properties (23)
authorpilcrow
permlinkre-reggaemuffin-2017817t184832996z
categorycoding-challenge
json_metadata{"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"}
created2017-08-17 16:48:33
last_update2017-08-17 16:48:33
depth1
children1
last_payout2017-08-24 16:48:33
cashout_time1969-12-31 23:59:59
total_payout_value0.366 HBD
curator_payout_value0.007 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length212
author_reputation2,531,070,549,481
root_title"Introducing the Coding Challenge"
beneficiaries
0.
accountesteemapp
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,101,453
net_rshares113,205,958,237
author_curate_reward""
vote details (12)
@reggaemuffin ·
Looking forward to your solution :)
properties (22)
authorreggaemuffin
permlinkre-pilcrow-re-reggaemuffin-2017817t184832996z-20170817t180235271z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 18:02:36
last_update2017-08-17 18:02:36
depth2
children0
last_payout2017-08-24 18:02:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length35
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,107,227
net_rshares0
@pilcrow · (edited)
$1.32
Alright, here's my solution: https://jsfiddle.net/jf68mfj1/2/

I went for some solutions that may not be "good coding practices" depending on who you ask, because I wanted to explore JavaScript a bit further than a basic for-loop and if-statement.

Here's the main fizzBuzz function: 

```
function fizzBuzz(num) {
    let returnValue = '';
    if (num % 3 === 0) returnValue += 'Fizz';
    if (num % 5 === 0) returnValue += 'Buzz';
    return returnValue || String(num);
}
```

Like others I concatenate `Fizz` and `Buzz` so I don't need a third if-statement. As a bonus I use JavaScript's type coercion to check if returnValue is truthy, and if it's not (an empty string `''` is falsy) I return the original number. Initially I returned it as an integer too, but returning mixed types is bad practice and in fact actually broke my tests, so I return it a as string now too.

Fizzing from 0 to 100 I do with this method:
```
function fizzTo100() {
    const allFizzBuzzes = [...Array(100).keys()].map(fizzBuzz);
    output(allFizzBuzzes.join('\n'));
}
```

The first line looks a bit like a hack. What I do is create an array of 100 length and then take the keys from that array. All the values are still undefined, but the keys are 0-100. The result of `keys()` is an iterable though, so I turn it back into an array using the spread operator in a new array `[...x]`.
Now I have an array of 1-100 that I can map to fizzBuzz. 

See and test my code here: https://jsfiddle.net/jf68mfj1/2/

If anyone is interested in more details let me know and I'll write a blog post about it. Not going throught that effort if nobody cares though ;)
👍  , , ,
properties (23)
authorpilcrow
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170818t085726321z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"links":["https://jsfiddle.net/jf68mfj1/2/"],"app":"steemit/0.1"}
created2017-08-18 08:57:27
last_update2017-08-18 08:58:15
depth1
children5
last_payout2017-08-25 08:57:27
cashout_time1969-12-31 23:59:59
total_payout_value0.991 HBD
curator_payout_value0.326 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,635
author_reputation2,531,070,549,481
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,157,695
net_rshares377,412,334,263
author_curate_reward""
vote details (4)
@benniebanana ·
$0.10
This is really neat. Well done
👍  
properties (23)
authorbenniebanana
permlinkre-pilcrow-re-reggaemuffin-introducing-the-coding-challenge-20170819t122006588z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-19 12:20:06
last_update2017-08-19 12:20:06
depth2
children0
last_payout2017-08-26 12:20:06
cashout_time1969-12-31 23:59:59
total_payout_value0.074 HBD
curator_payout_value0.024 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length30
author_reputation875,530,017,816
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,258,140
net_rshares27,329,218,811
author_curate_reward""
vote details (1)
@reggaemuffin ·
+1 for 
> Initially I returned it as an integer too, but returning mixed types is bad practice and in fact **actually broke my tests**, so I return it a as string now too.

and for having a test that breaks when this is not the case, tip! worthy :)

The `||` is a pretty clean way, I like that! 

Your explanation on why you used the spread operator is glorious! Thank you for giving insight into why you used that :) 

I would definitely read a blog post about it. But if you want to save your efforts for a harder challenge, a new one will come up pretty soon :)
properties (22)
authorreggaemuffin
permlinkre-pilcrow-re-reggaemuffin-introducing-the-coding-challenge-20170818t102036456z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 10:20:39
last_update2017-08-18 10:20:39
depth2
children2
last_payout2017-08-25 10:20:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length564
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,162,209
net_rshares0
@pilcrow ·
Thanks! In that case I'll wait for the next one. This is fun :)
properties (22)
authorpilcrow
permlinkre-reggaemuffin-2017818t124833597z
categorycoding-challenge
json_metadata{"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"}
created2017-08-18 10:48:36
last_update2017-08-18 10:48:36
depth3
children0
last_payout2017-08-25 10:48:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length63
author_reputation2,531,070,549,481
root_title"Introducing the Coding Challenge"
beneficiaries
0.
accountesteemapp
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,163,717
net_rshares0
@zuricher ·
 
properties (22)
authorzuricher
permlinkre-re-pilcrow-re-reggaemuffin-introducing-the-coding-challenge-20170818t102036456z-20200829t032329z
categorycoding-challenge
json_metadata"{"app": "beem/0.23.9"}"
created2020-08-29 03:23:30
last_update2020-08-29 03:23:30
depth3
children0
last_payout2020-09-05 03:23:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1
author_reputation-39,571,640,904
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,332,904
net_rshares0
@tipu ·
<table><tr><td>http://i.imgur.com/IFF4CSc.jpg</td><td><p><strong>Hi @pilcrow! You have just received a 0.5 SBD tip from @reggaemuffin!</strong></p><hr><p><a href="https://steemit.com/steemit/@tipu/tipu-quick-guide" rel="noopener">@tipU quick guide</a> |  How to check your <a href="https://steemit.com/steemit/@tipu/cool-steem-tools-check-your-pending-payouts-with-charts" rel="noopener">pending payouts.</a></p></td></tr></table>
properties (22)
authortipu
permlinkre-re-reggaemuffin-introducing-the-coding-challenge-20170818t085726321z-20170818t102050
categorycoding-challenge
json_metadata""
created2017-08-18 10:20:51
last_update2017-08-18 10:20:51
depth2
children0
last_payout2017-08-25 10:20:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length430
author_reputation55,912,306,507,814
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,162,224
net_rshares0
@pinaynomad ·
Interesting challenge. All I know is WordPress, but I'm open to studying the morbid stuff that you do here on Steemit like having a bot and stuff. I'm amazed with your skills. :-)
properties (22)
authorpinaynomad
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170818t082603536z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 08:26:03
last_update2017-08-18 08:26:03
depth1
children0
last_payout2017-08-25 08:26:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length179
author_reputation3,805,814,570,723
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,156,011
net_rshares0
@ratticus ·
$0.37
5 minute C/C++ solution. Taking more time I'd look at getting rid of the trailing ',' in the loop through the function calls, and maybe do some error checking regarding sending wrong type to the function, but for now I think this is pretty simple and the comments make it self explanatory. 

Code:
```
#include <stdio.h>
using namespace std;

//function fizzbuzz takes in an integer and prints out the intended output for that integer
void fizzbuzz (int n) {

	//if the number is divisible by 15
	if (n%15 == 0) {
		printf("FizzBuzz, ");
	}
	//if the number is divisible by 5
	else if (n%5 == 0) {
		printf("Buzz, ");
	}
	//if the number is divisible by 3
	else if (n%3 == 0) {
		printf("Fizz, ");
	}
	//if the number is not divisible by 3 or 5 (or 15)
	else {
		printf("%i, ", n);
	}
} //END fizzbuzz

int main (int argc, char* argv[]) {

	//test casses
	printf("Test Cases: ");
	fizzbuzz(0);	//prints "FizzBuzz"
	fizzbuzz(15);	//prints "FizzBuzz"
	fizzbuzz(5);	//prints "Buzz"
	fizzbuzz(3);	//prints "Fizz"
	fizzbuzz(22);	//prints "22"
	fizzbuzz(-5);	//prints "Buzz"
	fizzbuzz(-98);	//prints "-98"
	
	printf("End Test Cases\n\n");
	
	//loop through numbers 0 to 100 and call fizzbuzz on each
	for (int i = 0; i < 101; i++) {
		fizzbuzz(i);
	}

} //END main
```

Console Output
```
Test Cases: FizzBuzz, FizzBuzz, Buzz, Fizz, 22, Buzz, -98, End Test Cases

FizzBuzz, 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, FizzBuzz, 31, 32, Fizz, 34, Buzz, Fizz, 37, 38, Fizz, Buzz, 41, Fizz, 43, 44, FizzBuzz, 46, 47, Fizz, 49, Buzz, Fizz, 52, 53, Fizz, Buzz, 56, Fizz, 58, 59, FizzBuzz, 61, 62, Fizz, 64, Buzz, Fizz, 67, 68, Fizz, Buzz, 71, Fizz, 73, 74, FizzBuzz, 76, 77, Fizz, 79, Buzz, Fizz, 82, 83, Fizz, Buzz, 86, Fizz, 88, 89, FizzBuzz, 91, 92, Fizz, 94, Buzz, Fizz, 97, 98, Fizz, Buzz,
```
👍  
properties (23)
authorratticus
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170818t080136457z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 08:01:36
last_update2017-08-18 08:01:36
depth1
children1
last_payout2017-08-25 08:01:36
cashout_time1969-12-31 23:59:59
total_payout_value0.275 HBD
curator_payout_value0.091 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,884
author_reputation5,793,669,654,286
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,154,812
net_rshares105,640,991,575
author_curate_reward""
vote details (1)
@reggaemuffin ·
Looking good to me :)
properties (22)
authorreggaemuffin
permlinkre-ratticus-re-reggaemuffin-introducing-the-coding-challenge-20170818t102220794z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 10:22:24
last_update2017-08-18 10:22:24
depth2
children0
last_payout2017-08-25 10:22:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length21
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,162,318
net_rshares0
@reggaemuffin · (edited)
$0.04
My ruby solution to FizzBuzz: https://repl.it/KNug/2
![](https://steemitimages.com/DQmPnwXYo6v2UYahrzvbKuKNfYWvTS8D1nimu9XCLXpD3oX/image.png)

I used the range iterator `(0..100).each` because it is really nice to read in my opinion.

Constants are important, but `FIZZBUZZ` depends on `FIZZ` and `BUZZ` so a dynamic constant is best there.

helper functions to test for the various cases  are really helpful for testing at. And the final fizzbuzz function reads like natural language.

The code works for negative values just fine and all functions are pure, so it can be used without printing anything.
👍  , , ,
properties (23)
authorreggaemuffin
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t145007513z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"image":["https://steemitimages.com/DQmPnwXYo6v2UYahrzvbKuKNfYWvTS8D1nimu9XCLXpD3oX/image.png"],"links":["https://repl.it/KNug/2"],"app":"steemit/0.1"}
created2017-08-17 14:50:09
last_update2017-08-17 14:50:36
depth1
children0
last_payout2017-08-24 14:50:09
cashout_time1969-12-31 23:59:59
total_payout_value0.031 HBD
curator_payout_value0.006 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length604
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,091,769
net_rshares10,733,352,661
author_curate_reward""
vote details (4)
@rizasukma ·
Great post and very interesting. Provide a very useful knowledge. Thank you so much for sharing
properties (22)
authorrizasukma
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t143828984z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 14:38:33
last_update2017-08-17 14:38:33
depth1
children0
last_payout2017-08-24 14:38:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length95
author_reputation56,673,466,694,018
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,090,748
net_rshares0
@steemitadventure ·
If I could code I would be all over this :) looks like a cool idea good luck!
properties (22)
authorsteemitadventure
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t164108781z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 16:41:09
last_update2017-08-17 16:41:09
depth1
children0
last_payout2017-08-24 16:41:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length77
author_reputation38,702,956,343,359
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,100,851
net_rshares0
@tantawi ·
@reggaemuffin I want to know how young to learn kede easily, please teach me and please give me easy tips for me to learn it. I am very interested in your current posting of friends.
***
***
saya pingin tau bagaimana cara yang muda untuk mempelajari kede itu dengan mudah, tolong ajarin saya dan tolong beri saya tips yang mudah untuk saya mempelajari nya.saya sangat tertarik dengan postingan anda saat ini teman.
👍  
properties (23)
authortantawi
permlinkre-reggaemuffin-2017817t22164886z
categorycoding-challenge
json_metadata{"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"}
created2017-08-17 15:16:12
last_update2017-08-17 15:16:12
depth1
children0
last_payout2017-08-24 15:16:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length414
author_reputation4,391,501,911,743
root_title"Introducing the Coding Challenge"
beneficiaries
0.
accountesteemapp
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,094,042
net_rshares3,892,422,535
author_curate_reward""
vote details (1)
@tarekadam ·
I like it! I am not good at coding but I love the challenge and one sweet day win one of your challenges :)
properties (22)
authortarekadam
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t171410493z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 17:14:09
last_update2017-08-17 17:14:09
depth1
children0
last_payout2017-08-24 17:14:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length107
author_reputation50,131,776,387,207
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,103,358
net_rshares0
@tarekadam ·
$0.37
My Solution in plain old JS5 :)

```
function fizzbuzz(value) {
    if (value % 5 == 0 && value % 3 == 0) {
        console.log("FizzBuzz")
    } else if (value % 5 == 0) {
        console.log("Buzz")
    } else if (value % 3 == 0) {
        console.log("Fizz")
    } else {
        console.log(value)
    }
};

function TestNumbers() {
for (var i = 0; i < 101; i++) {
    console.log(fizzbuzz(i));
    }
};

TestNumbers();
```
👍  ,
properties (23)
authortarekadam
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t183855297z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 18:38:54
last_update2017-08-17 18:38:54
depth1
children1
last_payout2017-08-24 18:38:54
cashout_time1969-12-31 23:59:59
total_payout_value0.278 HBD
curator_payout_value0.091 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length427
author_reputation50,131,776,387,207
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,110,053
net_rshares106,798,081,292
author_curate_reward""
vote details (2)
@reggaemuffin ·
$0.22
Looks good to me ;)
👍  
properties (23)
authorreggaemuffin
permlinkre-tarekadam-re-reggaemuffin-introducing-the-coding-challenge-20170817t193556268z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 19:35:57
last_update2017-08-17 19:35:57
depth2
children0
last_payout2017-08-24 19:35:57
cashout_time1969-12-31 23:59:59
total_payout_value0.166 HBD
curator_payout_value0.055 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length19
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,114,148
net_rshares64,624,258,529
author_curate_reward""
vote details (1)
@turpsy ·
Reading the comments gave me hope i can restart the basics of computer programming i learnt in undergraduates.  I will follow the solutions and one day soon i will write my code.
properties (22)
authorturpsy
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170817t151225604z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-17 15:12:27
last_update2017-08-17 15:12:27
depth1
children0
last_payout2017-08-24 15:12:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length178
author_reputation22,352,016,062,417
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,093,717
net_rshares0
@tzs ·
$0.78
Two solutions with Haskell: http://codepad.org/tIR16emr

![Screen Shot 2017-08-17 at 9.21.12 PM.png](https://steemitimages.com/DQmed9LTNRtgUqf7jqWYbpWGJUWmUaRt4XXJePTmYzSJ6Zd/Screen%20Shot%202017-08-17%20at%209.21.12%20PM.png)
👍  , ,
properties (23)
authortzs
permlinkre-reggaemuffin-introducing-the-coding-challenge-20170818t022340743z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"image":["https://steemitimages.com/DQmed9LTNRtgUqf7jqWYbpWGJUWmUaRt4XXJePTmYzSJ6Zd/Screen%20Shot%202017-08-17%20at%209.21.12%20PM.png"],"links":["http://codepad.org/tIR16emr"],"app":"steemit/0.1"}
created2017-08-18 02:23:42
last_update2017-08-18 02:23:42
depth1
children6
last_payout2017-08-25 02:23:42
cashout_time1969-12-31 23:59:59
total_payout_value0.585 HBD
curator_payout_value0.193 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length226
author_reputation66,276,041,146
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,137,454
net_rshares226,124,129,786
author_curate_reward""
vote details (3)
@reggaemuffin ·
$0.03
Thank you for your submission! I really hoped that I get a Haskell one 🐑

Your first solution is pretty concise, not much to say there. The second one is really cool! Abstracting it as rules is smart and that filter reduces logic duplication. 

I think you can make this a bit more readable with making rules a constant and extracting the tester in a helper function that has a good name. 

Looking forward to you writing a post on how your process was, implementing the second version of it.
👍  
properties (23)
authorreggaemuffin
permlinkre-tzs-re-reggaemuffin-introducing-the-coding-challenge-20170818t054013756z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 05:40:15
last_update2017-08-18 05:40:15
depth2
children5
last_payout2017-08-25 05:40:15
cashout_time1969-12-31 23:59:59
total_payout_value0.020 HBD
curator_payout_value0.006 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length492
author_reputation37,964,839,695,531
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,147,892
net_rshares7,757,166,712
author_curate_reward""
vote details (1)
@ratticus ·
$0.03
Only comment I have is the question asked for 0 to 100 but the solutions are for 1..100. How does either solution work for 0? Dealing with 0 shouldn't be too difficult, though 0/x is going to be 0 and 0 mod x is also 0. I guess it will/should print FizzBuzz for n=0.
👍  
properties (23)
authorratticus
permlinkre-reggaemuffin-re-tzs-re-reggaemuffin-introducing-the-coding-challenge-20170818t072036776z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 07:20:36
last_update2017-08-18 07:20:36
depth3
children3
last_payout2017-08-25 07:20:36
cashout_time1969-12-31 23:59:59
total_payout_value0.020 HBD
curator_payout_value0.006 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length266
author_reputation5,793,669,654,286
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,152,860
net_rshares7,599,660,789
author_curate_reward""
vote details (1)
@tzs ·
I don't know what you mean by
> making rules a constant

It's already a constant there.

Since the filter phrase used once and it's a short one, I'd argue it's easier to read it this way.

I implemented/borrowed the second one because I wanted to have a generic solution that is easy to expand or change with new `rules`. Now, all you need is to update the `rules` to get a new `FizzBuzz`.
properties (22)
authortzs
permlinkre-reggaemuffin-re-tzs-re-reggaemuffin-introducing-the-coding-challenge-20170818t233545415z
categorycoding-challenge
json_metadata{"tags":["coding-challenge"],"app":"steemit/0.1"}
created2017-08-18 23:35:42
last_update2017-08-18 23:35:42
depth3
children0
last_payout2017-08-25 23:35:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length389
author_reputation66,276,041,146
root_title"Introducing the Coding Challenge"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,217,895
net_rshares0