Viewing a response to: @philosophist/re-reggaemuffin-introducing-the-coding-challenge-20170817t191654393z
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 |
That is a good idea! Nice improvement, this is worth a tip!
author | reggaemuffin |
---|---|
permlink | re-philosophist-re-reggaemuffin-re-philosophist-re-reggaemuffin-introducing-the-coding-challenge-20170818t052705282z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 05:27:06 |
last_update | 2017-08-18 05:27:06 |
depth | 4 |
children | 1 |
last_payout | 2017-08-25 05:27: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 | 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,147,251 |
net_rshares | 0 |
Thanks bud! Much appreciated.
author | philosophist |
---|---|
permlink | re-reggaemuffin-re-philosophist-re-reggaemuffin-re-philosophist-re-reggaemuffin-introducing-the-coding-challenge-20170818t055825025z |
category | coding-challenge |
json_metadata | {"tags":["coding-challenge"],"app":"steemit/0.1"} |
created | 2017-08-18 05:58:24 |
last_update | 2017-08-18 05:58:24 |
depth | 5 |
children | 0 |
last_payout | 2017-08-25 05:58: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 | 29 |
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,148,732 |
net_rshares | 0 |
<table><tr><td>http://i.imgur.com/IFF4CSc.jpg</td><td><p>Hi @philosophist! You have just received a 0.5 SBD tip from @reggaemuffin!</p><p><strong>From @reggaemuffin : <a href=https://steemit.com/witness-category/@reggaemuffin/witness-reggaemuffin rel="noopener"> If You Like What I Do, Vote Me For Witness :)</a></strong></p></td></tr></table><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>
author | tipu |
---|---|
permlink | re-re-reggaemuffin-re-philosophist-re-reggaemuffin-introducing-the-coding-challenge-20170818t013330149z-20170818t052721 |
category | coding-challenge |
json_metadata | "" |
created | 2017-08-18 05:27:21 |
last_update | 2017-08-18 05:27:21 |
depth | 4 |
children | 0 |
last_payout | 2017-08-25 05:27: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 | 517 |
author_reputation | 55,914,546,531,008 |
root_title | "Introducing the Coding Challenge" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,147,271 |
net_rshares | 0 |