DEV Community

Cover image for Code Your Way: BadaBing! staff for The DEV Team

Posted on

Code Your Way: BadaBing!

Hey there, you've happened upon Code Your Way: Quick Challenges in Every Language! Every week, we throw down a new programming challenge that you can take on in any language you like. It doesn't matter if you're a coding ninja or a newbie, these challenges are perfect for taking a break, sharpening your skills, pushing yourself, and learning new tricks. So, grab your go-to coding tools and let's dive in.

Today’s challenge is the BadaBing!

Write a program that prints numbers from 1 to 100, but for multiples of three, print "Bada" instead of the number and for multiples of five, print "Bing." For numbers that are multiples of both three and five, print "BadaBing."

Your goal is to complete this challenge in the most efficient way possible. You may want to time yourself. ⏰ πŸƒπŸ»β€β™‚οΈ See you in the comments!

Top comments (2)

siddharthshyniben profile image

Golfed it! 63 bytes.

Enter fullscreen mode Exit fullscreen mode

Surprisingly for me, golfing made the code more efficient! Takes about 3ms, sometimes 2.5, which is a big improvement from the 4ms for my non-golfed version.

namenotavilable profile image
Adam Markiewicz

for i in range(1, 101):
if i % 3 == 0 and i % 5 == 0:
elif i % 3 == 0:
elif i % 5 == 0: