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

>"99% of /g/ cannot fizzbuzz. You're not one of

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 316
Thread images: 29

File: 1487132340091.gif (2MB, 245x373px) Image search: [Google]
1487132340091.gif
2MB, 245x373px
>"99% of /g/ cannot fizzbuzz. You're not one of them, right anon?"
>>
>>59327915
BRAAAAAAAAAAAAAAAAAAAP
>>
if(true){
return;
}
>>
if num == 10 { urmom
>>
I can fizzbuzz:
interface FizzBuzzable {
public int value();
public String doFizzBuzz();
}
final class FizzBuzzableNumber implements FizzBuzzable {
private final int num;
public FizzBuzzableNumber(int n) { this.num = n; }
public final int value() { return this.num; }
public final String doFizzBuzz() { return new Integer(this.num).toString(); }
}
abstract class DivisibleNumber implements FizzBuzzable {
protected final FizzBuzzable original;
public DivisibleNumber(FizzBuzzable origin) { this.original = origin; }
public final int value() { return this.original.value(); }
public final String doFizzBuzz() {
String fizzBuzzed;
if (this.isDivisible())
fizzBuzzed = this.fizzBuzzing();
else
fizzBuzzed = this.original.doFizzBuzz();
return fizzBuzzed;
}
protected abstract boolean isDivisible();
protected abstract String fizzBuzzing();
}
final class NumberDivisibleByThree extends DivisibleNumber {
public NumberDivisibleByThree(FizzBuzzable origin) { super(origin); }
protected final String fizzBuzzing() { return "Fizz"; }
protected final boolean isDivisible() { return ((this.value() % 3) == 0); }
}
final class NumberDivisibleByFive extends DivisibleNumber {
public NumberDivisibleByFive(FizzBuzzable origin) { super(origin); }
protected final String fizzBuzzing() { return "Buzz"; }
protected final boolean isDivisible() { return ((this.value() % 5) == 0); }
}
final class NumberDivisibleByThreeAndFive extends DivisibleNumber {
public NumberDivisibleByThreeAndFive (FizzBuzzable origin) { super(origin); }
protected final String fizzBuzzing() { return "Fizz Buzz"; }
protected final boolean isDivisible() { return ((this.value() % 15) == 0); }
}

public class Main {
public static void main(String[] args) {
for (int i = 1; i <= 100; ++i) {
System.out.print(new NumberDivisibleByThreeAndFive(new NumberDivisibleByFive(new NumberDivisibleByThree(new FizzBuzzableNumber(i)))).doFizzBuzz());
if (i < 100) System.out.print(", ");
}
}
}
>>
Throw new OpIsAFagException(500);
>>
File: 1431434986158.png (750KB, 854x853px) Image search: [Google]
1431434986158.png
750KB, 854x853px
https://css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
>>
>>59327915
post the other half of that gif where he shows his girl cock
>>
File: 1486183555504.png (393KB, 730x916px) Image search: [Google]
1486183555504.png
393KB, 730x916px
>>59327915
is it strange that i've never did fizzbuzz? actually, where i study people won't even know about it, probably.
>>
File: FizzBuzzed.png (391KB, 1848x2018px) Image search: [Google]
FizzBuzzed.png
391KB, 1848x2018px
>>59328037
>>
>>59327980
>Enterprise fizzbuzz
>>
>>59327915
i fizzbuzz in assembler
eat that bitches
>>
for num in xrange(1,101):
if num % 5 == 0 and num % 3 == 0:
print "FizzBuzz"
elif num % 3 == 0:
print "Fizz"
elif num % 5 == 0:
print "Buzz"
else:
print num
>>
File: 1474222345815.jpg (73KB, 332x333px) Image search: [Google]
1474222345815.jpg
73KB, 332x333px
>>59327980

>Enterprise grade

This is the kind of shit I deal with every day at work, but in C#/.Net
>>
#include <iostream.h>

public static void main {}
{
cout <"Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz
Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz
Fizz
Buzz
Fizz
Buzz
Fizz
FizzBuzz
Buzz
Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz
Fizz
Fizz
Fizz
Buzz
Fizz
FizzBuzz
Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz
Fizz
Buzz
Fizz
Fizz
Buzz">
}
>>
Why do Fizzbuzz when you can take it a step higher and do Flozzblazz?
>>
>>59327980
You're doing Java/C# just right anon, gg
>>
File: 1323488149757.jpg (31KB, 650x452px) Image search: [Google]
1323488149757.jpg
31KB, 650x452px
>>59328233
>he doesn't fozzlebozz
>>
File: 1489126738794-1160620971.jpg (2MB, 4608x3456px) Image search: [Google]
1489126738794-1160620971.jpg
2MB, 4608x3456px
I'm at the rugby you fuckstick. Too busy for that shit.
>>
>>59327915
_.range(1, 6gorilions)
.forEach(num => {
if (num % 15 == 0) { return console.log('FizzBuzz'); }
if (num % 5 == 0) { return console.log('Buzz'); }
if (num % 3 == 0) { return console.log('Fizz'); }
else return console.log(num);
}
>>
>>59328232
klassik
>>
>>59329299
console.log has no return value, you tool
and if you have return statements inside a conditional, using 'else' is pointless
>:(
>>
>>59329299
Nigga just do:
var out='';
for (var num=1; num<=6gorillions; num++) {
num%3 || (out+='Fizz ');
num%5 || (out+='Buzz ');
!(num%3 && num%5) || (out+=(num+' '));
}
console.log(out);
>>
>>59327915
Stop shitposting with clips from porn of solo shemales. Do something productive with your fucking time.
>>
org 0x100
use16
xor cx, cx
xor ax, ax
aa: push ax
mov bp, sp
push 0x0024
push 0x0a0d
test cl, cl
jnz @f
mov cl, 0x05
push 0x7a7a
push 0x7542
@@: test ch, ch
jnz @f
mov ch, 0x03
push 0x7a7a
push 0x6946
@@: sub cx, 0x0101
pop dx
push dx
cmp dl, 0x0d
jne @f
xchg al, ah
or ax, 0x3030
push ax
@@: mov ah, 0x09
mov dx, sp
int 0x21
mov sp, bp
pop ax
inc ax
AAA;!!!
cmp ah, 0x0a
jne aa
ret

70 bytes.
>>
FizzBuzz without the modulo operator. Even if you have never used or even seen the modulo operator in your life, you still have no excuse to be unable to solve this. The only knowledge you need to be able to solve this is basic concepts of iteration, if statements, and variable assignment.

#include <stdio.h>

int main(void)
{
// rem3 and rem5 store the remainder when
// i is divisible by 3 and 5 respectively
int rem3 = 1, rem5 = 1;
for (int i = 1; i <= 100; i++) {
int print_num = 1;

// If i divisible by 3, print Fizz
if (rem3 == 0) {
printf("Fizz");
print_num = 0;
}
// If i divisible by 5, print Buzz
if (rem5 == 0) {
printf("Buzz");
print_num = 0;
}
// If neither of the above were executed, print the number
if (print_num != 0) {
printf("%d", i);
}

// Print newline regardless
printf("\n");

// Increment both remainders.
// Reset to 0 when they equal the divisor.
rem3++;
if (rem3 == 3) {
rem3 = 0;
}

rem5++;
if (rem5 == 5) {
rem5 = 0;
}
}
}
>>
Array.from(Array(100)).map((_,idx) => idx + 1).map(num => {
if (num % 3 && num % 5) return num
var result = "";
if (!(num % 3)) result += "Fizz"
if(!(num % 5)) result += "buzz"
return result;
});
>>
for (i=1;i<=100;i++){console.log(i%5==0 ? i%3==0?"FizzBuzz":"Buzz" : i%3==0?"Fizz":i)}
>>
>>59328086
>timecode string to seconds
Microwave time to seconds?
>>
(map (lambda (x)
(cond ((= (modulo x 3) 0) 'fizz)
((= (modulo x 5) 0) 'buzz)
((= (modulo x 15) 0) 'fizzbuzz)
(else x)))
(iota 100 1))
>>
>>59328165
>if num % 5 == 0 and num % 3 == 0:
instead of
>if num % 15 == 0:

Sorry, you didn't get the job.
>>
>>59329671
I never thought about how to solve it assuming I didn't know what modulo was, but this was nice and clean. Good job.
>>
>>59327980
Wow this is some enterprise certified fizzbuzzing
>>
 test plox 
>>
def FizzBuzz(number)
i = 0
1.upto(number) do
if i % 5 == 0 and i % 3 == 0 then
puts("FizzBuzz")
elsif i % 5 == 0 then
puts("Buzz")
elsif i % 3 == 0 then
puts("Fizz")
else
puts(i)
end
i += 1
end
end

FizzBuzz(100)


How did I do fa/g/s?
>>
>>59327915
I haven't tried so I probably cant yet. But I'm sure it can't be too hard
>>
>>59329841
Refer to:
>>59329761
>>59329761
>>59329761
>>
>>59329723
>>59328086
Can someone explain how to do the time in string one?

Would you cast it to int to start
>>
>>59329855
>implying their dicks won't explode when they see my github anyway.
>>
>>59329723
function timeToSeconds(time){
time = time.split(":").map(item => Number(item));
var seconds = time.pop();
if (time.length){
return seconds += time.reduce((a,b) => {
b += a * 60;
return b;
}) * 60;
} else {
return seconds;
}
}
>>
>>59329889
You believe that after they see that you don't understand basic mathematical concepts like LCM/GCF that they're going to hire you?

LUL
>>
>>59329910
>mad NEET
>>
>>59329883
This is javascript:
>>59329905
I don't know much about anything other than Js or Python, but if you're able to split , then map then that would be the ideal way of casting them to integers.
>>
>>59329749
>'15' branch will never be taken
As expected, Lisp-fags can't program anything more complex than factorial.
>>
>>59329924
>calling someone a NEET to defend against your ignorance

Good job, kiddo.
>>
>>59329905
lol Just realized I could've done

return time.split(":").map(item => Number(item)).reduce((a,b) => {
b += a * 60;
return b;
});
>>
>always thought fizbuzzing was going to be some horrific buzzword laden big-o google recruitment shit
>its literally just lambda and modulo

wew... am I one of the good ones then?
>>
>>59329982
No, it's extremely simple. The goal is to be able to do it with speed and beautifully - without remembering.
>>
watch this fucc
d=(a,b)=>{
while (a)if((a=(le=>((f=>f(f))(f=>(le((...x)=>f(f)(...x))))))
(ad=>(a,b)=>(b)?ad(a^b,(a&b)<<1):a)(a, -b))<0)return!a
return!a
}
console.log(new Array(100).fill().map((a,b)=>(d(b,3)?'Fizz':'')+(d(b,5)?'Buzz':'')||b))
>>
You are why professional coding is a shithole full of limpdick pegboard nerds.
>>
>>59329982
>literally just lambda

Nobody in this thread did it as a lambda. You don't know what that is, do you?
>>
>>59329855
>>59329761

Wouldn't it be more proper not to bury your magic numbers? In which case you can't use magic number 1 * magic number 2 unless both are prime.
#include <stdio.h>
#define FIZZ 3
#define BUZZ 5
#define LIMIT 100
int main()
{
for(int i=0; i<LIMIT; i++){
if (i%FIZZ == 0 && i%BUZZ == 0)
printf("fizzbuzz");
else if (i%FIZZ == 0)
printf("fizz");
else if (i%BUZZ == 0)
printf("buzz");
else
printf("%d", i);
}
return 0;
}
>>
>>59327925
SNIIIIIIIIIFFF
>>
>>59329249
Chea Rangi
>>
>>59330009
Damn nigga you have me beat. What the fuck is the le thing I've been seeing?
>>
>>59330034
>#define FIZZ 3

HAHAHAH HOLY SHIT YOU FUCKING WHAT

Is this a meme? Or do you unironically think that is an appropriate method of defining that variable?
>>
>>59330064
it's Y combinator in javascript
>>
>>59330034
you would get laughed out of an interview and spit on in a classroom for defining variables like that, please don't ever do that again
>>
>>59330067
It's what K&R suggest in their book when dealing with magic numbers
>>
>>59330034

int fizz = 3;

nigga what
>>
>>59329964
>not denying your NEEThood
>NEET confirmed


>gg kiddo
>>
>>59330081
That's awful. I unironically cringed.
>>
File: maxresdefault[1].jpg (82KB, 1920x1080px) Image search: [Google]
maxresdefault[1].jpg
82KB, 1920x1080px
>>59330077
Whaat
>>
module FizzBuzz where

fizzBuzz x = mapM_ print $map checkFizzBuzz [1..x]

checkFizzBuzz val
| val `mod` 15 == 0 = "FizzBuzz"
| val `mod` 3 == 0 = "Fizz"
| val `mod` 5 == 0 = "Buzz"
| otherwise = show val
>>
>>59327915
Notfizzbuzz = ' ';
Fizz = "fizz";
Buzz = "buzz";
Fizzbuzz = "fizzbuzz";
For i < 100; I++;
If 1 print notfizzbuzz
If 2 print notfizzbuzz
If 3 print buzz
If 15 print fizzbuzz

Fuck anon it's pretty easy get over yourself.
>>
>>59330108
Why, is K&R really that out of date and no longer useful?
>>
>>59330136
You should certainly not be defining variables like that for any purpose. There's never a good reason in any program to do it that way. I mean, of course that's just an opinion and there's never a right way to do programming, but it's industry standard to NOT define vars in that manner.
>>
>>59330091
>>59330079
>>59330067
>>59330067
[spoiler]Defines are not variables. What he does is right.[/spoiler]
>>
>>59327915
ok so from reading the replies it seems it's a guy but jokes on you i wasn't even aroused. i was about to comment something like "imagine being an average girl who doesn't even lift or anything and all you have to do is pull down your pants to get (You)s"
>>
>>59329910
>you need math to code
You would get shit for writing a non-expandable pile of crap full of magic numbers but not for math-related issues.
>>
>>59330034
Since you're replying to him I'd think you'd do
```
if (i % FIZZ * BUZZ === 0)
```
>>
>>59327915
>python
for num in xrange(1,101):
msg = ''
if num % 3 == 0:
msg += 'Fizz'
if num % 5 == 0:
msg += 'Buzz'
print msg or num
>>
>>59330157
>not being aroused by the obvious trap
>still angry enough to whine about OPs (You)'s
>>
>>59330150
I know that at least the Solarized developers use it.
The .Xresources file they ship with has a bunch of #define for the various colors. Which is a shame because GNOME for example ends up doing xrdb --nocpp ~/.Xresources
>>
>>59330179
tiny mode i like it
>>
>>59330154
You're right, they're not variables. Variables are what he should've been using, though, as there is LITERALLY no reason or excuse for using defines. In fact, variables aren't even necessary as the cleanest way to go about this basic problem is close to how
>>59329841
did it.
>>
>>59330034
>you can't use magic number 1 * magic number 2 unless both are prime.
They only have coprime.
>>
>>59330171
Only works if FIZZ and BUZZ do not share a common prime factor
Let FIZZ = 4, BUZZ = 6
Your code will miss 12
>>
>>59330198
>the cleanest way to go about this basic problem is
Magic numbers are anything but "clean"
>>
>>59327915

modulus and three if statements right?
>>
>>59330150
>>59330191
I should also add that I decided to look at some random code from the Linux kernel, they use #define in the first code I see.
Maybe it is something to do with C.
>>
javafag here:

import static java.lang.System.out;
public class denn {

public static void main( String [] args){

for (int i= 0; i<100; i++){
if(i % 3 == 0 && i % 5 == 0){
out.println("fizzbuzz " + i);
}else if(i % 5 == 0){
out.println("buzz " + i);
}else if(i % 3 == 0){
out.println("fizz " + i);
}else if(i % 3 != 0 || i % 5 != 0){
out.println(i);
}
}
}
}



>inb4 that unnecessary import ;)
>>
>>59328232
what the fuck is this language? looks like an C++ and C# fucked but then C# aborted. however, C++ took the aborted fetus and presented as a functioning language
>>
>>59330286
just forget to adding "<=" to the for loop sorry ;)
>>
>>59329636
>AAA;!!!
AAAAAAA!!!!!!
>>
File: 1487636881507.jpg (272KB, 1200x675px) Image search: [Google]
1487636881507.jpg
272KB, 1200x675px
>>59327915
>>
>>59330179
Why did you copy me?
n = 1
while n < 101:
out = ''
if not n % 3:
out = 'Fizz'
if not n % 5:
out += 'Buzz'
if out == '':
print(n)
else:
print(out)
n += 1

Mine is better because for loops are inferior to while loops.
>>
>>59330232
There's no magic numbers?
>>
>>59330471
His is clearly better.
>>
>>59330530
Five is a magic number. Three is a magic number.
Not encapsulating your conditions is generally a bad idea.
Given ruby has a proper "for" loop over ranges, using it instead of manually incrementing a variable would be a more readable solution.

If someone's told to make this FizzBuzz react to different numbers - they'll have to edit the algorithm directly. If they'll need to add a third number - they'll have to alter it altogether.

Code should be written in a way someone who has no fucking idea what's it all about can properly read it.
>>
>>59330618
>python 2
>>
>>59330684
So you're going to write code that handles any number of numbers and messages?
Keep it simple stupid.
>>
>>59329761
>three division ops
>not two and a comparison

I'm sorry, we're looking for someone else.
>>
>>59330738
>implying the compiler doesn't do this for you
>>
['Fizz'*(not i%3) + 'Buzz'*(not i%5) or i for i in range(1, 100)]
>>
>>59330738
the compiler does it for you. you're a fucking jackass for writing unreadable code for no reason
>>
>>59330814
>the compiler does it for you
well not the i % 15 part but i mean not explicitly storing the m3 and m5 variables
>>
>>59327915
that girl has almost no ass, it's all angle.
>>
>>59330827
it's a trap, and yeah it's a totally uninteresting ass, it's a weak bait, yet it's the best the trapfag trolls can come up with
>>
>>59330684
>Code should be written in a way someone who has no fucking idea what's it all about can properly read it.
This is bullshit. Why should you dumb down instead of expecting the reader to smarten up? What if you're implementing formulas or algorithms and someone who reads it has no idea of the math involved? Granted, comments would suffice to explain, but it applies to, say, cryptography, where if you don't understand you should just stay away instead of whining about "readability". At a certain point, it's completely arbitrary what is or isn't readable; like verbose prose in a novel, some people just can't read it, but it doesn't make it "unreadable".
>>
>2012
>modulo operations
fizzBuzz = zipWith emp [1..100] $ concat . repeat $ ["", "", "Fizz", "", "Buzz"] ++ replicate 9 "" ++ ["FizzBuzz"] where
emp x [] = show x
emp _ s = s
>>
I am. I specialize in Chemistry little code monkey.
>>
>>59330812
Neat. Why does str*False return an empty string? Is this Python? It should be range(1, 101) then
>>
>>59327915

GET THIS SMUT OFF MY SFW BOARD REEEE SAGED
>>
>>59327915
More like 99% of /g/ doesn't know more programming than fizzbuzz.
>>
>>59330914
In Python bool is subclass of int and multiplying string by int repeats it.
>>
>>59330337
always scream when doing bcd arithmetic.
>>
>>59330794
Except it doesn't. The person I was replying to suggested "num % 15" which will generate a separate set of operations in addition to the %5 and %3.

The typical sample that repeats %5 and %3 MAY or MAY NOT result in the compiler storing the result for you. Depends on platform and compiler.

>>59330814
>"unreadable code"
Fuck off back to India Pajeet, and take your poo with you.
>>
>>59330930
yeah i've been programming for 3 years and i'd say i'm pretty good but most people on /g/ and most people in general are quite shit at programming
>>
>>59331032
It could also be that it is hard to show programming on /g/, especially larger projects.
>>
>>59331049
true
>>
like there's a lot of newfags who are still in school but there's probably a bunch of seasoned programmers here as well
>>
>>59330997
I see, you're actually multiplying by either int 0 or 1.
>>
>>59330684
KISS
>>
Is it possible to fuzzbuzz in c++ with only for loops and if else ? Honest question
>>
>>59331177

#include <iostream>
#include <sstream>

int main()
{
for (int i = 1; i <= 100; ++i)
{
std::stringstream s { };
if (i % 3 == 0) s << "Fizz";
if (i % 5 == 0) s << "Buzz";
if (s.peek() == EOF) s << i;
std::cout << s.str() << std::endl;
}
}
>>
>>59331178
Iam not understanding the purpose of s.peak line and stream in general why not just write else cout<<" fizzbuzz" in the end if it is not multiple of niether numbers ?
>>
>>59330705
Ideally - yes.
>>59330846
This is common sense. If you are implementing basically any formulas or algorithms you should encapsulate them into readable methods/functions - not leave their bare bones in your code.
Even a math genius will have to spend his time decoding what the fuck your great algorithm tries to achieve and why is it there in the first place, meanwhile even a math-illiterate person will understand what's going on were you to encapsulate it into a properly named method.
>>59331150
"Simple" is relative. Having proper encapsulation makes your final code "simple".

You, guys, shouldn't be learning how to write FizzBuzz for 3 and 5. You should learn how to write programs you and other people will end up supporting over a long time.
>>
>>59327915
Sauce or gtfo
>>
>>59331178
Please tell me the answer to
>>59331209
I am not baiting, i have come into this field now i am really afraid of my future,
Should have just gone to civil engineering
>>
>arguing over fizzbuzz

Can we get a new coding quiz? I suggest something we can call PooLoo.
>>
>>59331267
(s.peek() == EOF) returns true when the stringstream is empty, to avoid checking the case where (i % 3 == 0 && i % 5 == 0)
>>
>>59331209
Because this way he only has three separate ifs as opposed to if, else if, else if, else nested one into another.
Appending the string makes adding another multiplier a much easier task, which is good.

However, checking for the end of file is completely counterintuitive, thus - stupid.
>>
>>59331209
>Iam not understanding the purpose of s.peak line
I'm guessing s.peek lets him get the last character in the stream without changing the offset in the stream.

If it's EOF then neither Fizz nor Buzz (nor FizzBuzz) was printed, and he has to print the number. A clever if obscure way to determine whether or not to print the number.
>>
>current year
>not recursive fizzbuzzing

const
s=(a,b)=>(b)?s(a^b,(a&b)<<1):a,
f=a=>(++a>100)?process.exit(0):(console.log(((d(a,3)?'Fizz':'')+(d(a,5)?'Buzz':'')||a)),f(a)),
d=(a,b)=>{
while (a)if((a=s(a, -b))<0)
return!a
return!a
}
f(!f)
>>
>>59331317
>current year
>not using code tags
>>
So after preaching the virtues of Rust on this board without having tried it, I sat down and tried to write a Fizzbuzz in rust. I failed.

Why the fuck would you want to create a language where string literals and strings have different types? That defeats the entire point of string literals.
>>
>>59331289
Ohhhh thanks man you just gave me knowledge a lot
>>
>>59331322
>he can't read plaintext code
>he needs colors and highlights for his autism
>>
look mom, no %
int mod(unsigned char a, unsigned char b){
int division = 0;
int rest = a;
int shifted_b = b;
for(int i = 8; i >= 0; --i){
shifted_b = b << i;
if(rest >= shifted_b && shifted_b > 0){
rest -= shifted_b;
division += 1 << i;
}
}
return rest;
}

void fizzbuzz(int max, size_t f=3, size_t b=5){
for(int i = 1; i <= max; ++i){
std::string p;
if(!mod(i,f)){
p += "fizz";
}
if(!mod(i,b)){
p += "buzz";
}
if(p.empty()){
p = std::to_string(i);
}
std::cout << p << std::endl;
}
}
>>
>>59331231
>Ideally - yes.
Why? You're wasting time and adding complexity for imagined use case that will probably never happen.
If it does happen just add it then.
>meanwhile even a math-illiterate person will understand what's going on were you to encapsulate it into a properly named method.
No they won't. Regardless this is why you'd have a description of algorithm in addition to code. For example
https://github.com/gramoli/synchrobench/blob/master/java/src/trees/lockbased/LockBasedFriendlyTreeMap.java
https://sydney.edu.au/engineering/it/~gramoli/doc/pubs/EuroPar2013.pdf

>You, guys, shouldn't be learning how to write FizzBuzz for 3 and 5. You should learn how to write programs you and other people will end up supporting over a long time.
It's a sanity check to see if someone lied on resume.
>>
>>59331289
It's actually to avoid checking when the number should be printed. Case case where (i % 3 == 0 && i % 5 == 0) is handled in his code because his if's are not "if/else". Both ifs can succeed resulting in FizzBuzz.

>>59331298
>However, checking for the end of file is completely counterintuitive, thus - stupid.
It's not stupid. If it wasn't there it would print the number after every Fizz, Buzz, and FizzBuzz, and he wouldn't get hired.
>>
>>59331322
Sorry fwiend

const 
s=(a,b)=>(b)?s(a^b,(a&b)<<1):a,
f=a=>(++a>100)?process.exit(0):(console.log(((d(a,3)?'Fizz':'')+(d(a,5)?'Buzz':'')||a)),f(a)),
d=(a,b)=>{
while (a)if((a=s(a, -b))<0)
return!a
return!a
}
f(!f)
>>
00000000  31 c9 31 c0 50 89 e5 6a  24 68 0d 0a 84 c9 75 08  |1.1.P..j$h....u.|
00000010 b1 05 68 7a 7a 68 42 75 84 ed 75 08 b5 03 68 7a |..hzzhBu..u...hz|
00000020 7a 68 46 69 81 e9 01 01 5a 52 80 fa 0d 75 06 86 |zhFi....ZR...u..|
00000030 c4 0d 30 30 50 b4 09 89 e2 cd 21 89 ec 58 40 37 |..00P.....!..X@7|
00000040 80 fc 0a 75 bf c3 |...u..|
00000046
>>
>>59331341
It's not plain code. It's shit.
>>
>>59328086
so this is a girl, right?
>>
whoops
;TAKES AN INPUT 1-127 ON PORTB
processor 18f8722
config osc = hs, wdt = off, lvp = off

WREG EQU 0xFE8
FIZZ EQU 0xB
BUZZ EQU 0xC

MOVLW 0b11111000
MOVWF TRISA ;SET PINS 0-2 ON PORT A TO OUTPUT

MOVLW 0xFE
MOVWF TRISB ;SET PINS 0-6 ON PORT B TO INPUT

START:
MOVF PORTB,W ;MOVES VALUE ON PORT B INTO W
ANDLW 0b01111111;SCRUBS VALUE ON MSB PORT B
MOVWF 0xA;MOVES NUMBER TO TEST INTO A

CALL ISDIVBY3
CALL ISDIVBY5 ;DO THE FIZZBUZZ

MOVWF FIZZ;BRING FIZZ VALUE INTO WREG
SUBWF FIZZ,0;subtract fizz from buzz
BZ FB; IF RESULT IS ZERO THEN BOTH FIZZ AND BUZZ MUST BE TRUE SO FIZZBUZZ
BN F;IF RESULT IS NEGATIVE THEN FIZZ IS TRUE BUT BUZZ IS NOT (IE IF BUZZ IS 0 AND FIZZ IS 1 THEN RESULT OF BUZZ-FIZZ = -1)
BNN B;IF RESULT IS POSITIVE THEN IT MUST BE BUZZ
BRA START ;SOMETHING HAS GONE HORRIBLY WRONG, DO NOT OUTPUT AND TRY AGAIN
F:
MOVLW 0b1
MOVWF LATA;IF FIZZ
BRA START

B:
MOVLW 0b10
MOVWF LATA;IF BUZZ
BRA START
FB:
MOVWF 0b100
MOVWF LATA;IF FIZZBUZZ
BRA START



ISDIVBY3 ; CHECK IF NUMBER IF DIVISBLE BY 3


MOVF 0xA,0;move A into WREG
divtest3:

NEGF WREG;negate wreg
ADDLW 0d3;add 3 to wreg
BNN isnotdiv3;if wreg is now +ve, we have crossed 0 and number is not divisble by 3
BZ isdiv3;if wreg is now zero, number is divisle by 3
BN divtest3;if wreg is still -ve, still need to keep subtracting

isdiv3:
MOVLW 0b1;move true into wreg
MOVWF FIZZ;SET fizz to true

isnotdiv3:

MOVLW 0b0;move true into wreg
MOVWF FIZZ;SET fizz to true

RETURN

ISDIVBY5 ; CHECK IF NUMBER IF DIVISBLE BY 5


MOVF 0xA,0;move A into WREG
divtest5:

NEGF WREG;negate wreg
ADDLW 0d5;add 3 to wreg
BNN isnotdiv5;if wreg is now +ve, we have crossed 0 and number is not divisble by 3
BZ isdiv5;if wreg is now zero, number is divisle by 3
BN divtest5;if wreg is still -ve, still need to keep subtracting

isdiv5:
MOVLW 0b1;move true into wreg
MOVWF FIZZ;SET fizz to true

isnotdiv5:

MOVLW 0b0;move true into wreg
MOVWF FIZZ;SET fizz to true

RETURN
>>
>>59331381
It's a retard.
>>
>>59331355
>It's not stupid.
It's stupid. I ain't saying it doesn't work - I'm saying it's counterintuitive. As in "you need to go and see how the algorithm itself works to understand why is it there."
It makes sense for the possible expandability, but it should be shoved into a method in this case.
>>59331352
>You're wasting time and adding complexity for imagined use case that will probably never happen.
We started from talking about "clean code" in general - not FizzBuzz in particular. Not to mention, proper encapsulation won't make your code more complex - it'll make it much simpler.
>No they won't.
Do you even fucking know what "encapsulation" means? It means hiding all of your algorithm inside a method so all of that diabolic shit ends up being "map.doMaintenance()" resulting in a person who reads the code to say "Oh, I get it, it does maintenance!" If you have algorithm inside algorithms (aka "how exactly it does the maintenance") - you encapsulate them as well, so whoever had the misfortune of debugging your shitty code won't have to see all of it - only the necessary parts.

>It's a sanity check to see if someone lied on resume.
That's why I'm saying it isn't something you should be wasting your time on learning. Learn to code properly instead. No one will ask you to write a FizzBuzz in the least lines possible - unless they are idiots.
>>
My final submission
Array(100).fill().map((_,idx) => {
var num = ++idx;
var result = "";
if (!(num % 3)) result += "Fizz";
if (!(num % 5)) result += "Buzz";
return result || num;
}).join(" ");


Honestly, thanks to the people ITT this is the first time in a long time that I've learned multiple new things in a day.
>>
>>59331463
Ah shit, forgot to make the isdivby5 function buzz
>>
>>59331477
girls and retards aren't mutually exclusive
>>
This thread makes me anxious.
>>
>>59331485
Why do "magic numbers" matter if I'm just going to encapsulate it into a method call for knuckle draggers?
>Do you even fucking know what "encapsulation" means?
You can't encapsulate a tree more than add and remove and get.
If they don't understand the algorithm even a little they won't understand the performance in different situations.
>That's why I'm saying it isn't something you should be wasting your time on learning
Nobody has to learn fizz buzz, you should just know how to do it. I assume this threads are tongue in cheek.
>>
>>59331596
they're not tongue in cheek because it's a test that is genuinely used and that countless people genuinely fail despite having genuine degrees in the field
>>
>>59331615
>countless people genuinely fail despite having genuine degrees in the field
I can't believe this.
>>
>>59327915
what do her farts smell like?
>>
>>59331325
Update: got it to work.

fn fbstring (i : i64)-> std::string::String {
match (i%3,i%5) {
(0,0) => "FizzBuzz".to_string(),
(0,_) => "Fizz".to_string(),
(_,0) => "Buzz".to_string(),
_ => i.to_string()
}
}

fn main () {
for i in 0..20 {
println!("{}", fbstring(i))
}
}
>>
>>59331627
did you interact with other students while completing your degree?
>>
>>59331627
https://blog.codinghorror.com/why-cant-programmers-program/
>>
File: 1483501565792.gif (2MB, 500x400px) Image search: [Google]
1483501565792.gif
2MB, 500x400px
>>59331660
Yes but I went to a "good" school.
How can someone pass cs 101 let alone earn a degree without understanding basic loops and conditionals?

>>59331675
How??? Who are these people?
>>
>>59331697
1. go to a school where the final exams are less like 80% and more like 50%
2. pay someone to do all your assignments
3. comb through the class content for the stuff that's pure memorization and memorize it to pass the exam
4. receive degree
>>
>>59331697
Women and shitskins are given a pass at Universities even if they fail.
>>
>>59330738
>putting fizz, buzz and fizzbuzz separately insead of just fizz and buzz
Anon, we well sure call you back
>>
>>59327915
I'm not a code monkey. I can just hire one if I need one.
>>
Python:

def fizzbuzz(i):
if 0,0 == i%3,i%5:
return "FizzBuzz"
elif 0 == i%3:
return "Fizz"
elif 0 == i%5:
return "Buzz"
else:
return str(i)

def printseq(f,n):
for i in range(0,n):
print(f(i))


usage:

printseq(fizzbuzz,20)
>>
>>59330150
but it's a constant, not a variable
>>
>>59331820
Alternatively:

def fizzbuzz(n):
def fb(i):
if 0,0 == i%3,i%5:
return "FizzBuzz"
elif 0 == i%3:
return "Fizz"
elif 0 == i%5:
return "Buzz"
else:
return str(i)

for i in range(0,n):
print(fb(i))


Tbh it's utterly stupid that Python's if statement are not expression. It would be a lot more natural if I could write
def fizzbuzz(n):
for i in range(0,n):
print(
if 0,0 == i%3,i%5:
"FizzBuzz"
elif 0 == i%3:
"Fizz"
elif 0 == i%5:
"Buzz"
else:
str(i)
)


But Python decided to have a separate if and ternary operator, with an utterly stupid syntax for the ternary that makes it annoying to chain.
>>
>>59331900
That looks like ass.
>>
File: aaahh!-real-monsters-t.jpg (100KB, 400x258px) Image search: [Google]
aaahh!-real-monsters-t.jpg
100KB, 400x258px
>>59330337
>AAAAAAA!!!!!!
REAL MONSTERS
>>
>>59331697
I have interviewed someone who has 5 years of experience as a "coder", who could not display the 12x12 table.

And they also failed simpler-than-FizzBuzz: "Count down from 700 to 200, in decrements of 13".

To save time, I now filter candidates with a simpler question on the phone: "In your programming language of choice, count from 1-100. For each number, say whether it is odd or even." The majority of candidates fail this.
>>
>>59331961
What kind of company is this?
>>
>>59331974
I just want to hire a simple front-end web dev. Someone, anyone, who can work with HTML, CSS, and JS. That is all. Not looking for another Carmack, not looking for 180 IQ and 50 years of experience with Windows 10, not looking for someone who has won 20 web design awards. Just a simple web dev.

Been looking for a year now. Finding a competent developer is a Herculean task.
>>
>>59332017
well i can write a loop to count from 1 to 100 and state whether it is odd or even so hire me
>>
>>59330021
except they have, you big doofus
>>
>>59332033
I cannot afford to pay the government enough to get the license to hire foreigners, so if you are a Malaysian (or if you have PR here), I will accept your resume. We will be hiring in April.

We will be TRYING to hire in April. I expect another 100 resumes of people who cannot FizzBuzz.
>>
File: haskell-logo.jpg (25KB, 431x172px) Image search: [Google]
haskell-logo.jpg
25KB, 431x172px
>>59327915
make way for a real language faggots

main =  mapM_ putStrLn $ fizzBuzz <$> [1..100]
where fizzBuzz n
| mod n 15 == 0 = "FizzBuzz"
| mod n 5 == 0 = "Buzz"
| mod n 3 == 0 = "Fizz"
| otherwise = show n
>>
>>59328232
well thats wrong you retard
>>
>>59327915
Is this lady's butt talking to me?
>>
>>59330337
http://uncyclopedia.wikia.com/wiki/AAAAAAAAA!
>>
>>59332191 bad code
>>
hoho
>>
>>59331381
>omg math so hard, let's go JSing!
>when faced with failure, blame process, not one's own lack of knowledge

Gee, what do YOU think?
>>
File: wtf reaction dog.jpg (20KB, 480x451px) Image search: [Google]
wtf reaction dog.jpg
20KB, 480x451px
>>59330179
Beginner here, am I stupid if this is the only one I understand? It seems like the simplest, most elegant, and most straightforward solution. Almost everything else in this thread makes me go "what the fuck are these guys doing?"

I mean this problem is straightforward and requires a few operations and this python solution could not be simpler or easier to read. No bullshit special snowflake code tricks, no overbuilt nonsense, etc...

Can someone explain what is going on with the rest of these solutions?

>>59330286
Like this, wtf? Is this the power of Java?
>>
>>59328086
If I understand the second one correctly
>split input by delimiter ':' and throw em into an array
>return parse(array[0]) * 60 * 60 + parse(array[1]) * 60 + parse(array[2])
>place a nice big comment at the top //assumes HH:MM:SS input
Would an interview accept psudocode? I hate writing code outside of an IDE, not having syntax highlighting fires up my autism.
>>
>>59327915
that's a dude
>>
>>59332449
python strings are immutable, that solution as printing each string without the concatenation operator, and is actually microscopically more confusing because it requires you to look at two places to see what's printed for each option

the most complex ones are intentionally made more complex

java has always been overly verbose
>>
>>59332580
calling everything a man until proven otherwise is a sign of paranoia stemming from fear of your own homosexuality

it's a woman
>>
for i in xrange(1,101): print 'FizzBuzz'[(i%3>0)*4 : 4+4*(i%5<1)] or i
>>
>>59331255
jennatrapxxx
>>
>>59332611
no one said it was a bad thing
>>
>>59332611
>can't tell the difference between a man and a woman
lmao fag
>>
>>59327915
this is a blue board, dipshit
i.e. sfw
>>
>>59335883
Nothing NSFW about that image
>>
>>59335924
using System;

namespace Fizzbuzz
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Type how many numbers you want:");
int printCount = int.Parse(Console.ReadLine());
Console.Write("\n");

for (int i = 1; i <= printCount; i++)
{
string textToDisplay = $"{i} ";
if (i % 3 == 0)
{
textToDisplay += "fizz";
}
if (i % 5 == 0)
{
textToDisplay += "buzz";
}
Console.Write(textToDisplay += "\n");
}
Console.ReadKey();
}
}
}
>>
>>59332191
why not
mapM_ (putStrLn . fizzBuzz) [1..100]
>>
for i in range(1,101):
print("FizzBuzz"[i*i%3*4:8--i**4%5] or i)
>>
>>59331900
>elif after a return.
>>
>>59332191
See:
>>59330126

I didn't use where but it's still haskell.
>>
[1..100]
|> List.map (fun i ->
match (i % 3, i % 5) with
| 0,0 -> "FizzBuzz"
| 0,_ -> "Fizz"
| _,0 -> "Buzz"
| _ -> string i
>>
>>59327915
WHY THE FUCK has a picture of a bare butt been on /g/ homepage for 15 hours straight? Is there no moderation team here?
>>
>>59335952
you failed, you're not meant to print i if you print fizz/buzz/fizzbuzz
>>
>>59327915
Who are you quoting?
>>
Make way, hyperplebs.

x = 0
while (x < 100):
x += 1
if (x % 15 == 0):
print("fizzbuzz")
elsif (x % 5 == 0):
print("buzz")
elsif (x % 3 == 0):
print("fizz")
else:
print(x)
>>
>>59328037

Urgh, Math.
>>
#include <stdio.h>

int main(int argc, char* argv) {
int i = 0, f = 3, b = 5, p = 1;

for (i = 0; i <= 50; i++, --f, --b, p--) {
if (!f && --p) {
printf("fizz");
f = 3;
}
if (!b && --p) {
printf("buzz");
b = 5;
}
if ((!f | b) && p >= 0)
printf("%d", i);
printf("\n");
p = 1;
}

return 0;
}
>>
>>59331961
>>59332062
>I expect another 100 resumes of people who cannot FizzBuzz
What do these imbeciles have on their resume that allows them to get even a preliminary interview, while I can't even get a call back? Is it a fictitious cover letter?
>>
>>59336744
He's in Malaysia lol.
>>
>>59331961
This is bizarre to me. I don't consider myself to be the greatest coder but before an interview it just makes sense to go over stuff like this so you're at least decently prepared. Makes me wonder if people are this incompetent in interviews for other professions.
>>
say "Fizz"x!($_%3)."Fuzz"x!($_%5)||$_ for 1..100
>>
i can only do it in C and python.
>>
int main(void)
{
int i;
for(i = 1; i < 101; ++i) {
printf("%d\r", i);
if (i % 3 == 0) printf("Fizz");
if (i % 5 == 0) printf("Buzz");
printf("\n");
}
}
>>
>>59335179
Somebody break down the second half of this? I've seen python one liners before like it but I never quite understand all the arithmetic going on
>>
>>59331961
>"Count down from 700 to 200, in decrements of 13".

But the closest you can get is 206?
>>
>>59336563
Obviously the "girl", you fucking autist.
>>
>>59336968
'String'[n:m]
will return a string made up of the characters of the original string between n and m.

Let's say for example that i is 5.
(i%3>0)*4
= 4
4+4*(i%5<1)
= 8
So we end up with
'FizzBuzz'[4:8]
which is 'Buzz'
>>
>>59332191

main = mapM_ putStrLn fizzBuzz

fizzBuzz = zipWith (\a b -> if null b then show a else b) [1..100] $ zipWith (++) (cycle ["","","Fizz"]) (cycle ["","","","","Buzz"])
>>
<style>
@import "compass/css3";

ul{
list-style-type:none;
}
li:nth-child(3n), li:nth-child(5n){
font-size:0px;
}

li:nth-child(3n):before{
font-size:16px;
content:"Fizz";
}
li:nth-child(5n):after{
font-size:16px;
content:"Buzz";
}
</style>
<ul>
<li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li><li>21</li><li>22</li><li>23</li><li>24</li><li>25</li><li>26</li><li>27</li><li>28</li><li>29</li><li>30</li><li>31</li><li>32</li><li>33</li><li>34</li><li>35</li><li>36</li><li>37</li><li>38</li><li>39</li><li>40</li><li>41</li><li>42</li><li>43</li><li>44</li><li>45</li><li>46</li><li>47</li><li>48</li><li>49</li><li>50</li><li>51</li><li>52</li><li>53</li><li>54</li><li>55</li><li>56</li><li>57</li><li>58</li><li>59</li><li>60</li><li>61</li><li>62</li><li>63</li><li>64</li><li>65</li><li>66</li><li>67</li><li>68</li><li>69</li><li>70</li><li>71</li><li>72</li><li>73</li><li>74</li><li>75</li><li>76</li><li>77</li><li>78</li><li>79</li><li>80</li><li>81</li><li>82</li><li>83</li><li>84</li><li>85</li><li>86</li><li>87</li><li>88</li><li>89</li><li>90</li><li>91</li><li>92</li><li>93</li><li>94</li><li>95</li><li>96</li><li>97</li><li>98</li><li>99</li><li>100</li></ul>
>>
>>59327925
I don't get this meme, do you hate women so you want to kill them with a machine gun sound?
>>
>>59337749
That's a fart noise, doofus
>>
File: url.jpg (6KB, 334x151px) Image search: [Google]
url.jpg
6KB, 334x151px
>>59337823
uh, no. That's like an A10's machine gun
>>
>>59335899
Cool boss, HR, and CEO if they can walk by your desk and see a girls bare ass and not give a shit.
>>
>>59337897
>girls
>>
>>59337897
So your boss would be fine with you being on 4chan at work, but not not if there was an ass on it?

Protip: SFW doesn't literally mean it would be allowed at your place of work, it just refers to whether or not something is pornographic
>>
>>59337923
Actually, that might save me
>A naked girl! lawsuit! harassment!
actually, it's a trap boy, I'm gay
>sorry, here is money, we aren't bigots, don't sue us.
>>
>>59331485
>It's stupid. I ain't saying it doesn't work - I'm saying it's counterintuitive. As in "you need to go and see how the algorithm itself works to understand why is it there."

WTF? I got it on the first read. Maybe you need to spend some more time in school Sanjay.
>>
>>59327915
>fizzbuzz
stop this. it's basically Hello World tier. can't you just meme some interesting straightforward algorithm that leaves a lot of room for personalization, like the sieve of Eratosthenes?
>>
>>59337897
>HR
>CEO

If you're not working for yourself or a company with fewer than 10 people and reaping massive profits, I don't know what you're doing with your life.
>>
File: fucking-font.webm (320KB, 1138x640px) Image search: [Google]
fucking-font.webm
320KB, 1138x640px
>>59327915
is this good enuff?
>>
>>59336402
it's a male butt so it's ok
>>
(1 to 100).map(_ match {
case n if n % 15 == 0 => "Fizzbuzz"
case n if n % 5 == 0 => "Buzz"
case n if n % 3 == 0 => "Fizz"
case n => n
}).foreach(println _)
>>
>>59338135
I can dig it, p h a m
>>
>>59337823
Kill yourself, shit stain.
>>
>branching

#include <stdio.h>

int main()
{
int i;
const char *fizzy[] = {"FizzBuzz\n", "%d\n", "%d\n", "Fizz\n", "%d\n", "Buzz\n", "Fizz\n", "%d\n", "%d\n", "Fizz\n", "Buzz\n", "%d\n", "Fizz\n", "%d\n", "%d\n"};

for (i = 1; i <= 100; i++)
printf(fizzy[i % 15], i);
}
>>
File: 1484209406181.jpg (93KB, 1024x768px) Image search: [Google]
1484209406181.jpg
93KB, 1024x768px
>shit I don't care about because I'm a QA
>>
>>59338182
don't say that. don't ruin my erection.
>>
File: 1489008954468.jpg (138KB, 1247x810px) Image search: [Google]
1489008954468.jpg
138KB, 1247x810px
>>59330067
>define
>variable
Kill yourself, idiot.
>>
File: 2017-03-10-175027_1824x984_scrot.png (332KB, 1824x984px) Image search: [Google]
2017-03-10-175027_1824x984_scrot.png
332KB, 1824x984px
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main ()
{
int fb_range;
cout << "Fizzbuzz:> ";
cin >> fb_range;
for (int i = 1; i <= fb_range; i++) {
if (i % 3 == 0)
cout << "fizz";
if (i % 5 == 0)
cout << "buzz";
if (i % 3 and i % 5)
cout << i;
if (i != fb_range)
cout << ", ";
} cout << endl;
return 0;
}
>>
File: 1485115961983.jpg (47KB, 564x400px) Image search: [Google]
1485115961983.jpg
47KB, 564x400px
>>59330067
>sperging out this hard
It is absolutely appropriate (and correct) to use preprocessor definitions for magic numbers. They're not variables.
>>
File: 1450219827973.jpg (15KB, 220x255px) Image search: [Google]
1450219827973.jpg
15KB, 220x255px
>>59330198
>no reason or excuse for using defines
>>
File: images_0.jpg (7KB, 260x193px) Image search: [Google]
images_0.jpg
7KB, 260x193px
>>59338324
>>
>>59330051
Owo
>>
>>59330108
Sounds like you have downs. Kill yourself. Retard.
>>
File: 1478345665311.jpg (57KB, 500x440px) Image search: [Google]
1478345665311.jpg
57KB, 500x440px
>>59329723
Goddamnit this gets me everytime
>>
>>59338441
#include <stdio.h>

int main()
{
int i;
const char *fmts[] = {"%.0s%.0s%d\n", "%s%s\n"};

for (i = 1; i <= 100; i++)
printf(fmts[(i % 3 == 0 || i % 5 == 0)], "Fizz" + (4 * !!(i % 3)), "Buzz" + (4 * !!(i % 5)), i);
}
>>
>>59332562
Some interviews do. Generally they'll explicitly tell you "pseudocode is fine", but I've been expected to write it down before. For that type of problem, they ask you to "talk through it" which basically means lay out an algorithm and probably write some pseudocode.
>>
>>59332562
Just do python since it's simple and easy to write by hand.
>>
>>59327915
*teleports behind you*

foreach(1..100){print $_%15 ? $_%3?$_%5?"$_\n":"Buzz\n":"Fizz\n" : "FizzBuzz\n" ;}



pssh nothin personnel, kid
>>
>>59337897
Hi, office fag. Is pajeet heating up fish in the breakroom microwave?

t. never worked in office setting
>>
File: 17irs57ndbizjjpg.jpg (64KB, 800x470px) Image search: [Google]
17irs57ndbizjjpg.jpg
64KB, 800x470px
>>59329723
>>
>>59332062
Hire me, I'll work for free so you don't even need a license I just want experience to put on my resume so I can finally get a call back

I'm still a foreigner though
>>
>>59336566
Fucking using a while loop for a predetermined number of iterations

% 15 instead of % 3 && %5 making your code less self-documenting and harder to read>>59337721

>>59337721
Just use javascript to generate that table instead of typing it out
>>
OK

using System;
using System.Collections.Generic;

namespace FizzBuzz{
class Program {
static void Main() {
List<string> fb = new List<string>;
fb.add("fizz");
fb.add("buzz");

Random r = new Random ();
for(int c=1;c<32;++c){
Console.Write("{0} ", fb[r.Next(0, 1);
}
}
}
}
>>
>>59327980
Seems like the long way around
>>
File: already dead.jpg (79KB, 626x479px) Image search: [Google]
already dead.jpg
79KB, 626x479px
>>59329723
>microwave time
>hit 30, then start
>runs for 30 seconds
>hit 100, then start
>runs for 60 seconds
>this is considered user friendly
>>
>>59327915
#include <stdio.h>

int main() {
int i, f, b;
for(i=1; i<=100; i++) {
f = (i%3);
b = (i%5);
if (!f && !b) puts ("FizzBuzz"); else
if (!f && b) puts ("Fizz"); else
if (f && !b) puts ("Buzz"); else
printf("%d\n", i);
}
return 0;
}
>>
>>59328086
this is like someone spent a week in /g/ and wrote a fanfiction
>>
#include <stdio.h>
#define BUZZZ int
#define FIZZZ printf
#define FIZZ for
#define BUZZ if
#define BZZ "\n"
#define FUZZ return
#define FIZZBUZZZ main
#define FIZZZBUZZ "%d"
#define FIZZBUZZ else
#define BUZZFIZZ 3
#define FIZZFIZZ 5
#define BUZZBUZZ 100

BUZZZ FIZZBUZZZ(){BUZZZ fizzbuzz;FIZZ(fizzbuzz=BUZZFIZZ/BUZZFIZZ;fizzbuzz<=BUZZBUZZ;++fizzbuzz){BUZZ(fizzbuzz%(BUZZFIZZ*FIZZFIZZ)==BUZZBUZZ-BUZZBUZZ)FIZZZ("FIZZBUZZ");FIZZBUZZ BUZZ(fizzbuzz%BUZZFIZZ==FIZZFIZZ-FIZZFIZZ)FIZZZ("FIZZ");FIZZBUZZ BUZZ(fizzbuzz%FIZZFIZZ==BUZZFIZZ-BUZZFIZZ)FIZZZ("BUZZ");FIZZBUZZ FIZZZ(FIZZZBUZZ,fizzbuzz);FIZZZ(BZZ);}FUZZ BUZZBUZZ-fizzbuzz;}
>>
>>59341312
MOODS
>>
>>59341153
>what are minutes
kek
>>
>>59341153
1:00 != 100
>>
>>59327915
>>59341312
SOURCE
>>
>>59327915
var fbpw = Array.apply(null, Array(500)).map((x,i)=>{
var coolstring = ""
x = i+1;
if(x%3==0)coolstring+="Fizz";
if(x%5==0)coolstring+="Buzz";
if(x%7==0)coolstring+="Pop";
if(x%11==0)coolstring+="Whack";
return (coolstring.length > 0)?coolstring:x;
})
>>
>>59332191
nope
(defun fizzbuzz (n &aux (f (mod n 5))
(g (mod n 3)))
(cond ((= f g 0) 'fizzbuzz)
((= g 0) 'fizz)
((= f 0) 'buzz)
(t n)))

(dotimes (i 100)
(print (fizzbuzz (+ i 1))))
>>

// IO ports
#define FB_COMMAND_PORT 0x3D4
#define FB_DATA_PORT 0x3D5

// IO port commands
#define FB_HIGH_BYTE_COMMAND 14
#define FB_LOW_BYTE_COMMAND 15

// Default Colors
#define DEFAULT_FG_COLOR 2
#define DEFAULT_BG_COLOR 0

void fb_write_cell(unsigned int i, char c, unsigned char fg, unsigned char bg);
void fb_move_cursor(unsigned short pos);
int write(char *buf, unsigned int len);

unsigned short curpos = 0;
char *fb = (char *) 0x000B8000;

void fb_write_cell(unsigned int i, char c, unsigned char fg, unsigned char bg)
{
fb[i] = c;
fb[i + 1] = ((fg & 0x0F) << 4) | (bg & 0x0F);
}

void fb_move_cursor(unsigned short pos)
{
outb(FB_COMMAND_PORT, FB_HIGH_BYTE_COMMAND);
outb(FB_DATA_PORT, ((pos >> 8) & 0x00FF));
outb(FB_COMMAND_PORT, FB_LOW_BYTE_COMMAND);
outb(FB_DATA_PORT, pos & 0x00FF);
}


int write(char *buf, unsigned int len)
{
char *t = buf;
char nl = '\n';
while(len) {

if (*t == nl) {
curpos = curpos - (curpos % 80) + 80;
fb_move_cursor(curpos);
t++;
len--;
continue;
}

fb_write_cell(curpos*2, *t, DEFAULT_FG_COLOR, DEFAULT_BG_COLOR);
curpos++;
fb_move_cursor(curpos);
len--;
t++;
}
return t-buf;
}

int main (void)
{
int x;
for(x = 1; x <= 100; x++) {
if (x % 15 == 0) {
write("FizzBuzz\n", 9);
}
else if (x % 3 == 0) {
write("Fizz\n", 5);
}
else if (x % 5 == 0) {
write("Buzz\n", 5);
}
else {
char* c = " \n";
*c = x;
write(x);
}
}
return 0;
}
>>
>>59328086
>it's real

Christ.

>people proposing all these roundabout methods to do it

I thought we were past this.
>>
npm install fizzbuzz
>>
emerge -av fizzbuzz
>>
Fizzbuzz: Scientific Engineering edition

PROGRAM FIZZBUZZ
IMPLICIT NONE
INTEGER:: N, THR, FIV
LOGICAL:: THRYES, THRNO, FIVYES, FIVNO
PRINT*, "Pick a number."
READ*, N
THR = NMOD3
FIV = NMOD5
THRYES = THR.EQ.0
FIVYES = FIV.EQ.0
THRNO = THR.NE.0
FIVNO = FIV.NE.0
DO i=1, N
IF (THRYES.AND.FIVNO) THEN
PRINT*, "Fizz"
IF (THRYES.AND.FIVNO) THEN
PRINT*, "Fizz"
IF (THRNO.AND.FIVYES) THEN
PRINT*, "Buzz"
IF (THRYES.AND.FIVYES) THEN
PRINT*, "FizzBuzz"
ELSE
PRINT i
END IF
END DO
END PROGRAM FIZZBUZZ
>>
>>59335883
and?
>>
>>59335883
>i.e. sfw
I can watch porn at work
>>
>>59343438
I just got promoted
>>
>>59330150
Defines are fine for constant integers. Only for other things do people begin caring about having const x
>>
File: 1483401875705.jpg (10KB, 337x270px) Image search: [Google]
1483401875705.jpg
10KB, 337x270px
>>59327980
You're hired
>>
File: zl0IUqn.png (173KB, 566x479px) Image search: [Google]
zl0IUqn.png
173KB, 566x479px
>>59330738
nice waste of memory u got there
>>
>>59327980
Scrub.

https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
This made me realise my shell-scripting was rusty: I kept wanting to use C syntax instead of shell syntax.
#!/bin/sh

I=1
MAX=100

while
test $I -lt $MAX
do
if
test `expr $I % 3` -eq 0
then
PRINT=fizz
fi
if
test `expr $I % 5` -eq 0
then
PRINT=${PRINT}buzz
fi
echo ${PRINT:-$I}
PRINT=
I=`expr $I + 1`
done
>>
for(int i = 1; i < 9001; i++) {
string s = i%3==0 ? "fizz":"";
s += i%5==0 ? "buzz":"";
cout << s.empty() ? i:s << endl;
}

get on my tier fags
>>
>>59344459
Explain ur thinking
>>
Is anyone here actually THAT retarded? I did FizzBuzz in like 2 minutes
>>
>>59344467
wut is ternary operator for 500 Alex

>>59344474
There's some article about a tumblr girl who is an "experienced js cover and web designer", interviewer asked her to do fizzbuzz, she lost her spaghetti, then wrote a blog article about how fizzbuzz is stupid and misogynistic. If anyone has the blog post it's golden
>>
Don't need to fulfill arbitrary interview tasks when you make malware for a living.
>>
def fizzbuzz(limit=100):
for value in range(1, limit + 1):
line_out = ''
if is_divisible_by_3(value):
line_out += 'fizz'
if is_divisible_by_5(value):
line_out += 'buzz'
if not line_out:
line_out = value
print(line_out)

three_six_nine = {3, 6, 9}
def is_divisible_by_3(value):
while len(str(value)) > 1:
value = sum(int(c) for c in str(value))
return value in three_six_nine

zero_five = {'0', '5'}
def is_divisible_by_5(value):
return str(value)[-1] in zero_five


if __name__ == '__main__':
fizzbuzz()

:^)
>>
>>59344505
Sorey Alex the correct answer was


var vals = [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14, "FizzBuzz", 16, 17, "Fizz", 19, "Buzz", "Fizz", 22, 23, "Fizz", "Buzz", 26, "Fizz", 28, 29, "FizzBuzz", 31, 32, "Fizz", 34, "Buzz", "Fizz", 37, 38, "Fizz", "Buzz", 41, "Fizz", 43, 44, "FizzBuzz", 46, 47, "Fizz", 49, "Buzz", "Fizz", 52, 53, "Fizz", "Buzz", 56, "Fizz", 58, 59, "FizzBuzz", 61, 62, "Fizz", 64, "Buzz", "Fizz", 67, 68, "Fizz", "Buzz", 71, "Fizz", 73, 74, "FizzBuzz", 76, 77, "Fizz", 79, "Buzz", "Fizz", 82, 83, "Fizz", "Buzz", 86, "Fizz", 88, 89, "FizzBuzz", 91, 92, "Fizz", 94, "Buzz", "Fizz", 97, 98, "Fizz", "Buzz"];
for(var i=1, len=res.length; i<len; i++){
console.log(res[i]);
}

We like to keep your resume on deck in case we ever need a css developer
>>
>>59344474
>>59344505
Found it:

>>59328086
>>
#include <stdio.h>

int main(void)
{
int i;
for(i=1; i<=100; ++i)
{
if (i % 3 == 0)
printf("Fizz");
if (i % 5 == 0)
printf("Buzz");
if ((i % 3 != 0) && (i % 5 != 0))
printf("number=%d", i);
printf("\n");
if(i == 39)
printf("NIGGERNIGGERNIGGER");
}
return 0;
}
>>
#include <stdio.h>
int main(void){
int i,j,t[15]={1,2,-1,4,-2,-1,7,8,-1,-2,11,-1,13,14,-3};
for(i=0;i<10;i++){
for(j=0;j<15;j++){
switch(t[j]){
case -1:printf("Fizz\n");break;
case -2:printf("Buzz\n");break;
case -3:printf("FizzBuzz\n");break;
default:printf("%d\n",t[j]);break;
}
if(t[j]>0)t[j]=t[j]+15;
}
}
return 0;
}
>>
>>59344474
>he took two minutes to code fizzbuzz

We'll get back to you.
>>
>>59327915
fn main()
{
for i in 1..101 {
let x = match (i % 3, i % 5) {
(0, 0) => "Fizzbuzz".to_string(),
(_,0) => "buzz".to_string(),
(0,_) => "fizz".to_string(),
(_,_) => i.to_string(),
};
println!("{}", x);
}
}
>>
>>59344414
Bash
for i in {1..100} ; do
out=""
(( $i % 3 == 0 )) && out="Fizz"
(( $i % 5 == 0 )) && out="${out}Buzz"
echo ${out:-$i}
done
>>
File: 1489173082128.jpg (33KB, 400x400px) Image search: [Google]
1489173082128.jpg
33KB, 400x400px
>>59339703
>==0
>not !
>>
>>59327915
>>59331659
>>59345530

Unnecessary heap allocations.

use std::borrow::Cow;

fn fizzbuzz(i: u64) -> Cow<'static, str> {
match (i%3, i%5) {
(0, 0) => "Fizzbuzz".into(),
(0, _) => "Fizz".into(),
(_, 0) => "Buzz".into(),
_ => format!("{}", i).into(),
}
}

fn main() {
for i in 0..100 {
println!("{}", fizzbuzz(i));
}
}
>>
she has no ass
>>
>>59329585
for (var num=1; num<=100; num++) {
console.log((out => (num%3 || (out+='Fizz ')) && (num%5 || (out+='Buzz ')) && (!(num%3 && num%5) || (out+=(num+' '))) && out)(''));
}
>>
activate.
prepare :::
- \x ⇒ x mod 3 ℕ → ℕ --| compiler: total.
- \x ⇒ x mod 5 : ℕ → ℕ --| compiler: total.
- { } : ℕ 1..inf --| halt if (> 99999999).
give names :::
previous:
- fizz
- buzz
- n

loop : n → () --| compiler: iterate n.
bind a = (fizz x, buzz x)
match a :::
(0,0) → IO.print() --| compiler: infer arguments.
(0,_) → IO.print() --| compiler: infer arguments.
(_,0) → IO.print() --| compiler: infer arguments.
_ → IO.print() --| compiler: infer arguments.
next n.

halt.
QED.
>>
>>59346430
Forgot a colon in the type signature of fizz.
>>
>no brainfuck

>++++++[<++++++++>-]++++++++++[>++++++++++<-]>[>>+<<->>>>+++<<[>+>->+<[>]>[<+>-
]<<[<]>-]>[-<+>]>>>[-]+>[-]<<[>-<[>>+<<-]]>>[<<+>>-]<[>+++++++[>++++++++++<-]>.
>>+++[>+++++<-]>[<+++++++>-]<.>++++[>++++<-]>+[<<+>>-]<<..[-]<<[-]<<-<<<<<<<+>>
>>>>>]<[-]<[-]+++++<<[>+>->+<[>]>[<+>-]<<[<]>-]>[-<+>]>+>>[-]+>[-]<<[>-<[>>+<<-
]]>>[<<+>>-]<[>++++++[>+++++++++++<-]>.>+++++++++[>+++++++++++++<-]>.+++++..[-]
<<[-]<<-<<<<<<<+>>>>>>>]<[-]<[-]>[-]<<<<<<[>>>>>+>+<<<<<<-]>>>>>[<<<<<+>>>>>-]+
>[<<<<<<[-]>>>>>->[-]],<[<<[>>>+>+<<<<-]>>>[-<<<+>>>]>>>++++++++++<<[->+>-[>+>>
]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[>
++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++++++<]>.[-]]<<++++++[-<+++
+++++>]<.[-]<<[-<+>]<-<<-]++++++++++.[-]<<<<]
>>
>>59328232
>include iostream.h
>public static void main {} {}
Cava++
>>
>>59346579
It doesn't even work though.
>>
>>59346627
it works though
https://www.nayuki.io/page/brainfuck-interpreter-javascript

the instructions I followed were:
print “Fizz” if the number can be divided by 3 only
print “Buzz” if the number can be divided by 5 only
print “FizzBuzz” if the number can be divided by both 3 and 5
print the number otherwise
>>
>>59346663
and by “by 3 only” or “by 5 only”, I meant not by the other, not by anything else
>>
>>59346663
It's fucking garbage. It doesn't work with my formally verified compiler.
>>
#bizzfuzz.sh 0.2
n=0
while [ $n -lt 100 ]; do
x=$(shuf -i 0-10 -n 1)
if [[ $x == 0 ]]; then echo -n bizz; fi
if [[ $x == 1 ]]; then echo -n fuzz; fi
if [[ $x == 2 ]]; then echo -n bizzfuzz; fi
if [ "$x" -ge 3 ]; then echo -n $n; fi
let n=n+1; echo -n " "
done
>>
>>59327915
Computes at read-time:
#.(loop for i from 1 to 100 do
(if (not (or (zerop (mod i 3)) (zerop (mod i 5))))
(princ i)
(progn (when (zerop (mod i 3)) (princ "Fizz"))
(when (zerop (mod i 5)) (princ "Buzz"))))
(terpri))
>>
>>59344444
>>
import fizzbuzz
fizzbuzz.do()


Get fucked kiddos
>>
>>59339703
Why are you browsing /g/ on a rpi?
>>
>>59347941
>has to import an already written fizzbuzz module to his program to do fizzbuzz
>>
>>59347983
>has to reinvent the wheel
That's why you're unemployeed
>>
print+(Fizz)[$_%3].(Buzz)[$_%5]||$_,$/for 1..100

48 characters
Perl
Shortest possible fizzbuzz
Prove me wrong.
>>
>>59347983
it's a built-in function in my language.
>>
>>59346067
I don't have bash installed.
>>
>>59340364
>>59346430
>>59347941
wew
>>
>>59350897
what?
>>
>>59348089
code golf promotes bad practices
>>
File: 001.png (149KB, 500x313px) Image search: [Google]
001.png
149KB, 500x313px
>>59346335
>she
>>
>>59327915
This is a SFW board and that is a NSFW image. Please remove it
>>
>>59332611
>woman
That literally is a dude. There;s another part of the gif where he shows his cock off
>>
>>59327915
I reported this yesterday, why is is still up
this is a blue board and a picture of an ass out like such would be enough to get someone fired @ work
>>
>>59353454
People with jobs don't type in 4chan.org.
>>
>>59351065
lad
>>
>>59348089
27 characters
gs2

1b    100
2f range1 (1..n)
fe m: (map rest of program)

cc put0 (pop and store in register 0)
04 string-begin
Fizz
09 9
07 string-separator
Buzz
19 25
06 string-end-array (result: ["Fizz"+chr(9) "Buzz"+chr(25)])

27 right-uncons
2d sqrt
d8 tuck0 (insert value of register 0 under top of stack)
62 divides
32 times (string multiplication)
ec m5 (create block from previous 5 tokens, then call map)

99 flatten
dc show0 (convert register 0 to string and push it)
61 logical-or
0a newline
>>
>>59327915
>99% of autists can't follow simple rules

You're not one of them, rig--oh, yeah. You are. Fuck off.
>>
>>59353486
don't "lad" me.
>>
>>59353478
This is incorrect. I'm posting from work right now. In between patients I literally have five minutes of work with an hour to do it in, so I waste the other 55 minutes here.
>>
using System;

namespace FizzBuzz
{
class Program
{
public static void Main()
{
for (int i = 1; i <= 100; i++ )
Console.WriteLine((i % 3 == 0 || i % 5 == 0) ? ((i % 3 == 0 && i % 5 == 0) ? $"FizzBuzz: {i}" : ((i % 3 == 0) ? $"Fizz: {i}" : $"Buzz: {i}")) : i.ToString());
}
}
}
Thread posts: 316
Thread images: 29


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.