[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
FizzBuzz
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 25
Thread images: 3
File: 1442882720449.jpg (40 KB, 600x846) Image search: [Google]
1442882720449.jpg
40 KB, 600x846
Fizzbuzz thread?

pls r8 and do not hate

public static void main(String[] args) {
String res;
for(int i=1; i<=100; i++){
res = "";
if(i % 3 == 0){
res += "fizz";
}
if(i % 5 == 0){
res += "buzz";
}
if(res.equals("")){
res += i;
}
System.out.println(res);
}
}


pic unrelated
>>
File: 1441250309081.jpg (143 KB, 457x381) Image search: [Google]
1441250309081.jpg
143 KB, 457x381
>>51852750
Discusting.
>>
>>51853049
Oi at least I don't use mod 15
>>
>>51852750
I don't even c# and I can guess that line 4 is unnecessary. Did you read the docs for String's default ctor, anon?
>>
>>51854742
>System.out.println(res);
>C#
Thats java u dumb normie
>>
>>51854855
I dont Java either.

Original question still stands.
>>
Ree java get out. Real men use ArnoldC.
IT'S SHOWTIME
HEY CHRISTMAS TREE result
YOU SET US UP @NO PROBLEMO
HEY CHRISTMAS TREE modresult
YOU SET US UP @I LIED
HEY CHRISTMAS TREE mod3result
YOU SET US UP @I LIED
HEY CHRISTMAS TREE mod3
YOU SET US UP 1
HEY CHRISTMAS TREE mod5result
YOU SET US UP @I LIED
HEY CHRISTMAS TREE mod5
YOU SET US UP 1
HEY CHRISTMAS TREE currentInt
YOU SET US UP 1
STICK AROUND result

GET YOUR ASS TO MARS mod3
DO IT NOW modulo currentInt 3

GET YOUR ASS TO MARS mod5
DO IT NOW modulo currentInt 5

GET TO THE CHOPPER mod3result
HERE IS MY INVITATION mod3
YOU ARE NOT YOU YOU ARE ME 0
ENOUGH TALK

GET TO THE CHOPPER mod5result
HERE IS MY INVITATION mod5
YOU ARE NOT YOU YOU ARE ME 0
ENOUGH TALK

GET TO THE CHOPPER modresult
HERE IS MY INVITATION mod3result
CONSIDER THAT A DIVORCE mod5result
ENOUGH TALK

BECAUSE I'M GOING TO SAY PLEASE mod3result
TALK TO THE HAND "Fizz"
YOU HAVE NO RESPECT FOR LOGIC

BECAUSE I'M GOING TO SAY PLEASE mod5result
TALK TO THE HAND "Buzz"
YOU HAVE NO RESPECT FOR LOGIC

BECAUSE I'M GOING TO SAY PLEASE modresult
BULLSHIT
TALK TO THE HAND currentInt
YOU HAVE NO RESPECT FOR LOGIC

GET TO THE CHOPPER result
HERE IS MY INVITATION 100
LET OFF SOME STEAM BENNET currentInt
ENOUGH TALK
GET TO THE CHOPPER currentInt
HERE IS MY INVITATION currentInt
GET UP 1
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED

LISTEN TO ME VERY CAREFULLY modulo
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE dividend
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE divisor
GIVE THESE PEOPLE AIR
HEY CHRISTMAS TREE quotient
YOU SET US UP 0
HEY CHRISTMAS TREE remainder
YOU SET US UP 0
HEY CHRISTMAS TREE product
YOU SET US UP 0
GET TO THE CHOPPER quotient
HERE IS MY INVITATION dividend
HE HAD TO SPLIT divisor
ENOUGH TALK
GET TO THE CHOPPER product
HERE IS MY INVITATION divisor
YOU'RE FIRED quotient
ENOUGH TALK
GET TO THE CHOPPER remainder
HERE IS MY INVITATION dividend
GET DOWN product
ENOUGH TALK
I'LL BE BACK remainder
HASTA LA VISTA, BABY
>>
>>51855149
Also Joost confirmed for loving men that code with it.
>>
>>51855149
Also I'm just now realising that I called out Java after posting code that compiles to Java Byte Code. Reee gGEOTENJAEWFM<
>>
>>51855215
>>51855179
>>51855149
Samefag
>>
I'm sure this is fucking awful. I know it can be done in one line, but I don't fully understand how that works yet.
for i in range(100):
if i % 3 == 0 and i % 5 == 0: print "FizzBuzz"
elif i % 3 == 0: print "Fizz"
elif i % 5 == 0: print "Buzz"
else: print i
>>
>>51855250
>calling out samefag on yourself.
>>
>use java to write fizz buzz
>don't even bother to make it oo for the hell of it.
You could have at least used the strategy pattern for no reason.
>>
>>51855260
I mean its Python but yeah not bad my friend. >>51855268
Post yours faggot
>>
>>51852750
>4 conditional statements evaluated each iteration

lmao
>>
>>51855286
To be honest family, Python is the only language I've touched, and I'm only just getting started with that. So far I've done Codecademy's course, made a simple Blackjack game, touched on sqlite a bit, and currently I have an assignment to scrape an online store website for products and dump them in an sqlite database along with prices, names, and links to the products.
Figuring out how to filter out all the junk data is proving to be a little more difficult than I thought it would be.
>>
>>51855310
People keep calling OP out and then not posting their own.
OP used way less conditional operators than me>>51855149
>>
>>51855325
I started out with Python and know a few languages now. Its a real nice starter one cause it eases you into everything. I went to Java > C then some random other kek languages after that. EG:>>51855149
>>
>>51855330
This is child's play programming, just pointing out that OP doesn't realize each conditional is going to be evaluated. Else/elseif is a friend.
>>
Can someone help me with my FizzBuzz code? I'm just learning to program (with Python), but it doesn't seem to be working??

def checkFive(n):
valueToReturn = False
i = 0
while i <= 2147483647:
if i == n:
valueToReturn = True
i += 5
return valueToReturn
def checkThree(n):
valueToReturn
i = 0
while i <= 2147483647:
if i == n:
valueToReturn = True
i += 3
return valueToReturn
def FizzBuzz(max):
for i in xrange(max):
if checkThree(i) == True:
print "Fizz"
if checkFive(i) == True:
print "Buzz"
if checkThree(i) == True and checkFive(i) == True:
print "FizzBuzz"
if checkThree(i) == False and checkFive(i) == False:
print i
>>
File: 1421848019318.webm (999 KB, 1020x800) Image search: [Google]
1421848019318.webm
999 KB, 1020x800
>>
>>51855364
Pretty bad way of pointing it out don't ya think?
>>
>>51855386
No. But now I think you're a nitpick faggot.
>statements evaluated
Pretty obvious what that means
>>
>>51852750
What is it supposed to do?
>>
>>51855425
Not to someone who is new to it.
Thread replies: 25
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.