Welcome to the Coding Challenge.  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.
author | reggaemuffin |
---|---|
permlink | introducing-the-coding-challenge |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge","coding","dev","programming","coding-solution"],"image":["https://steemitimages.com/DQmZKvzF6x23MFsTpWicM6bFYaZ4Gosh9irSM17TdaYtPu6/image.png"],"app":"steemit/0.1","format":"markdown"} |
created | 2017-08-17 14:32:06 |
last_update | 2017-08-17 14:32:06 |
depth | 0 |
children | 86 |
last_payout | 2017-08-24 14:32:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 89.068 HBD |
curator_payout_value | 7.508 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,031 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,090,182 |
net_rshares | 27,588,387,049,778 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
berkah | 0 | 59,132,859,655 | 11% | ||
pnc | 0 | 38,034,693,615 | 11% | ||
teamsteem | 0 | 1,762,258,792,472 | 11% | ||
thecryptodrive | 0 | 168,429,570,097 | 100% | ||
lauralemons | 0 | 3,738,113,246 | 5.5% | ||
sephiroth | 0 | 683,972,459,672 | 100% | ||
artific | 0 | 146,221,909,701 | 100% | ||
badbeth | 0 | 174,103,193 | 100% | ||
melek | 0 | 19,189,198,400 | 100% | ||
lamech-m | 0 | 2,095,404,846 | 11% | ||
awkwardawk | 0 | 2,231,722,550 | 100% | ||
runridefly | 0 | 10,855,746,087 | 2% | ||
barrydutton | 0 | 63,521,809,788 | 10% | ||
swisswatcher | 0 | 12,098,362,700 | 11% | ||
tarekadam | 0 | 858,695,791,483 | 100% | ||
safar01 | 0 | 4,446,189,146 | 100% | ||
thomasp | 0 | 374,466,010 | 100% | ||
steemsports | 0 | 49,757,659,594 | 15% | ||
taynav00 | 0 | 347,126,765 | 53.63% | ||
teodora | 0 | 16,521,295,328 | 100% | ||
bandli | 0 | 2,213,971,631 | 100% | ||
gamevortex | 0 | 51,751,490 | 100% | ||
automaton | 0 | 8,035,113,229 | 100% | ||
ackza | 0 | 4,858,028,694 | 16% | ||
carbunco10 | 0 | 1,157,018,633 | 100% | ||
trafalgar | 0 | 1,898,824,912,080 | 9% | ||
aomura | 0 | 209,777,506,546 | 100% | ||
oendertuerk | 0 | 6,267,556,816 | 10% | ||
velimir | 0 | 24,809,839,906 | 100% | ||
greenstar | 0 | 8,203,947,277 | 11% | ||
aarkay | 0 | 161,885,958 | 100% | ||
stargarden | 0 | 34,689,004,833 | 100% | ||
merchdesigner | 0 | 2,652,439,610 | 100% | ||
etcbits | 0 | 2,539,115,081 | 100% | ||
jraysteem | 0 | 1,280,236,359 | 100% | ||
rizasukma | 0 | 2,914,440,804 | 100% | ||
reggaemuffin | 0 | 9,135,941,061,329 | 100% | ||
fredrikaa | 0 | 30,254,499,256 | 50% | ||
ecoinstant | 0 | 10,108,765,761 | 100% | ||
xenitron | 0 | 42,392,756,773 | 100% | ||
malicered | 0 | 107,876,451,951 | 100% | ||
scooter77 | 0 | 13,550,469,717 | 51% | ||
tantawi | 0 | 3,986,215,849 | 100% | ||
adnanrahic | 0 | 8,863,600,578 | 100% | ||
etnique | 0 | 8,766,508,483 | 100% | ||
benniebanana | 0 | 7,217,255,670 | 100% | ||
bania | 0 | 5,107,534,002 | 100% | ||
carlosd15 | 0 | 22,803,519,512 | 100% | ||
pennsif | 0 | 5,666,236,761 | 22% | ||
mumofmany | 0 | 6,552,190,044 | 11% | ||
centerlink | 0 | 42,377,885,294 | 11% | ||
sammosk | 0 | 9,340,414,981 | 100% | ||
suesa | 0 | 183,411,250,921 | 100% | ||
ausbitbot | 0 | 3,279,266,133 | 8.8% | ||
steemitadventure | 0 | 55,641,916,612 | 47% | ||
imransoudagar | 0 | 1,847,614,516 | 100% | ||
pilcrow | 0 | 21,352,972,837 | 50% | ||
cristiungureanu | 0 | 567,092,929 | 100% | ||
furious-one | 0 | 9,798,313,151 | 50% | ||
dheerajdj | 0 | 18,529,785,022 | 100% | ||
maretha94 | 0 | 633,171,060 | 100% | ||
steppingout23 | 0 | 24,568,321,043 | 4% | ||
raili | 0 | 739,934,906 | 100% | ||
steemvotes | 0 | 1,050,860,719 | 100% | ||
dino85fr | 0 | 3,575,308,037 | 100% | ||
ikenna | 0 | 1,784,433,479 | 100% | ||
icedrum | 0 | 53,678,992,622 | 100% | ||
minnowbooster | 0 | 11,578,103,031,053 | 100% | ||
wahyu07 | 0 | 2,699,201,006 | 100% | ||
eyegasm | 0 | 1,927,617,285 | 11% | ||
that1consultant | 0 | 532,245,516 | 5.67% | ||
mickyscofield | 0 | 683,273,824 | 100% | ||
camilomango | 0 | 449,152,000 | 100% | ||
celestialme | 0 | 1,493,495,466 | 100% | ||
philosophist | 0 | 5,526,195,090 | 100% | ||
jfuenmayor96 | 0 | 3,370,941,217 | 100% | ||
hery1983 | 0 | 663,467,572 | 100% | ||
ezequieltorres | 0 | 582,873,014 | 100% | ||
kingsteem | 0 | 514,441,570 | 100% | ||
andr1an0 | 0 | 6,136,735,412 | 100% | ||
pinaynomad | 0 | 5,075,788,329 | 100% | ||
arunad | 0 | 341,860,949 | 100% | ||
ramzialhaddadtm | 0 | 630,342,998 | 100% | ||
offgrind | 0 | 446,055,202 | 100% | ||
acehpungo | 0 | 777,692,857 | 100% | ||
rmaxhuni | 0 | 328,143,567 | 100% | ||
hiradate | 0 | 775,312,688 | 100% | ||
ahmedkedd | 0 | 564,364,275 | 100% | ||
a1n21t | 0 | 550,492,831 | 100% | ||
madmaxfury | 0 | 686,281,338 | 100% | ||
hamet123 | 0 | 424,734,190 | 100% | ||
chrisdavidphoto | 0 | 798,008,910 | 1.1% | ||
flaminggoat | 0 | 469,046,988 | 100% | ||
phatez | 0 | 84,621,633 | 100% | ||
mrsquiggle | 0 | 12,361,841,885 | 11% | ||
n4t3w | 0 | 631,655,688 | 100% | ||
shahriar27 | 0 | 77,057,738 | 100% | ||
writer1 | 0 | 99,614,826 | 100% | ||
jnjmarketing | 0 | 1,162,751,614 | 100% | ||
newarguy | 0 | 63,862,800 | 100% | ||
lesley2958 | 0 | 1,120,023,015 | 100% | ||
mikeshuh | 0 | 460,700,161 | 100% | ||
medogamal | 0 | 626,814,874 | 100% | ||
bankholiday | 0 | 203,127,222 | 100% | ||
eastmael | 0 | 1,131,625,591 | 100% | ||
aziz01 | 0 | 150,883,017 | 100% | ||
dongately | 0 | 247,654,978 | 100% | ||
ksvvb | 0 | 214,717,958 | 100% | ||
markcarlo | 0 | 1,137,423,461 | 100% | ||
lavokad | 0 | 1,160,635,079 | 100% | ||
quarterlifehuman | 0 | 1,102,599,848 | 100% | ||
killuminati | 0 | 0 | -100% | ||
adrienlaville | 0 | 0 | 100% |
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
author | ackza |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t233919371z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 23:39:18 |
last_update | 2017-08-17 23:39:18 |
depth | 1 |
children | 1 |
last_payout | 2017-08-24 23:39:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 440 |
author_reputation | 287,776,574,693,472 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,128,656 |
net_rshares | 0 |
Thank you 😊 I'll see about making these challenges steem specific, that could be fun 😊
author | reggaemuffin |
---|---|
permlink | re-ackza-re-reggaemuffin-introducing-the-coding-challenge-20170818t053202394z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 05:32:03 |
last_update | 2017-08-18 05:32:03 |
depth | 2 |
children | 0 |
last_payout | 2017-08-25 05:32:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 87 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,147,505 |
net_rshares | 3,874,119,146 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ackza | 0 | 3,874,119,146 | 12% |
Wonderful post @reggaemuffin
author | andrewramdas |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t143851104z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"users":["reggaemuffin"],"app":"steemit/0.1"} |
created | 2017-08-17 14:37:45 |
last_update | 2017-08-17 14:37:45 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 14:37:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 28 |
author_reputation | 2,441,258,120,617 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,090,679 |
net_rshares | 0 |
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?
author | bandli |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t194047303z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 19:40:45 |
last_update | 2017-08-17 19:40:45 |
depth | 1 |
children | 5 |
last_payout | 2017-08-24 19:40:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.344 HBD |
curator_payout_value | 0.020 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 3,652 |
author_reputation | 1,950,997,435 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,114,504 |
net_rshares | 105,637,451,265 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,637,451,265 | 1% |
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 :)
author | reggaemuffin |
---|---|
permlink | re-bandli-re-reggaemuffin-introducing-the-coding-challenge-20170817t194717153z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 19:47:21 |
last_update | 2017-08-17 19:47:21 |
depth | 2 |
children | 2 |
last_payout | 2017-08-24 19:47:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 355 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,114,956 |
net_rshares | 0 |
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!
author | bandli |
---|---|
permlink | re-reggaemuffin-re-bandli-re-reggaemuffin-introducing-the-coding-challenge-20170817t200437680z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 20:04:36 |
last_update | 2017-08-17 20:04:36 |
depth | 3 |
children | 1 |
last_payout | 2017-08-24 20:04:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 339 |
author_reputation | 1,950,997,435 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,116,163 |
net_rshares | 0 |
<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>
author | tipu |
---|---|
permlink | re-re-reggaemuffin-introducing-the-coding-challenge-20170817t194047303z-20170817t194736 |
category | coding-challenge |
json_metadata | "" |
created | 2017-08-17 19:47:39 |
last_update | 2017-08-17 19:47:39 |
depth | 2 |
children | 1 |
last_payout | 2017-08-24 19:47:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 338 |
author_reputation | 55,912,306,507,814 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,114,979 |
net_rshares | 0 |
Thank you for the tip!
author | bandli |
---|---|
permlink | re-tipu-re-re-reggaemuffin-introducing-the-coding-challenge-20170817t194736-20170817t200505268z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 20:05:03 |
last_update | 2017-08-17 20:05:03 |
depth | 3 |
children | 0 |
last_payout | 2017-08-24 20:05:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 22 |
author_reputation | 1,950,997,435 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,116,195 |
net_rshares | 0 |
Cool concept, don't know how to code like that but still seems pretty dope
author | bankholiday |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t144033270z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 14:40:33 |
last_update | 2017-08-17 14:40:33 |
depth | 1 |
children | 1 |
last_payout | 2017-08-24 14:40:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 74 |
author_reputation | 18,282,679,050 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,090,947 |
net_rshares | 0 |
You can always try it :) Or read the solutions others submit and see how they did it
author | reggaemuffin |
---|---|
permlink | re-bankholiday-re-reggaemuffin-introducing-the-coding-challenge-20170817t150113596z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 15:01:15 |
last_update | 2017-08-17 15:01:15 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 15:01:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 84 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,092,749 |
net_rshares | 0 |
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.
author | benniebanana |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t151818433z |
category | coding-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"]} |
created | 2017-08-17 15:18:18 |
last_update | 2017-08-17 16:57:42 |
depth | 1 |
children | 5 |
last_payout | 2017-08-24 15:18:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.436 HBD |
curator_payout_value | 0.137 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,406 |
author_reputation | 875,530,017,816 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,094,236 |
net_rshares | 164,600,576,083 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,617,815,737 | 1% | ||
dewallenband | 0 | 6,331,332,274 | 100% | ||
benniebanana | 0 | 7,013,378,391 | 100% | ||
gokulnk | 0 | 29,888,261,369 | 30% | ||
dirkodie | 0 | 817,070,647 | 100% | ||
maretha94 | 0 | 643,383,496 | 100% | ||
dse | 0 | 13,601,977,269 | 1% | ||
pieterb3 | 0 | 687,356,900 | 100% |
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.
author | reggaemuffin |
---|---|
permlink | re-benniebanana-re-reggaemuffin-introducing-the-coding-challenge-20170817t172427039z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:24:30 |
last_update | 2017-08-17 17:24:30 |
depth | 2 |
children | 4 |
last_payout | 2017-08-24 17:24:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.023 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 518 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,104,149 |
net_rshares | 6,931,827,479 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
benniebanana | 0 | 6,931,827,479 | 100% |
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() ````
author | benniebanana |
---|---|
permlink | re-reggaemuffin-re-benniebanana-re-reggaemuffin-introducing-the-coding-challenge-20170817t173128127z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:31:27 |
last_update | 2017-08-17 17:44:48 |
depth | 3 |
children | 3 |
last_payout | 2017-08-24 17:31:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.303 HBD |
curator_payout_value | 0.063 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 822 |
author_reputation | 875,530,017,816 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,104,637 |
net_rshares | 105,617,815,737 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,617,815,737 | 1% |
I wish I could understand those lines >.>
author | carlosd15 |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t151033881z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 15:10:33 |
last_update | 2017-08-17 15:10:33 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 15:10:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 41 |
author_reputation | 43,966,086,012,501 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,093,571 |
net_rshares | 0 |
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
author | codetechninja |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t170328715z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:03:33 |
last_update | 2017-08-17 17:03:33 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 17:03:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 119 |
author_reputation | 1,893,030,609 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,102,583 |
net_rshares | 563,763,200 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
codetechninja | 0 | 563,763,200 | 100% |
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?
author | cristiungureanu |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t150427587z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 15:05:42 |
last_update | 2017-08-17 15:05:42 |
depth | 1 |
children | 3 |
last_payout | 2017-08-24 15:05:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.020 HBD |
curator_payout_value | 0.005 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 184 |
author_reputation | 17,242,438,134 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,093,157 |
net_rshares | 7,332,395,096 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
joeyarnoldvn | 0 | 6,687,619,700 | 100% | ||
tfury | 0 | 644,775,396 | 100% |
Great
author | joeyarnoldvn |
---|---|
permlink | re-cristiungureanu-re-reggaemuffin-introducing-the-coding-challenge-20170817t155414363z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 15:54:15 |
last_update | 2017-08-17 15:54:15 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 15:54:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 5 |
author_reputation | 51,475,568,620,387 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,097,164 |
net_rshares | 0 |
Coding is awesome, try it :)
author | reggaemuffin |
---|---|
permlink | re-cristiungureanu-re-reggaemuffin-introducing-the-coding-challenge-20170817t150641407z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 15:06:45 |
last_update | 2017-08-17 15:06:45 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 15:06:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 28 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,093,239 |
net_rshares | 0 |
Nice
author | tfury |
---|---|
permlink | re-cristiungureanu-re-reggaemuffin-introducing-the-coding-challenge-20170817t173417574z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:34:18 |
last_update | 2017-08-17 17:34:18 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 17:34:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 4 |
author_reputation | 3,206,548,905,049 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,104,882 |
net_rshares | 0 |
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
author | datageek |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t145856810z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 14:59:00 |
last_update | 2017-08-17 14:59:00 |
depth | 1 |
children | 4 |
last_payout | 2017-08-24 14:59:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.366 HBD |
curator_payout_value | 0.003 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 392 |
author_reputation | 4,485,172,800,090 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,092,530 |
net_rshares | 106,228,042,937 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,617,815,737 | 1% | ||
codetechninja | 0 | 610,227,200 | 100% |
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.
author | cryptomaker |
---|---|
permlink | re-datageek-re-reggaemuffin-introducing-the-coding-challenge-20170817t151748361z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"links":["https://steemit.com/introduceyourself/@cryptomaker/first-introduceyourself-on-steemit"],"app":"steemit/0.1"} |
created | 2017-08-17 15:18:00 |
last_update | 2017-08-17 15:19:33 |
depth | 2 |
children | 1 |
last_payout | 2017-08-24 15:18:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 184 |
author_reputation | 17,042,683,569,275 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,094,195 |
net_rshares | -104,526,817,535 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | -105,617,815,737 | -1% | ||
cryptomaker | 0 | 1,090,998,202 | 100% |
I suggest you don't hijack other posts and ask for upvotes.
author | reggaemuffin |
---|---|
permlink | re-cryptomaker-re-datageek-re-reggaemuffin-introducing-the-coding-challenge-20170817t171044162z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:10:45 |
last_update | 2017-08-17 17:10:45 |
depth | 3 |
children | 0 |
last_payout | 2017-08-24 17:10:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 59 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,103,095 |
net_rshares | 0 |
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
author | reggaemuffin |
---|---|
permlink | re-datageek-re-reggaemuffin-introducing-the-coding-challenge-20170817t150026130z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 15:00:30 |
last_update | 2017-08-17 15:00:30 |
depth | 2 |
children | 1 |
last_payout | 2017-08-24 15:00:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 189 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,092,676 |
net_rshares | 597,836,800 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
codetechninja | 0 | 597,836,800 | 100% |
Yeah I got my pen and notebook ready. Would try to understand the thought process of each solution.
author | datageek |
---|---|
permlink | re-reggaemuffin-re-datageek-re-reggaemuffin-introducing-the-coding-challenge-20170817t175739381z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:57:48 |
last_update | 2017-08-17 17:57:48 |
depth | 3 |
children | 0 |
last_payout | 2017-08-24 17:57:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 99 |
author_reputation | 4,485,172,800,090 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,106,787 |
net_rshares | 0 |
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)) ```
author | eastmael |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t163546110z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 16:35:21 |
last_update | 2017-08-17 16:35:21 |
depth | 1 |
children | 3 |
last_payout | 2017-08-24 16:35:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.275 HBD |
curator_payout_value | 0.091 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 318 |
author_reputation | 78,967,407,130,763 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,100,357 |
net_rshares | 105,617,815,737 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,617,815,737 | 1% |
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 :)
author | reggaemuffin |
---|---|
permlink | re-eastmael-re-reggaemuffin-introducing-the-coding-challenge-20170817t173004188z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:30:06 |
last_update | 2017-08-17 17:53:09 |
depth | 2 |
children | 2 |
last_payout | 2017-08-24 17:30:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 323 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,104,541 |
net_rshares | 0 |
Thank you for the feedback. I'm come from Java. Automatically coded in it's coding style. lols
author | eastmael |
---|---|
permlink | re-reggaemuffin-re-eastmael-re-reggaemuffin-introducing-the-coding-challenge-20170818t170513133z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 17:04:45 |
last_update | 2017-08-18 17:04:45 |
depth | 3 |
children | 0 |
last_payout | 2017-08-25 17:04:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 94 |
author_reputation | 78,967,407,130,763 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,191,805 |
net_rshares | 0 |
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.
author | philosophist |
---|---|
permlink | re-reggaemuffin-re-eastmael-re-reggaemuffin-introducing-the-coding-challenge-20170818t061116915z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 06:11:15 |
last_update | 2017-08-18 06:11:15 |
depth | 3 |
children | 0 |
last_payout | 2017-08-25 06:11:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 201 |
author_reputation | 1,642,759,591,030 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,149,363 |
net_rshares | 0 |
Nice post
author | fauzi86 | ||||||
---|---|---|---|---|---|---|---|
permlink | re-reggaemuffin-2017817t213551520z | ||||||
category | coding-challenge | ||||||
json_metadata | {"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"} | ||||||
created | 2017-08-17 14:35:54 | ||||||
last_update | 2017-08-17 14:35:54 | ||||||
depth | 1 | ||||||
children | 0 | ||||||
last_payout | 2017-08-24 14:35:54 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 9 | ||||||
author_reputation | 2,932,445,711,161 | ||||||
root_title | "Introducing the Coding Challenge" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 12,090,493 | ||||||
net_rshares | 4,134,400,858 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
fauzi86 | 0 | 4,134,400,858 | 100% |
```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.
author | gokulnk |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t183339395z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"links":["https://steemit.com/steemgig/@gokulnk/programming-challenge-1-break-it-down-further"],"app":"steemit/0.1"} |
created | 2017-08-17 18:33:39 |
last_update | 2017-08-17 18:33:39 |
depth | 1 |
children | 1 |
last_payout | 2017-08-24 18:33:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.274 HBD |
curator_payout_value | 0.091 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 874 |
author_reputation | 17,871,219,215,380 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,109,684 |
net_rshares | 105,637,451,265 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,637,451,265 | 1% |
I submitted an entry for your challenge, pretty cool :)
author | reggaemuffin |
---|---|
permlink | re-gokulnk-re-reggaemuffin-introducing-the-coding-challenge-20170817t192928190z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 19:29:30 |
last_update | 2017-08-17 19:29:30 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 19:29:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 55 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,113,631 |
net_rshares | 0 |
Great post and very interesting
author | jhoshua1144 |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t151355728z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 14:51:00 |
last_update | 2017-08-17 14:51:00 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 14:51:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 31 |
author_reputation | 67,841,557,506 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,091,831 |
net_rshares | 0 |
Thanks for the information .. i am happy to see this news .. help devoted me
author | kingsteem | ||||||
---|---|---|---|---|---|---|---|
permlink | re-reggaemuffin-2017817t22129922z | ||||||
category | coding-challenge | ||||||
json_metadata | {"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"} | ||||||
created | 2017-08-17 15:12:15 | ||||||
last_update | 2017-08-17 15:12:15 | ||||||
depth | 1 | ||||||
children | 0 | ||||||
last_payout | 2017-08-24 15:12:15 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 76 | ||||||
author_reputation | 12,311,247,330 | ||||||
root_title | "Introducing the Coding Challenge" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 12,093,703 | ||||||
net_rshares | 0 |
Next post Please. My mind is moving. https://media.giphy.com/media/nZ9TjTs1lfTwI/giphy.gif
author | kumar.malhotra |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t174707850z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"image":["https://media.giphy.com/media/nZ9TjTs1lfTwI/giphy.gif"],"app":"steemit/0.1"} |
created | 2017-08-17 17:47:12 |
last_update | 2017-08-17 17:47:12 |
depth | 1 |
children | 1 |
last_payout | 2017-08-24 17:47:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 93 |
author_reputation | 159,754,286,047 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,105,913 |
net_rshares | 0 |
Can you give me feedback? Was it too hard or too easy? What would you like to see next?
author | reggaemuffin |
---|---|
permlink | re-kumarmalhotra-re-reggaemuffin-introducing-the-coding-challenge-20170817t174755509z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:47:57 |
last_update | 2017-08-17 17:47:57 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 17:47:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 87 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,105,974 |
net_rshares | 0 |
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") ```
author | lavokad |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170818t165825769z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 16:58:27 |
last_update | 2017-08-18 16:58:27 |
depth | 1 |
children | 2 |
last_payout | 2017-08-25 16:58:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 729 |
author_reputation | 3,393,470,987 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,191,308 |
net_rshares | 1,160,635,170 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
maramed | 0 | 1,160,635,170 | 100% | ||
lavokad | 0 | 0 | 0% |
lisp! What a brilliant, old and unique language :) Hope to find free time and learn it well one day :P
author | maramed |
---|---|
permlink | re-lavokad-re-reggaemuffin-introducing-the-coding-challenge-20170818t195227804z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 19:52:33 |
last_update | 2017-08-18 19:52:33 |
depth | 2 |
children | 1 |
last_payout | 2017-08-25 19:52:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 102 |
author_reputation | 29,004,247,491 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,204,384 |
net_rshares | 1,149,028,729 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
lavokad | 0 | 1,149,028,729 | 100% |
:P true. You will, i'm sure about that
author | lavokad |
---|---|
permlink | re-maramed-re-lavokad-re-reggaemuffin-introducing-the-coding-challenge-20170818t195438009z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 19:54:39 |
last_update | 2017-08-18 19:54:39 |
depth | 3 |
children | 0 |
last_payout | 2017-08-25 19:54:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 38 |
author_reputation | 3,393,470,987 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,204,537 |
net_rshares | 0 |
I'm gone do it.
author | melek |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t144328205z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 14:43:27 |
last_update | 2017-08-17 14:43:27 |
depth | 1 |
children | 1 |
last_payout | 2017-08-24 14:43:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.064 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 15 |
author_reputation | 3,825,345,106,211 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,091,205 |
net_rshares | 18,778,001,291 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
melek | 0 | 18,778,001,291 | 100% |
Nice! Post your solution here when you got it. https://repl.it is really good for sharing code.
author | reggaemuffin |
---|---|
permlink | re-melek-re-reggaemuffin-introducing-the-coding-challenge-20170817t145201173z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"links":["https://repl.it"],"app":"steemit/0.1"} |
created | 2017-08-17 14:52:03 |
last_update | 2017-08-17 14:52:03 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 14:52:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 95 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,091,922 |
net_rshares | 0 |
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.
author | mkt |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t154821852z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"links":["https://pastebin.com/q0GqCaG2"],"app":"steemit/0.1"} |
created | 2017-08-17 15:48:09 |
last_update | 2017-08-17 15:53:57 |
depth | 1 |
children | 3 |
last_payout | 2017-08-24 15:48:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.353 HBD |
curator_payout_value | 0.113 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,234 |
author_reputation | 45,513,283,519,678 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,096,667 |
net_rshares | 134,106,493,332 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,617,815,737 | 1% | ||
benniebanana | 0 | 7,135,704,758 | 100% | ||
pilcrow | 0 | 21,352,972,837 | 50.51% |
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 :)
author | reggaemuffin |
---|---|
permlink | re-mkt-re-reggaemuffin-introducing-the-coding-challenge-20170817t171542809z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:15:45 |
last_update | 2017-08-17 17:15:45 |
depth | 2 |
children | 2 |
last_payout | 2017-08-24 17:15:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 446 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,103,479 |
net_rshares | 0 |
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!
author | mkt |
---|---|
permlink | re-reggaemuffin-re-mkt-re-reggaemuffin-introducing-the-coding-challenge-20170817t203611617z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"users":["benniebanana"],"app":"steemit/0.1"} |
created | 2017-08-17 20:36:00 |
last_update | 2017-08-17 20:40:42 |
depth | 3 |
children | 1 |
last_payout | 2017-08-24 20:36:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 968 |
author_reputation | 45,513,283,519,678 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,118,156 |
net_rshares | 0 |
Probably the shortest FizzBuzz code for(i=0;i<1e2;) console.log((++i%3?"":"Fizz")+(i%5?"":"Buzz")||i)
author | monkonacid |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20180618t132550644z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2018-06-18 13:24:27 |
last_update | 2018-06-18 13:24:27 |
depth | 1 |
children | 2 |
last_payout | 2018-06-25 13:24:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 111 |
author_reputation | 436,763,812 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 61,225,466 |
net_rshares | 0 |
You can go even shorter ;) But I mean the idea is to have it nice and readable and thought through :P
author | reggaemuffin |
---|---|
permlink | re-monkonacid-re-reggaemuffin-introducing-the-coding-challenge-20180619t103438706z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2018-06-19 10:34:36 |
last_update | 2018-06-19 10:34:36 |
depth | 2 |
children | 1 |
last_payout | 2018-06-26 10:34:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.035 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 101 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 61,342,657 |
net_rshares | 17,563,191,347 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
upheaver | 0 | 2,091,705,568 | 6% | ||
upgoat | 0 | 326,777,447 | 10% | ||
simi | 0 | 15,144,708,332 | 54% |
Not the best looking code, however you could add some comments... :D
author | monkonacid |
---|---|
permlink | re-reggaemuffin-re-monkonacid-re-reggaemuffin-introducing-the-coding-challenge-20180619t173207673z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2018-06-19 17:32:09 |
last_update | 2018-06-19 17:32:09 |
depth | 3 |
children | 0 |
last_payout | 2018-06-26 17:32:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 69 |
author_reputation | 436,763,812 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 61,387,277 |
net_rshares | 0 |
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>
author | mrziaulkamal |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t150125368z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"image":["https://steemit.com/images/steemit-share.png"],"links":["https://steemit.com/@mrziaulkamal"],"app":"steemit/0.1"} |
created | 2017-08-17 15:01:24 |
last_update | 2017-08-17 15:01:24 |
depth | 1 |
children | 1 |
last_payout | 2017-08-24 15:01:24 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 780 |
author_reputation | -952,072,864 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,092,757 |
net_rshares | -105,617,815,737 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | -105,617,815,737 | -1% |
You did not upvote me, please don't spam :)
author | reggaemuffin |
---|---|
permlink | re-mrziaulkamal-re-reggaemuffin-introducing-the-coding-challenge-20170817t150357691z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 15:04:00 |
last_update | 2017-08-17 15:04:00 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 15:04:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 43 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,093,010 |
net_rshares | 0 |
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.
author | n4t3w |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170820t162023033z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-20 16:20:30 |
last_update | 2017-08-20 16:20:30 |
depth | 1 |
children | 0 |
last_payout | 2017-08-27 16:20:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 468 |
author_reputation | 49,667,465,108 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,359,988 |
net_rshares | 0 |
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.
author | philosophist |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t191654393z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 19:16:54 |
last_update | 2017-08-17 19:16:54 |
depth | 1 |
children | 5 |
last_payout | 2017-08-24 19:16:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.313 HBD |
curator_payout_value | 0.055 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,931 |
author_reputation | 1,642,759,591,030 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,112,691 |
net_rshares | 106,693,625,857 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,637,451,265 | 1% | ||
quarterlifehuman | 0 | 1,056,174,592 | 100% |
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 :)
author | reggaemuffin |
---|---|
permlink | re-philosophist-re-reggaemuffin-introducing-the-coding-challenge-20170817t193456828z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 19:35:00 |
last_update | 2017-08-17 19:35:00 |
depth | 2 |
children | 4 |
last_payout | 2017-08-24 19:35:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 245 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,114,069 |
net_rshares | 0 |
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 ```
author | philosophist |
---|---|
permlink | re-reggaemuffin-re-philosophist-re-reggaemuffin-introducing-the-coding-challenge-20170818t013330149z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 01:33:30 |
last_update | 2017-08-18 01:36:27 |
depth | 3 |
children | 3 |
last_payout | 2017-08-25 01:33:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 994 |
author_reputation | 1,642,759,591,030 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,134,774 |
net_rshares | 0 |
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!
author | pilcrow | ||||||
---|---|---|---|---|---|---|---|
permlink | re-reggaemuffin-2017817t184832996z | ||||||
category | coding-challenge | ||||||
json_metadata | {"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"} | ||||||
created | 2017-08-17 16:48:33 | ||||||
last_update | 2017-08-17 16:48:33 | ||||||
depth | 1 | ||||||
children | 1 | ||||||
last_payout | 2017-08-24 16:48:33 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.366 HBD | ||||||
curator_payout_value | 0.007 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 212 | ||||||
author_reputation | 2,531,070,549,481 | ||||||
root_title | "Introducing the Coding Challenge" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 12,101,453 | ||||||
net_rshares | 113,205,958,237 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
good-karma | 0 | 102,192,980,241 | 0.5% | ||
mondeja | 0 | 145,808,223 | 0.5% | ||
mysteem | 0 | 168,217,247 | 1% | ||
demo | 0 | 324,528,789 | 1% | ||
swisswatcher | 0 | 2,016,393,783 | 0.5% | ||
feruz | 0 | 3,042,146,291 | 1% | ||
esteemapp | 0 | 3,483,444,771 | 1% | ||
sellergenius | 0 | 100,330,039 | 0.5% | ||
meysam | 0 | 748,011,561 | 0.25% | ||
bounties | 0 | 344,949,311 | 1% | ||
steempoll | 0 | 334,842,013 | 1% | ||
tipping | 0 | 304,305,968 | 1% |
Looking forward to your solution :)
author | reggaemuffin |
---|---|
permlink | re-pilcrow-re-reggaemuffin-2017817t184832996z-20170817t180235271z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 18:02:36 |
last_update | 2017-08-17 18:02:36 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 18:02:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 35 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,107,227 |
net_rshares | 0 |
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 ;)
author | pilcrow |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170818t085726321z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"links":["https://jsfiddle.net/jf68mfj1/2/"],"app":"steemit/0.1"} |
created | 2017-08-18 08:57:27 |
last_update | 2017-08-18 08:58:15 |
depth | 1 |
children | 5 |
last_payout | 2017-08-25 08:57:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.991 HBD |
curator_payout_value | 0.326 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,635 |
author_reputation | 2,531,070,549,481 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,157,695 |
net_rshares | 377,412,334,263 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 316,922,974,726 | 3% | ||
bulleth | 0 | 58,793,794,330 | 100% | ||
ramzialhaddadtm | 0 | 616,177,987 | 100% | ||
quarterlifehuman | 0 | 1,079,387,220 | 100% |
This is really neat. Well done
author | benniebanana |
---|---|
permlink | re-pilcrow-re-reggaemuffin-introducing-the-coding-challenge-20170819t122006588z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-19 12:20:06 |
last_update | 2017-08-19 12:20:06 |
depth | 2 |
children | 0 |
last_payout | 2017-08-26 12:20:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.074 HBD |
curator_payout_value | 0.024 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 30 |
author_reputation | 875,530,017,816 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,258,140 |
net_rshares | 27,329,218,811 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
pilcrow | 0 | 27,329,218,811 | 50.51% |
+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 :)
author | reggaemuffin |
---|---|
permlink | re-pilcrow-re-reggaemuffin-introducing-the-coding-challenge-20170818t102036456z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 10:20:39 |
last_update | 2017-08-18 10:20:39 |
depth | 2 |
children | 2 |
last_payout | 2017-08-25 10:20:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 564 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,162,209 |
net_rshares | 0 |
Thanks! In that case I'll wait for the next one. This is fun :)
author | pilcrow | ||||||
---|---|---|---|---|---|---|---|
permlink | re-reggaemuffin-2017818t124833597z | ||||||
category | coding-challenge | ||||||
json_metadata | {"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"} | ||||||
created | 2017-08-18 10:48:36 | ||||||
last_update | 2017-08-18 10:48:36 | ||||||
depth | 3 | ||||||
children | 0 | ||||||
last_payout | 2017-08-25 10:48:36 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 63 | ||||||
author_reputation | 2,531,070,549,481 | ||||||
root_title | "Introducing the Coding Challenge" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 12,163,717 | ||||||
net_rshares | 0 |
author | zuricher |
---|---|
permlink | re-re-pilcrow-re-reggaemuffin-introducing-the-coding-challenge-20170818t102036456z-20200829t032329z |
category | coding-challenge |
json_metadata | "{"app": "beem/0.23.9"}" |
created | 2020-08-29 03:23:30 |
last_update | 2020-08-29 03:23:30 |
depth | 3 |
children | 0 |
last_payout | 2020-09-05 03:23:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1 |
author_reputation | -39,571,640,904 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 99,332,904 |
net_rshares | 0 |
<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>
author | tipu |
---|---|
permlink | re-re-reggaemuffin-introducing-the-coding-challenge-20170818t085726321z-20170818t102050 |
category | coding-challenge |
json_metadata | "" |
created | 2017-08-18 10:20:51 |
last_update | 2017-08-18 10:20:51 |
depth | 2 |
children | 0 |
last_payout | 2017-08-25 10:20:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 430 |
author_reputation | 55,912,306,507,814 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,162,224 |
net_rshares | 0 |
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. :-)
author | pinaynomad |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170818t082603536z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 08:26:03 |
last_update | 2017-08-18 08:26:03 |
depth | 1 |
children | 0 |
last_payout | 2017-08-25 08:26:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 179 |
author_reputation | 3,805,814,570,723 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,156,011 |
net_rshares | 0 |
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, ```
author | ratticus |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170818t080136457z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 08:01:36 |
last_update | 2017-08-18 08:01:36 |
depth | 1 |
children | 1 |
last_payout | 2017-08-25 08:01:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.275 HBD |
curator_payout_value | 0.091 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,884 |
author_reputation | 5,793,669,654,286 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,154,812 |
net_rshares | 105,640,991,575 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,640,991,575 | 1% |
Looking good to me :)
author | reggaemuffin |
---|---|
permlink | re-ratticus-re-reggaemuffin-introducing-the-coding-challenge-20170818t102220794z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 10:22:24 |
last_update | 2017-08-18 10:22:24 |
depth | 2 |
children | 0 |
last_payout | 2017-08-25 10:22:24 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 21 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,162,318 |
net_rshares | 0 |
My ruby solution to FizzBuzz: https://repl.it/KNug/2  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.
author | reggaemuffin |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t145007513z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"image":["https://steemitimages.com/DQmPnwXYo6v2UYahrzvbKuKNfYWvTS8D1nimu9XCLXpD3oX/image.png"],"links":["https://repl.it/KNug/2"],"app":"steemit/0.1"} |
created | 2017-08-17 14:50:09 |
last_update | 2017-08-17 14:50:36 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 14:50:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.031 HBD |
curator_payout_value | 0.006 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 604 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,091,769 |
net_rshares | 10,733,352,661 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
benniebanana | 0 | 7,339,582,037 | 100% | ||
j4y | 0 | 2,640,018,812 | 100% | ||
codetechninja | 0 | 585,446,400 | 100% | ||
bankholiday | 0 | 168,305,412 | 100% |
Great post and very interesting. Provide a very useful knowledge. Thank you so much for sharing
author | rizasukma |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t143828984z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 14:38:33 |
last_update | 2017-08-17 14:38:33 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 14:38:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 95 |
author_reputation | 56,673,466,694,018 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,090,748 |
net_rshares | 0 |
If I could code I would be all over this :) looks like a cool idea good luck!
author | steemitadventure |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t164108781z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 16:41:09 |
last_update | 2017-08-17 16:41:09 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 16:41:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 77 |
author_reputation | 38,702,956,343,359 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,100,851 |
net_rshares | 0 |
@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.
author | tantawi | ||||||
---|---|---|---|---|---|---|---|
permlink | re-reggaemuffin-2017817t22164886z | ||||||
category | coding-challenge | ||||||
json_metadata | {"tags":"coding-challenge","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"} | ||||||
created | 2017-08-17 15:16:12 | ||||||
last_update | 2017-08-17 15:16:12 | ||||||
depth | 1 | ||||||
children | 0 | ||||||
last_payout | 2017-08-24 15:16:12 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 414 | ||||||
author_reputation | 4,391,501,911,743 | ||||||
root_title | "Introducing the Coding Challenge" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 12,094,042 | ||||||
net_rshares | 3,892,422,535 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
tantawi | 0 | 3,892,422,535 | 100% |
I like it! I am not good at coding but I love the challenge and one sweet day win one of your challenges :)
author | tarekadam |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t171410493z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 17:14:09 |
last_update | 2017-08-17 17:14:09 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 17:14:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 107 |
author_reputation | 50,131,776,387,207 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,103,358 |
net_rshares | 0 |
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(); ```
author | tarekadam |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t183855297z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 18:38:54 |
last_update | 2017-08-17 18:38:54 |
depth | 1 |
children | 1 |
last_payout | 2017-08-24 18:38:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.278 HBD |
curator_payout_value | 0.091 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 427 |
author_reputation | 50,131,776,387,207 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,110,053 |
net_rshares | 106,798,081,292 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 105,637,451,265 | 1% | ||
okremenovic | 0 | 1,160,630,027 | 100% |
Looks good to me ;)
author | reggaemuffin |
---|---|
permlink | re-tarekadam-re-reggaemuffin-introducing-the-coding-challenge-20170817t193556268z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 19:35:57 |
last_update | 2017-08-17 19:35:57 |
depth | 2 |
children | 0 |
last_payout | 2017-08-24 19:35:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.166 HBD |
curator_payout_value | 0.055 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 19 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,114,148 |
net_rshares | 64,624,258,529 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
tarekadam | 0 | 64,624,258,529 | 15% |
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.
author | turpsy |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170817t151225604z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-17 15:12:27 |
last_update | 2017-08-17 15:12:27 |
depth | 1 |
children | 0 |
last_payout | 2017-08-24 15:12:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 178 |
author_reputation | 22,352,016,062,417 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,093,717 |
net_rshares | 0 |
Two solutions with Haskell: http://codepad.org/tIR16emr 
author | tzs |
---|---|
permlink | re-reggaemuffin-introducing-the-coding-challenge-20170818t022340743z |
category | coding-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"} |
created | 2017-08-18 02:23:42 |
last_update | 2017-08-18 02:23:42 |
depth | 1 |
children | 6 |
last_payout | 2017-08-25 02:23:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.585 HBD |
curator_payout_value | 0.193 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 226 |
author_reputation | 66,276,041,146 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,137,454 |
net_rshares | 226,124,129,786 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
reggaemuffin | 0 | 211,281,983,150 | 2% | ||
benniebanana | 0 | 6,932,388,784 | 100% | ||
tzs | 0 | 7,909,757,852 | 100% |
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.
author | reggaemuffin |
---|---|
permlink | re-tzs-re-reggaemuffin-introducing-the-coding-challenge-20170818t054013756z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 05:40:15 |
last_update | 2017-08-18 05:40:15 |
depth | 2 |
children | 5 |
last_payout | 2017-08-25 05:40:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.020 HBD |
curator_payout_value | 0.006 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 492 |
author_reputation | 37,964,839,695,531 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,147,892 |
net_rshares | 7,757,166,712 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
tzs | 0 | 7,757,166,712 | 100% |
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.
author | ratticus |
---|---|
permlink | re-reggaemuffin-re-tzs-re-reggaemuffin-introducing-the-coding-challenge-20170818t072036776z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 07:20:36 |
last_update | 2017-08-18 07:20:36 |
depth | 3 |
children | 3 |
last_payout | 2017-08-25 07:20:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.020 HBD |
curator_payout_value | 0.006 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 266 |
author_reputation | 5,793,669,654,286 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,152,860 |
net_rshares | 7,599,660,789 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
tzs | 0 | 7,599,660,789 | 100% |
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`.
author | tzs |
---|---|
permlink | re-reggaemuffin-re-tzs-re-reggaemuffin-introducing-the-coding-challenge-20170818t233545415z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 23:35:42 |
last_update | 2017-08-18 23:35:42 |
depth | 3 |
children | 0 |
last_payout | 2017-08-25 23:35:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 389 |
author_reputation | 66,276,041,146 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,217,895 |
net_rshares | 0 |