![]() |
|
[C] FizzBuzz - a VERY simple challange for newbie C++'ers - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] FizzBuzz - a VERY simple challange for newbie C++'ers (/showthread.php?tid=6074344) |
FizzBuzz - a VERY simple challange for newbie C++'ers - SIM-3991524 - May 3, 2020 Checkout https://www.youtube.com/watch?v=QPZ0pIK_wsc Instructions stated in video however, For each number from 1 to 100, if that number is a multiple of 3, print 'Fizz'. If that number is a multiple of 5, print 'Buzz'. If the number is a multiple of both 3 and 5, print 'FizzBuzz'. Otherwise print that number Are you a nub? Would you get the job? Post your solutions below! RE: FizzBuzz - a VERY simple challange for newbie C++'ers - Sмℯґƒ - May 11, 2020 Code int main()RE: FizzBuzz - a VERY simple challange for newbie C++'ers - 0xDEAD10CC - May 11, 2020 For fun: Code #include <iostream>^ Wow look at that shitty highlighting.. Code #include <iostream>RE: FizzBuzz - a VERY simple challange for newbie C++'ers - 4Txe4y33C9zvNhMj - May 12, 2020 Probably not the fastest or most elegant way, but this is the first thing that came to my mind: Code #include <iostream>(May 11, 2020 10:14 PM)0xDEAD10CC Wrote: For fun: Cool idea to save just one string and build the substring based off that! RE: FizzBuzz - a VERY simple challange for newbie C++'ers - 0xDEAD10CC - May 12, 2020 (May 12, 2020 06:03 AM)4Txe4y33C9zvNhMj Wrote: Probably not the fastest or most elegant way, but this is the first thing that came to my mind: Probably not the most maintainable code in the world but this problem has been out for years, so I figured I'd use some out of the box thinking and come up with some alternatives. Lookup tables are fast, and with the one method, you don't have to check for divisibility of larger numbers, just keep track of the multiples up to 15 and reset. :) It will be faster once it reaches the larger numbers. RE: FizzBuzz - a VERY simple challange for newbie C++'ers - SIM-3991524 - May 12, 2020 did this just for fun. here's a solution that only uses O(1) operations (addition/comparison). Still runs in O(n) time like the rest Code #include <stdlib.h>RE: FizzBuzz - a VERY simple challange for newbie C++'ers - 0xDEAD10CC - May 12, 2020 (May 12, 2020 07:23 PM)SIM-3991524 Wrote: did this just for fun. here's a solution that only uses O(1) operations (addition/comparison). Still runs in O(n) time like the rest That's not C++.. 🤐 RE: a VERY simple challange for newbie C++'ers But it also does not work as the problem was intended. It writes out i for all the numbers in the range, and writing the words beside the numbers changes the requirements and makes the problem easier... The first solution written by "Sмℯґƒ" in post #2 is also invalid... Where are the newlines (not to mention == and not =)? Both fails IMHO. RE: FizzBuzz - a VERY simple challange for newbie C++'ers - SIM-3991524 - May 12, 2020 (May 12, 2020 11:20 PM)0xDEAD10CC Wrote: That's not C++.. 🤐 Its fine bro its just to have fun RE: FizzBuzz - a VERY simple challange for newbie C++'ers - My Computer - May 13, 2020 Code #include <iostream>This was my solution. According to the video, it's "dodgy." Guess I am a nub. :( Jokes aside, his final solution was actually pretty impressive. RE: FizzBuzz - a VERY simple challange for newbie C++'ers - Sugawara - May 14, 2020 A quick code that I can think of. Code int main() |