Sinisterly
Challenge - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: Challenge (/Thread-Challenge--100155)

Pages: 1 2


Challenge - casperandersen - 10-05-2018

Hey there guys and gals. So i would just like to propose a challenge for you guys. I want to challenge you to make a FizzBuzz program. This will not be a contest, so no prize.
But try to make a program that prints all the numbers from 1 to 100 with the following exceptions:
1. for every number divisible by 3, you Write Fizz
2. for every number divisible by 5 you write Buzz
3. and for every number divisible by 3 AND 5 you write FIzzBuzz

Good luck, and have fun Smile feel free to post here if you are stuck xD

ps. to challenge you all further, try to make it as small as possible


RE: Challenge - casperandersen - 10-05-2018

also, please post your code here when you are done Smile


RE: Challenge - Jimbo39238 - 10-05-2018

I remember doing this a long time ago in JavaScript. Simple and a good way to test your skills as a beginner Tongue


RE: Challenge - casperandersen - 10-06-2018

(10-05-2018, 11:01 PM)Jimbo39238 Wrote: I remember doing this a long time ago in JavaScript. Simple and a good way to test your skills as a beginner Tongue

why dont you give it a shot? xD


RE: Challenge - Vanfuzzy - 10-06-2018

tbh I have no experience in coding but good job with this post Biggrin


RE: Challenge - casperandersen - 10-06-2018

thanks Biggrin give it a shot anyways Biggrin


RE: Challenge - slothic - 11-01-2018

Code:
a = 1 for i in range(100): if (a % 3) + (a % 5) == 0: print("Number:",a," FIzzBuzz") if (a % 3) == 0: print("Number:",a,"Fizz") elif (a % 5) == 0: print("Number:",a,"Buzz") else: print(a) a += 1
It was easy to do, I just didn't see this post earlier Biggrin


RE: Challenge - casperandersen - 11-02-2018

(11-01-2018, 09:40 PM)slothic Wrote:
Code:
a = 1 for i in range(100): if (a % 3) + (a % 5) == 0: print("Number:",a," FIzzBuzz") if (a % 3) == 0: print("Number:",a,"Fizz") elif (a % 5) == 0: print("Number:",a,"Buzz") else: print(a) a += 1
It was easy to do, I just didn't see this post earlier Biggrin
nice one. How do you like this?
Code:
print '\n'.join("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i) for i in range(1,101))
quite proud of this oneliner Smile


RE: Challenge - slothic - 11-02-2018

(11-02-2018, 03:46 PM)oxnan Wrote:
(11-01-2018, 09:40 PM)slothic Wrote:
Code:
a = 1 for i in range(100): if (a % 3) + (a % 5) == 0: print("Number:",a," FIzzBuzz") if (a % 3) == 0: print("Number:",a,"Fizz") elif (a % 5) == 0: print("Number:",a,"Buzz") else: print(a) a += 1
It was easy to do, I just didn't see this post earlier Biggrin
nice one. How do you like this?
Code:
print '\n'.join("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i) for i in range(1,101))
quite proud of this oneliner Smile

Damn, I've never tried doing anything in one line. Looks good.


RE: Challenge - chunky - 11-07-2018

(11-02-2018, 03:46 PM)oxnan Wrote: nice one. How do you like this?
Code:
print '\n'.join("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i) for i in range(1,101))
quite proud of this oneliner Smile
Kinda weird you came up with a solution that already has been public in 2013  Tongue
http://michaeljgilliland.blogspot.com/2013/01/one-line-fizz-buzz-test-in-python.html