[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]

FizzBuzz

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: 317
Thread images: 21

File: 1307024554777.jpg (22KB, 500x533px) Image search: [Google]
1307024554777.jpg
22KB, 500x533px
The "Fizz-Buzz test" is an interview question designed to help filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag. The text of the programming assignment is as follows:
"Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”."


is this a joke? I'm studying C for 2 weeks and I literally wrote the if statements in for this in 2 minutes

 if( index%3 == 0 && index%5 != 0 ) printf("\nFizz");
if( index%5 == 0 && index%3 != 0 ) printf("\nBuzz");
if(index%3 == 0 && index%5 == 0) printf("\nFizzBuzz");
else if(index%3 != 0 && index%5 != 0) printf("\n%d", index);

>>
>>58332218
This is why
https://css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
>>
>>58332218
>writing unnecessary conditions because he's too retarded to use else-ifs and else properly.

kys retard
>>
wouldn't hire you with that shit code.
you are part of the 99.5%
>>
>>58332326
literally this
>>
>>58332257
Letting programmers name anything was a mistake.
>>
>>58332326
>>58332313

these
>>
>>58332431
give him a break he's a super beginner

is fizzbuzz real anyway? do they really ask you to do it?
>>
OP here

you are right I forgot about

>Once an else if succeeds, none of the remaining else if's or else's will be tested.

how is this?

 if(index%3 == 0 && index%5 == 0) printf("\nFizzBuzz");
else if(index%3==0) printf("\nFizz");
else if(index%5==0) printf("\nBuzz");
else printf("\n%d", index);
>>
I have not had fizzbuzz in any of my application tests
>>
>>58332438
it's real for shit tier cs jobs. I mean the quality of the work, not the pay. good cs jobs ask pretty interesting questions!
>>
>>58332459
You don't need to give FizzBuzz its own line. That's a bad flag. At its roughest, it should be:

>Check if it's not a multiple. Print number if true.
>Print Fizz if applicable.
>Print Buzz if applicable.
>Print line break.
>>
sub fizzbuzz ($n) {
given $n %% 3, $n %% 5 {
when ~(True, True ) { "fizzbuzz" }
when ~(True, False) { "fizz" }
when ~(False, True) { "buzz" }
$n
}
}


and some people find Perl6 hard.
>>
Dumb meme. For perspective, I was asked to write a method to check if a binary tree is balanced for a sophomore summer CS internship. (among other coding questions)
>>
 

for(int i = 0; i <= 30; i++) {
if(i % 5 && i % 3 == 0)
cout << "Fizzbuzz";
else if(i % 3 == 0)
cout << "Fizz";
else if(i % 5 == 0)
cout << "Buzz";
else
cout i;
}
>>
>>58332685
if (i % 5 && i % 3 == 0)

anon
you realize you wrote
if (i % 5 != 0 && i % 3 == 0)

you're part of the 99.5%
>>
for ( n = 0; n < 100; n++){
if ( n % 3 == 0 ){
cout << "Fizz";
} else if ( n % 5 == 0 ) {
cout << "Buzz";
else if(n%3 == 0 && n%5 ==0) {
cout << "Fizz" << " "<< "Buzz";
}else{
cout << n;
}
}
>>
>>58332218
You're part of the 99.5%.

Keep studying and don't be a pretentious asshole.
>>
>>58332733
whoops :^)
>>
>>58332218
This isn't what they do anymore. This is what they do now:

Step 1:
- Phone screen. Some contractor phones you and is typically as rude as possible/jackassery demanding you program over the fucking phone and asks you some questions. "What is the best way to sort X?" WRONG it's only X way".

Step 2:
- 'Founder' screen. If a startup some cofounder will phone you and ask you weird questions. 'What is a time you felt you were treated unfairly?". They will then shill all their bullshit culture and whatever in hopes of you joining the cult.

Step3:
You can invited for a week long interview (yes, a week usually longer). Basically you will have a huge series of 45min whiteboard interviews with various departments, all of them will by ivy league engineers trying to gotcha with stupid shit. All they really care at this part is you can explain your reasoning while you whiteboard program. They will continually ask you to optimize whatever you've done too. "balance this tree. How could you do it faster? Do it faster again blah blah".

Step4:
Monkey dancing continues with you typically doing a large work sample test that won't be like anything you will actually work on or applied for. Half way through you'll feel like you're working for free at this point and getting scammed.

Finally you get to negotiations where salary is discussed. This is where you discover after all that you'll only be offered a laughable salary. This is the current state of the art tech interview system unless you handpick a few startups that don't do this bullshit.
>>
printf( (!(i&3) && !(i&5))?"FizzBuzz\n":!(i&3)?"Fizz\n":!(i&5)?"Buzz\n":"%d\n", i );
>>
>>58332622
That's a step in the wrong direction.

Having a method print its result to stdout is already freshman tier bullshit. Now you're further writing yourself into that corner.
>>
>>58332767
Ooops, used & instead of %. Oh well.
>>
>>58332755
>mfw this is true if you interview
>mfw my good tier degree and FOSS contribs mean there are literally dozens of recruiters throwing salary quotes at me
The God tier way to get a job is to get recommendations from insider friends anyhow.
>>

for(var i = 0; i <= 15; i++){
if(i == 3 || i == 6 || i == 9 || i == 12)
console.log("Fizz")
else if(i == 5 || i == 10)
console.log("Buzz")
else if(i == 15)
console.log("Fizzbuzz")
}
>>
>>58332257
>Me: Ok, again to be honest, my JS knowledge is more regarding UI/UX based tasks. And I don't really understand the point of the question. Like, what's the use case? When would this come up in the role?

What the interviewer should have said was "We have a blog and we want to show ads on every 3rd post and every fifth one should be a sponsored story. Can you write "post, post, post with ad, post, sponsored story, ..."

Then she'd just say "oh,I see. I realize now that I'm a fraud. Sorry to waste your time." and maybe learn something instead of writing this blog post
>>
>>58332840
lol
>>
>>58332835
Same, that's how I got all my jobs before I just became a contractor. Still I had to whiteboard interview
>>
File: d.png (16KB, 294x294px) Image search: [Google]
d.png
16KB, 294x294px
import std.stdio;

void main() {
foreach (i ; 1 .. 101) {
if (i % 3 != 0 && i % 5 != 0)
writeln(i);
if (i % 3 == 0)
write("Fizz", (i % 5 != 0) ? "\n" : "");
if (i % 5 == 0)
writeln("Buzz");
}
}
>>
>>58332935
Less retarded version:
import std.stdio;

void main() {
foreach (i ; 1 .. 101) {
if (i % 3 != 0 && i % 5 != 0)
write(i);
if (i % 3 == 0)
write("Fizz");
if (i % 5 == 0)
write("Buzz");
writeln();
}
}
>>
OP here with another possible solution

if(index%3!=0 && index%5!=0) {printf("%d\n", index); continue;}
if(index%3==0) printf("Fizz");
if(index%5==0) printf("Buzz");
printf("\n");



I'm so glad I made this thread. I learned a lot.
>>
>>58332955

and please dont tell me using continue is bad programming practice
>>
>>58332218
you know you can still be part of the 99.5% even if you can do fizzbuzz right?
>>
>>58333001

yes I was already exposed read the thread
>>
>>58332415
>>58332257
even if you couldn't program this is a simple exercise in logic, the pseudo-code


if n is y and y fizz buzz
else if n = x fizz
else if n y buzz
print n

surely would have been possible with her "expertise" right?
>>
#include<stdio.h>
void main() {
const char *vars[] = { "%d ","Fizz ","Buzz ","FizzBuzz " };
for (int i = 1; i < 101; ++i)
printf(vars[(i % 3 == 0) + (i % 5 == 0)*2], i);
}
>>
It's not a joke. I interview for a reasonably well-known tech firm; we use it as a weed-out/warmup question. It doesn't say if we *should* hire you, just if we *shouldn't*.

There's a significant number of applicants who get really tripped up on this kind of thing. Seriously; it's amazing.
>>
>>58333046

can you sleep well at night?
>>
>>58332824
Welcome to the 99.5%
>>
>>58333046
I now use: "Count down from 700 to 200 in decrements of 13."
>>
>>58332955
>>58332955

I'm actually retarded. It can be done with only this

if(index%3==0) printf("Fizz");
if(index%5==0) printf("Buzz");
if(index%3!=0 && index%5!=0) {printf("%d", index);}
printf("\n");



this is it. this must be the ultimate solution.
>>
>>58333189
Can be done with two ifs.
>>
>>58333147
var i = 700
while i >= 200 {
print(i)
i -= 13
}

Can you mess that up?(I somehow messed that up)
>>
>>58332755
Fuck this I'm doing sales
>>
>>58333147
how is that even hard?
>>
>>58333235
Depending on the language, syntax might be off, but the logic is sound.

>>58333280
It is not hard.

It is like this: You are hiring a new pianist for your orchestra. An interviewee walks in, so you take them to a room with a piano, a drum, and a guitar.

"Point out the piano".

If the interviewee cannot point out the piano, what is the point of continuing the interview? So it goes with FizzBuzz, or "Count down from 700 to 200 in decrements of 13."
>>
 
(map (fn fizzbuzz [n]
(cond
(and
(zero? (mod n 3))
(zero? (mod n 5))) (println "FizzBuzz")
(zero? (mod n 3)) (println "Fizz")
(zero? (mod n 5)) (println "Buzz")
:else
(println n)))
(range 1 (inc 100)))


That whiner got whats comming, just because she wants to programm UI doesn't mean she should't be able to handle data...
>>
>>58333311
Yes that is right. You should be figuring out if the person really knows anything and possibly some problem solving. Most crap can be looked up but it takes years to learn some stuff. Also their personality. They can learn some skills on the job but being an asshole isn't something that can be fixed.
>>
>>58333311
it's fucking amazing how people can't get their head around it being simple
>>
File: lostlocke.jpg (22KB, 399x297px) Image search: [Google]
lostlocke.jpg
22KB, 399x297px
>>58333212
>>58333212

I give up

can you please tell me how?
>>
>>58333705
not him but maybe:
if(..)
if (..)
else
>>
>>58333778

that doesnt work. I cant find such a solution on the internet either
>>
>>58332935
D FUCK YES
>>
>>58333705
>>58333020
>>
>>58332438
I'm at a decent software company and we used to ask it to weed out fakers quickly.
Today we have an online test before the on-site interview that does more or less the same job.
>>
>>58333705
Here's my solution written in JS. It only uses two if-statements.
It is meant to be as small as possible (there are smaller solutions).
for(i=1;i<=99;i++)console.log((i%3?"":"Fizz")+(i%5?"":"Buzz")||i)
>>
>>58332767
>>58332824
>Why its a bad idea to code in one line/command
>>
>>58334079

I dont understand this

what would it look like in C ?
>>
>>58334210
You can't do that in C for at least 3 different reasons.
>>
File: 802unicorns.jpg (76KB, 600x816px) Image search: [Google]
802unicorns.jpg
76KB, 600x816px
>>58332257
I just read this, and is this faggot seriously complaining about being tested on fucking FizzBuzz?
>pic related
>>
>>58332737
You're doing it wrong kiddo.
I assume it's your first week coding, otherwise your wasting your time, go work at Burger King or something
>>
>>58332767
cannot find symbol 'i'
>>
>>58334370
its meant to be used in a for loop i'm guessing, cause i is always used in them
>>
for (int i = 1; i <= 100; ++i) {
printf(i%3 && i%5 ? "%d" : "", i);
printf("%s", i%3 ? "" : "Fizz");
printf("%s\n", i%5 ? "" : "Buzz");
}
>>
>>58334079

The ||-statement in your solution is an if-statement: if the value is "falthy" (empty or undefined) it gets set to i.

You're adding syntactic sugar, but it's still 3 if-statements.


>>58333189

There are many options:

1. Make a variable that gets set to fizz or buzz, check if it's empty --> if it's empty, print the number (the solution of the guy above)

2. if(i%15 == 0 ) --> "fizzbuzz", if(i%3 == 0 ) --> "fizz", if(i%5 == 0 ) --> "buzz"

Note that this solution does not work if you take numbers like 3 and 9 (each number which can be divided by 9 is already a "fizzbuzz", not each number which can be divided by 27).


3. Another optimization would be to do only two mod-operations for each number, since mod is quite expensive:
boolean_fizz = (i%3 == 0)
boolean_buzz = (i%3 == 0)

Checking your booleans afterwards costs almost nothing.


4. Higher optimization is about using "wheels":
You take two array with 100 booleans. For the first array you make a simple for-loop in steps of three and set every third value to "true". For the second array you repeat it with a for-loop in steps of 5. Step three is a simple for-loop that checks both boolean arrays.
You can completely avoid the modulo-operation, which is quite expensive.


5. A pretty mean hack is the "fizzbuzz of the christ", here in python, but you can also do it in C, since C looks at strings as an array of chars:
for i in range(1,101):
print("FizzBuzz"[i*i%3*4:8--i**4%5] or i)


Or with parentheses:

for i in range(1,101):
print("FizzBuzz"[((i**2)%3*4):(8-((-(i**4)))%5)] or i)


This is actually a pretty mathematical solution and works only because 5 and 3 are prime numbers. It uses a certain property of prime numbers:

"n^(n-1) mod n = 0", but "(n+k)^(n-1) mod n = 1" for all 0 < k < n

Check this out:
for i in range(1,101):
print((i**2)%3)



6. Using AI for "guessing" the numbers:
>http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
>>
for n in range(101):
if n%3==0:
print("fizz")
elif n%5==0:
print("butt")
else:
print(n)

Can I into code?
>>
>>58332218
10 INT I
20 I = I + 1
30 IF I MOD 15
40 THEN PRINT "FIZZBUZZ"
50 GOTO 20
60 IF I MOD 3
70 THEN PRINT "FIZZ"
80 IF I MOD 5
90 THEN PRINT "BUZZ"
100 ELSE PRINT I
110 GOTO 20
120 END
>>
>>58334625
>number coded basic
stop. That language ruined me forever.
>>
>>58334625

Dat nostalgia..
>>
using System;
using System.Text.RegularExpressions;
using static System.Console;
namespace fizzbuzz {
class Program {
static void Main(string[] args){
WriteLine(Regex.Replace(Regex.Replace("1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ",
@"(\d+ \d+ )\d+",
"$1Fizz"),
@"([^ ]+ [^ ]+ [^ ]+ [^ ]+ )(\d+)?([^\d ]+)?",
"$1$3Buzz")
);
Console.ReadKey();
}
}
}
>>
>>58334868

Holy shit, it actually works..
>>
>>58334915

Heh, why did he delete his solution?
>>
>>58334925

Oh I see, it's there:
>>58334880
>>
> all those 4 division solutions posed as a good ones
No wonder that programming is going to shit nowdays.
>>
>>58332622
Without its own line, a 3rd party reading the source may not realise that a multiple of 3 and 5 will print both. Therefore it is better to give it its own line at the expense of the extra computation time and code lines unless you are writing cycle-critical code.
>>
>>58334960
>We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil
>>
File: Obi-Wan-Kenobi.jpg (21KB, 454x330px) Image search: [Google]
Obi-Wan-Kenobi.jpg
21KB, 454x330px
>>58334625
>>58334625
>>
>>58332218
#include <stdio.h>

int main(){
fizzbuzz();
}

int fizzbuzz()
{
int x;
for(x = 1; x<101;x++){

if(x % 15 == 0){
printf("%d FizzBuzz\n",x);
}
else
if(x % 3 == 0){
printf("%d Fizz\n",x);
}

else
if(x % 5 == 0){
printf("%d Buzz\n",x);
}

else
printf("%d\n",x);
}
}

>>
(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)))
>>
$fizzbuzz = array('fizzbuzz','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');
print_r($fizzbuzz);
>>
>>58332218
++++++++++[>++++++++++<-]>>++++++++++>->>>>>>>>>>>>>>>>-->+++++++[->++
++++++++<]>[->+>+>+>+<<<<]+++>>+++>>>++++++++[-<++++<++++<++++>>>]++++
+[-<++++<++++>>]>>-->++++++[->+++++++++++<]>[->+>+>+>+<<<<]+++++>>+>++
++++>++++++>++++++++[-<++++<++++<++++>>>]++++++[-<+++<+++<+++>>>]>>-->
---+[-<+]-<[+[->+]-<<->>>+>[-]++[-->++]-->+++[---++[--<++]---->>-<+>[+
+++[----<++++]--[>]++[-->++]--<]>++[--+[-<+]->>[-]+++++[---->++++]-->[
->+<]>>[.>]++[-->++]]-->+++]---+[-<+]->>-[+>>>+[-<+]->>>++++++++++<<[-
>+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>
+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->+++
+++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]+[-<+]->>]+[-]<<<.>>>+[
-<+]-<<]
>>
>>58334210
listen man, you are appending buzz. Thus, a mutiple of 3 and 5 would be fizz + buzz. If it's only multi of 5, than "" (empty str) + buzz, which is just buzz. Thus done in a line. Lot of the people in this thread are writing the code verbatim to solve the problem and not thinking about a good way to solve the problem.
>>
For(int i=1, i<=100, i++){
if (i%3==0 || i%5==0) {
if (i%3==0){
print("Fizz");
}
if (i%5==0){
print("Buzz");
}
else{ print(i);}
print("\n");
}
>>
>>58332755
I want to give you reddit gold for this
>>
File: ;D.png (57KB, 800x334px) Image search: [Google]
;D.png
57KB, 800x334px
>>58332935
>>58332953
>global import
>foreach and not map or iter
>not even using predswitch
>>
What even is the point of the fizzbuzz challenge? To do it with the fewest possible comparisons? To just get it to work?
>>
>>58339796
To give people a reason to learn Haskell
>>
>>58332218

import fizzbuzz
fizzbuzz.run()


So easy, even a girl could do it.
>>
>>58332625
That looks really aesthetic for some reason.
>>
On a Popular Drinking Game.

Tybalt, the player of today's game.
Romeo, who keeps butting in.
Balthazar, a limiting factor.

Act I: Before the Game.

Scene I: An Uninvited Guest.
[Enter Balthazar and Tybalt]
Tybalt:
Listen to your heart.
Balthazar:
You plum.
[Exit Balthazar]
[Enter Romeo]
Scene II: Romeo's Question.
Romeo:
Is the remainder of the quotient between yourself and the sum
of a trustworthy fellow and a hero as good as nothing?
Tybalt:
If so, let us proceed to scene V.

Scene III: Romeo Continues.
Romeo:
Is the remainder of the quotient between yourself and the sum
of an angel and a beautiful blossoming flower as good as nothing?
Tybalt:
If so, let us proceed to scene VI.

Scene IV: The Easy Way Out.
Romeo:
Open your heart.
Tybalt:
Let us proceed to scene VII.

Scene V: Tybalt and the Art of Flattery.
Tybalt:

You mighty brave charming honest handsome noble fellow! You
are as bold as the sum of a big old hero and yourself. You are
as fair as the sum of a loving son and yourself! Speak your mind.

You are as rich as the sum of yourself and the quotient between
yourself and your large purse. Speak your mind.

You are as warm as the sum of yourself and a summer's day. You
are as cute as the sum of yourself and a pretty proud fine
little thing. Speak your mind. Speak your mind!
>>
>>58339867


Is the remainder of the quotient between myself and the sum of
my thing and your lovely cute sister as good as nothing?

Romeo:
If not, let us proceed to scene VII.

Scene VI: Tybalt Starts to Run Out of Steam.
Tybalt:
You cunning fellow. You are as mighty as the difference
between yourself and a stupid vile half-witted damned dirty
lying coward. Speak your mind.

You are as large as the product of yourself and the good Lord.
You are as small as the sum of yourself and the difference
between a cat and a beautiful blossoming lovely red
rose. Speak your mind.

You are as big as the sum of yourself and a good old pony. You
are as big as the sum of yourself and a thing. Speak your
mind. Speak your mind!

Scene VII: The Next Round Begins.
Tybalt:
You cunning fellow. You are as mighty as the sum of yourself
and the cube of a little cat. Speak your mind!
Romeo:
You are as good as the sum of yourself and a King.
Tybalt:
Am I better than Balthazar?
Romeo:
If not, let us return to scene II.
[Exeunt]
>>
>>58332218
First comment:

milar to many “interviews” I’ve been on. The whole fixbuzz thing is a huge joke. I have never used the or heard of PHP’s modulous operator before or since I failed the fizzbuzz test.
>>
function fizzBuzz2()
for i=1,100 do
number = true;
str=" ";
if (i % 3 == 0) then
str = str.."fizz"
number = false;
end

if (i % 5 == 0) then
str = str .. "buzz";
number = false;
end

if (number) then
str = str .. i;
end

print(str);
end
end
>>
>>58332218

C       FizzBuzz
PROGRAM FZZBZZ
INTEGER I
DO 10, I=1,100
CALL COUNT(I)
10 CONTINUE
END

SUBROUTINE COUNT(I)
INTEGER I
IF (MOD(I, 3) .EQ. 0 .AND. MOD(I, 5) .EQ. 0) THEN
WRITE (*,*) 'FizzBuzz'
ELSE IF (MOD(I, 3) .EQ. 0) THEN
WRITE (*,*) 'Fizz'
ELSE IF (MOD(I, 5) .EQ. 0) THEN
WRITE (*,*) 'Buzz'
ELSE
WRITE (*,*) I
END IF
END
>>
>>58339896
But I prefer this:
for i=1, 100 do
if(i % 15 == 0) then print('fizzbuzz')
elseif (i % 3 == 0) then print ('fizz');
elseif (i % 5 == 0) then print ('buzz');
else
print(i);
end
end
>>
>>58339880
>I have never used the or heard of PHP’s modulous operator before or since I failed the fizzbuzz test

Every once in a great while I read something that encapsulates everything that's going wrong in the world.

That sentence is a great example.

How can anyone even pretend to call themselves a programmer if they have never encountered the % operator, or not know what it is?

The thing that's so galling about this is that everyone knows what the underlying concept is. Everyone has, at some point in their childhood, sat in a math classroom and seen the concept of "remainder after division". What is 7 divided by 3? It's 2, with a remainder of 1. Everyone has seen this. Everyone. And people who call themselves "programmers" damn well better have enough curiosity to care about the concept of integer division and what the remainder might be after performing it. This is *division* we're talking about here. One of the four fundamental arithmetic operators. Something they teach to third graders. THIS IS LITERALLY CHILD'S PLAY. And yet, we have a whole army of people out there who like to think of themselves as "programmers" who can't even use a programming language to express a concept that we teach to third graders.

But what's much, much worse -- is that they don't even have the curiosity to find out. This guy learns that he is utterly deficient in one of the most fundamental math and programming concepts in existence: integer division and the remainder that it produces. So what does he do? Does he use this opportunity to realize his deficiency and learn something new? No -- of course not. Why would he fucking ever do that? Why would he not just blame everyone else for his deficiency?
>>
I just link to my repo:
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
>>58339963
>But what's much, much worse -- is that they don't even have the curiosity to find out.

I don't know how someone gets here. There probably isn't a single beginner programming course or book that omits modulus
>>
now do it in assembly
>>
>>58340104
which architecture?

>>58340096
>people skip a lot of shit
>>
>>58332257
Jesus, this bitch is Dunning-Kruger personified.
>>
>>58340201
>this guy has dunning-kruger
Tell tale symptoms of dunning-kruger
>>
>>58340096
>I don't know how someone gets here.

He was self-taught. Ever since the web came along, you don't really need a teacher anymore -- there's lots of web pages that will explain things to you like a teacher would.

The fact is that almost everything I do is self-taught. I got my degree in CS so long ago that the only thing about my degree that's still relevant is the basic science of it.

There's nothing in my education that prepared me for developing HTML GUI, designing applications based on the HTTP request/response model, or how to use Promises in JavaScript.

So I can see how the scatter-shot nature of learning by reading random web-pages can leave a person with a few deficiencies.

But for someone who calls himself a "programmer" to encounter the mod operator for the first time, and then immediately dismiss it as unimportant -- that shows a whole new level of arrogance and willful ignorance that's slowly and sadly becoming the new norm.
>>
>>58340153
>which architecture?
your favorite one :^
>>
>>58340225
The best thing about Dunning-Kruger is that it was meant as joke by these guys.
But since it's so easy to 'identify' in other people, it took on a life of it's own and now we have half of the internet diagnosing this for the other half.
>>
>>58340450
people who accuse other people of having dunning-kruger are the only people that actually have it
>>
>>58340408
My experience in graduation (btw, I graduated in a program called "Mathematics with CS emphasis", in the Mathematics department, which is something I don't know exists in the US) Most of the things I did were highly abstract and the only languages I was taught were x86 and MIPS asm (for computer architecture and design), C form everything else and Pascal in the first semester.
I believe that a CS course should focus on concepts instead of technologies.
Isn't like that anymore?
>>
>>58332218

I had to interview a fair number of people at my last job. It was *shocking* how bad most candidates were. I'm not interested in esoteric data structures or puzzle questions, I'm more the "can this person converse intelligently and explain their relevant past projects" kind of guy.

But I always give the basic questions, like "write a function that takes an argument 'n' and then prints out every number from one to n", or "write a function to reverse a string".

I actually interviewed one guy that had like 15 years of experience as a consultant, applying for a fairly difficult C++ position, who literally did not understand for loops. For example, given this:

for (int i = 0; i < 10; i++)


He thought that every time 'i' was referenced in the body of the function, that it would get incremented. He literally could not write a function that printed numbers from 1 to n.

>>58332257

Personally, I wouldn't expect a front-end Javascript hipster schmuck to do Fizzbuzz. The one and only reason for this is modulo arithmetic. It's *extremely* common to cover modulo in CS101 (or high school CS, in my case), but if you somehow missed out on that, then the problem becomes much, much harder.

I care about domain experience. If I'm looking for someone with reasonable design skills who can string together the latest stack of absurd Javascipt libraries, then I'm honestly not likely to care *at all* whether or not they can even write a proper loop. I would care much, much more about things like their attention to detail, how they organize and document their code, etc.
>>
>>58332218
I got 4 complicated code puzzles "what's the output of..."
And the last task was to implement a tree data structure, balance and populate it.

All in one hour. On paper.

Needless to say I failed because I picked the wrong strategy. Should have implemented the tree first.
>>
>>58340618
Balanced?
>>
>>58332755
>startups

Found your problem. Well, part of your problem.

Seriously, kids, don't play the startup lottery. You're much, much better off targeting one of the large, well-known tech companies (Google, Facebook, Apple, even Microsoft) to gold-plate your resume out of college.

If you can't hack that (no worries, I'm sure I couldn't), then look at established large companies, or small shops *that don't describe themselves as startups*. A lot of people seem to think that their dumb, small, privately owned company is a startup, and they use that buzz to try to convince /g/oobers to work for them.

Oh, and never EVER work for a startup unless there's a clear stock option plan. Not that they're worth much (most likely the company will fail before you can sell them), but *NO* stock option plan is a clear indicator that you're just being taken advantage of.
>>
>>58340554

'CS' is still floundering, unable to decide if it's mathematics or a technical school.

In my program, there were two sides of things. There were data structure and theory classes, then there were the engineering-related classes. To graduate, you had to do a sort of thesis, where you formed groups, went out and found someone in the community that needed software written (in our case, a medical records program), then you had to write all the stages of documentation, create the software, and present it.

Anyway, IMO we should have math-heavy CS and skills-oriented technical schools. In many, many situations, some basic business knowledge would be more useful to someone doing programming than a lot of CS theory would be.
>>
>>58340775
>Anyway, IMO we should have math-heavy CS and skills-oriented technical schools. In many, many situations, some basic business knowledge would be more useful to someone doing programming than a lot of CS theory would be.
depends what you're going into
>>
>>58340618
>balance

Balancing a binary tree is not easy feat. I only just got around to doing it a couple of years ago, and it probably took me two or three full days to fully work out what to do.

IIRC, it boils down to a pretty simple set of rules, but discovering those rules on your own isn't easy.
>>
>>58340794
>depends what you're going into

Right, which is why I wrote

> > IMO we should have math-heavy CS and skills-oriented technical schools.

You realize I'm saying TWO separate things, right? CS programs that are math heavy, and technical schools that are skills-focused.
>>
>>58340439
https://hastebin.com/elalehaxek.vbs
Holy shit, how many pastebin alternatives do I have to try before one isn't already 'marked as spam'. Fuck you.

>>58340529
I kind of implied that, somewhat.
>>
File: bone_dry.gif (2MB, 540x540px) Image search: [Google]
bone_dry.gif
2MB, 540x540px
#include <stdio.h>
#define LEFT_BRACE {
#define RIGHT_BRACE }
#define LEFT_BRACKET [
#define RIGHT_BRACKET ]
#define LEFT_PARENTHESIS (
#define RIGHT_PARENTHESIS )
#define SEMICOLON ;
#define COMMA ,
#define EQUALS =
#define IS_EQUAL_TO ==
#define IS_NOT_EQUAL_TO !=
#define IS_LESS_THAN <
#define IS_GREATER_THAN >
#define IS_LESS_THAN_OR_EQUAL_TO <=
#define IS_GREATER_THAN_OR_EQUAL_T >=
#define MODULUS %
#define INCREMENT ++
#define DECREMENT --
#define AND &&
#define OR ||

int main LEFT_PARENTHESIS RIGHT_PARENTHESIS
LEFT_BRACE
int i SEMICOLON
for LEFT_PARENTHESIS i EQUALS 0 SEMICOLON i IS_LESS_THAN_OR_EQUAL_TO 100 SEMICOLON i INCREMENT RIGHT_PARENTHESIS
LEFT_BRACE
if LEFT_PARENTHESIS i MODULUS 3 IS_NOT_EQUAL_TO 0 AND i MODULUS 5 IS_NOT_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "%d" COMMA i RIGHT_PARENTHESIS SEMICOLON
if LEFT_PARENTHESIS i MODULUS 3 IS_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "Fizz" RIGHT_PARENTHESIS SEMICOLON
if LEFT_PARENTHESIS i MODULUS 5 IS_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "Buzz" RIGHT_PARENTHESIS SEMICOLON

printf LEFT_PARENTHESIS " " RIGHT_PARENTHESIS SEMICOLON
RIGHT_BRACE

printf LEFT_PARENTHESIS "\n" RIGHT_PARENTHESIS SEMICOLON
return 0 SEMICOLON
RIGHT_BRACE
>>
>>58340828
>https://hastebin.com/elalehaxek.vbs
saved
>>
[('fizzbuzz' if i%15==0 else ('fizz' if i%3==0 else ('buzz' if i%5==0 else i))) for i in range(1,101)]
>>
>>58340775
In my case, most of my first two years were math only, I've had: Calculus I-IV, Numeric Calculus I-II, Geometries (Analytical I-II, Euclidean), Linear Algebra I-II-III, Algebra I-II, Statistics I-II, Logic I-II, Optimization and linear programming. We also had to go to the Physics department for General Physics (I-II-III) and their respective labs.
Then I've had everything else you should have on a proper "CS" course
>>
>>58340972
>Then I've had everything else you should have on a proper "CS" course

That's a bit of a silly thing to say in a thread discussing what a CS degree should be.
>>
>>58340991
That was the irony, sorry
>>
10 PRINT "

1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz"

>>
>>58333018
Sure, now write fizz buzz without the modulo operation
>>
>>58340921
Snook something like that into production.
Fuck you Lexware.
>>
Will I get any bullshit for this? It's the most direct way I thought of.

def main():
for x in range(1,101):
if x%3 != 0 and x%5 !=0:
print(x,end="")
if x%3 == 0:
print("Fizz",end="")
if x%5 == 0:
print("Buzz",end="")
print('\n')

if __name__ == "__main__":
main()

>>
 
count = 0

while count != 100:
count += 1
if count % 5 != 0 and count % 3 != 0:
print(count)
elif count % 5 == 0 and count % 3 == 0:
print("Fizzbuzz!")
elif count % 3 == 0:
print ("Fizz!")
elif count % 5 == 0:
print("Buzz!")
>>
File: 1476825755598.png (20KB, 1106x1012px) Image search: [Google]
1476825755598.png
20KB, 1106x1012px
>>58341261
Just realized I should've put an else after the first conditional.
>>
>>58341261
Your one looks better to mine >>58341264
>>
>>58340921
i would hire the fuck out of anyone with the balls to pull this off in an interview
>>
I have almost no knowledge of computer programming. I am full Pajeet. I tried to teach myself Python, and I gave up about halfway through the book I bought.

But for fuck's sake, even I can do this FizzBuzz shit. It might not be tidy, but it would get done and the output would all be correct.

So my question is: could I use my existing levels of programming skills to actually get a job? I assume the job will enhance my skills once I get it, so I only need a bottom-tier job. Is it possible?
>>
>>58341524
Python is shit, be glad you got out when you did
>>
>>58341457
I don't know if this would be a good idea.
Might be a red flag for 'clever code', which you absolutely do not want in a team effort.
>>
>>58341261

Stop making it so complicated.

if (i % 3 == 0 && i % 5 == 0)
print("Fizzbuzz");
else if (i % 3 == 0)
print("Fizz");
else if (i % 5 == 0)
print("Buzz");
else
print(i);


People care about whether it's correct. IIRC, Fizzbuzz is typically "from 1 to 100", which would make your first line wrong.
>>
>>58341457
I too would hire the fuck out of anyone who could do Search-and-Replace on a program written on a whiteboard
>>
>>58341524

No. Not without something to show.

Nobody is going to hire you because you can write Fizzbuzz. You have the logic backwards, Fizzbuzz is used to weed out the incompetent, not to find the competent.
>>
>>58341154
int third = 0; int fifth = 0;

for (int i = 1; i <= 100; i++) {
int thir = i / 3;
int fift = i / 5;

if (thir + fift > third + fifth) {
if (thir > third)
print "fizz";
if (fift > fifth)
print "buzz";
}
else {
print i;
}
print ",\n";
third = thir; fifth = fift;
}
>>
>>58340225
does he/she not though?
>>
>>58341589
>Fizzbuzz is typically "from 1 to 100", which would make your first line wrong.

Range in python starts with the first number, then goes up to (but not including) the second number.

It produces 1-100.
>>
>>58341641

That's fucking retarded. Inclusive on the low end, exclusive on the high end?

Good to know though.
>>
>>58332257
"Feel free to contradict me, but can we agree that there isn't such a thing as a B.S. in Design"
how out of touch can you even be
>>
>>58341524
I managed to bullshit my way into my current job and learned after the fact what I need to survive under pressure of being exposed.
It's not what I would advise though.
>>
>>58341524
At any decent company no, you'll just get fucked on the next stage
>>
>>58340966

Give it a print("\n".join(..)) and you're good to go.
>>
>>58341623
It's a pretty ugly workaround, and definitely not something people who are bad at math would think of

A prettier hack would be:

for(int i = 0; i <= 100; i++) {
if(i / 3 * 3 != i || i / 5 * 5 != i) {
if(i / 3 * 3 != i)
System.out.print("fizz");
if(i / 5 * 5 != i)
System.out.print("buzz");
System.out.println();
} else {
System.out.println(i);
}
}
>>
>>58341702
>Inclusive on the low end, exclusive on the high end?
C++ and C# follow the same logic in iterators and other collections related stuff.
>>
>>58341702
>That's fucking retarded.
It's consistent with programming languages and data structures in general. If you iterate over a collection, You go from 0 to size - 1, for instance (except for some idiotic ecosystems with 1-based indices). That's what Python is good at: being consistent.

Also, ranges in other languages work the same way by default, unless syntax allows explicit definition of inclusion/exclusion.

>>58341524
Start in technical support. Not the "have you tried turning it off an on again"-kind, but the "I'll show you how you fucked up at using our API"-kind. Work your way up from there. If your brain can take it, you'll eventually understand proper programming languages. If not, you'll have a cushy job appropriate to your skills.

Understanding FizzBuzz ist just about basic arithmetic skills anyway, as a previous anon has already pointed out.
>>
>>58341853
>It's consistent with programming languages and data structures in general. If you iterate over a collection, You go from 0 to size - 1, for instance (except for some idiotic ecosystems with 1-based indices). That's what Python is good at: being consistent.

Yeah, but as in the example, it goes from 1 to 100 (or 101). The language shouldn't be stepping in and saying, "hey, you know what, most of the time you end up putting a -1 at the end of your range, so lemme just step in here and fuck your shit up for you".

>anges in other languages work the same way by default, unless syntax allows explicit definition of inclusion/exclusion.

Eh? What languages assume inclusive on the low end and exclusive on the high end?
>>
#include <iostream>
using namespace std;

int main(){
for(int x=1; x<=100;++x){
if(x%3 !=0 && x%5 !=0)
cout << x << endl;
else{
if(x%3 == 0)
cout << "Fizz";
if(x%5 == 0)
cout << "Buzz";
cout << endl;
}
}
return 0;
}
>>
 IDENTIFICATION DIVISION.
PROGRAM-ID. FIZZ-BUZZ.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CT PIC 999 VALUE 1.
01 FZ PIC 999 VALUE 1.
01 BZ PIC 999 VALUE 1.
PROCEDURE DIVISION.
FIZZ-BUZZ-MAIN SECTION.
PERFORM 100 TIMES
IF FZ = 3
THEN IF BZ = 5
THEN DISPLAY "FizzBuzz"
COMPUTE BZ = 0
ELSE DISPLAY "Fizz"
END-IF
COMPUTE FZ = 0
ELSE IF BZ = 5
THEN DISPLAY "Buzz"
COMPUTE BZ = 0
ELSE
DISPLAY CT
END-IF
END-IF
ADD 1 TO CT
ADD 1 TO FZ
ADD 1 TO BZ
END-PERFORM
STOP RUN.
>>
>>58341895
D uses this with it's slice syntax
[0 .. $)
>>
>>58341942
>COBOL

blech.
>>
>>58341716
Wouldn't it be a B. A.?
>>
int fizz = 0;
int buzz = 0;
for(int i=1; i<=100; i++) {
fizz++;
buzz++;
if(fizz != 3 && buzz != 5) {
System.out.print(i);
} else {
if(fizz == 3) {
System.out.print("Fizz");
fizz = 0;
}
if(buzz == 5) {
System.out.print("Buzz");
buzz = 0;
}
}
System.out.println();
}
>>
>>58342007
>>58341154
>>
>>58341990
my college offered a B.S. in design. programs like that will usually integrate programming and development into it as well, because there's really no reason to have a designer who doesn't at least understand programming these days.
>>
>>58341895
>Yeah, but as in the example, it goes from 1 to 100 (or 101). The language shouldn't be stepping in and saying, "hey, you know what, most of the time you end up putting a -1 at the end of your range, so lemme just step in here and fuck your shit up for you".

I've been writing code for a living for years, and instances where the something - 1 assumption was false are rare, memorable events.

>Eh? What languages assume inclusive on the low end and exclusive on the high end?

In addition to the example by >>58341947 here's Ruby:

1...100


To be fair, Ruby also has the inclusive operator:

1..100


Also, the Golang slice syntax, working just like the Python sublist syntax, uses the first parameter as the start, and the second as excluded end.
>>
threes = {*range(3,100,3)}
fives = {*range(5,100,5)}
rest = {*range(100)}

fizzbuzz = threes & fives
fizz = threes - fives - fizzbuzz
buzz = fives - threes - fizzbuzz
concat = [[i, str(i)] for i in rest] + [[i, "fizz"] for i in fizz] + [[i, "buzz"] for i in buzz] + [[i, "fizzbuzz"] for i in fizzbuzz]
concat.sort(key=lambda x: x[0])

print("\n".join((i[1] for i in concat)))
>>
>>58340775
>'CS' is still floundering, unable to decide if it's mathematics or a technical school.

"CS" isn't floundering at all. The mathematics and theory guys picked the name "CS" a long time ago, and they totally own it.

Then, starting in the mid-90s, the internet exploded, and we suddenly had a huge demand for new skills like network technicians, web-page designers, and computer help-desk personnel.

At that point, two things conspired to muddle the perception of "CS" in the eyes of the general public:

(1) The education system was totally unprepared for the sudden creation of a new technical field overnight. Scrambling to accommodate it, they did the quickest thing they could think of -- they placed a new mandate on the CS department to expand into technical education. The new technical studies often carried the "CS" label, because it takes a lot of time to push the creation of a new department title through the molasses of the education bureaucracy.

(2) Very few people outside of CS have a clue what "CS" is. They assume that because it has the word "computer" in its name, then it must encompass anything dealing with computers. This resulted in a massive dumbing-down of what the terms "CS" and "programming" meant to the general public. For example, when most people's view of a "web programmer" is a person who crops photos and drag-and-drops them to create web pages -- then from that perspective, a person who knows how to type HTML code into Notepad starts to look like a programmer -- a hacker, even. The confused, befuddled masses have great strength in numbers, and if they want to start abusing terminology, they get the final say.

None of this caused CS to flounder. CS is just fine. The only thing that happened is that uninformed people started using the term "CS" in uninformed ways. That's their problem, not CS's.
>>
>>58332218
>>58332459
It's not only if you can do it, it's also how you do it. Your solution should agree with the company's views on code style, approach, optimization VS readability etc...
Its an easy way for them to see how much you'll have to learn/change until they can let you write code for them.

You forgot the entire loop. Omitting brackets is bad form according to many.
Same for a variable 'index'. Printf is not necessary here, though may be okay if its consistent with their code. Starting each printf with "\n" is weird if you don't join Fizz+Buzz anywhere.

Yes you can code your way out of a wet paper bag, and no they probably won't send you out inmediately for this. But be prepared to explain/defend your choices which really shows wether or not you know what you're doing.

Last time I remember that someone got to do this the follow up question was:
"Why or why not would you remove the third check (%3,%5,%3&%5)?"
A clear but detailed answer about standards, (compiler) optimization and readability was expected, though "just be consistent with existing code" was valued almost as much.
>>
>>58341947

How's that the case? $ just refers to the length. " .. $" just means "to the $th element".

>>58342069
>I've been writing code for a living for years,

Me too. Means nothing.

> and instances where the something - 1 assumption was false are rare, memorable events.

Good for you. I would *never* want a range to be INCLUSIVE on one end and EXCLUSIVE on the other. And every time I've ever iterated over a range, I want it to go to exactly the number I indicate, not some different number implied by the language.

> To be fair, Ruby also has the inclusive operator:

*eyeroll* so the standard range operator behaves the expected way, and the goofy, extended triple-dot behaves in the other, bizarre way. That's even worse than Python.

>Also, the Golang slice syntax, working just like the Python sublist syntax, uses the first parameter as the start, and the second as excluded end.

So, basically, only dumb hipster languages. I have no idea why people would want differing behavior on either end of a range, without mathematical-type range indicators ("]" vs ")").
>>
File: 1474840096841.jpg (33KB, 163x240px) Image search: [Google]
1474840096841.jpg
33KB, 163x240px
>>58342007
This is quite a convoluted solution, interesting though
>>
>>58332218
#include <stdio.h>
#define VALUE1
#define VALUE2

main()
{
if( VALUE1%3==0)
{
printf("Fizz");
}
elseif(VALUE2%5==0)
{
printf("Buzz");
}
}
>>
>>58340529
This is about as logically sound as 'Only a Sith deals in absolutes'.

KYS.
>>
>>58342116
>"CS" isn't floundering at all.

Okay, so I guess it's just a myth that everyone is discussing the ridiculous range in "CS" programs around the world. Good thing you were here to clear that up for us, anon.

>Then, starting in the mid-90s, the internet exploded, and we suddenly had a huge demand for new skills like network technicians, web-page designers, and computer help-desk personnel.

Oh bullshit. Network technicians have nothing to do with this and fucking help-desk? Are you kidding me?

>(1) The education system was totally unprepared for the sudden creation of a new technical field overnight.

No. The business side of software was already quite far along before the Internet came anywhere near the mainstream.

>None of this caused CS to flounder. CS is just fine.

No, it isn't. If that were the case, we wouldn't be regularly discussing whether or not CS is a subset of math, and what should or should not be in a CS program. There wasn't some mythical period where CS was a well-defined concept.
>>
File: imgres-9.jpg (5KB, 259x194px) Image search: [Google]
imgres-9.jpg
5KB, 259x194px
>>58342188
What the hell is this shit
>>
>>58334607
>Note that this solution does not work if you take numbers like 3 and 9
What?
>>
>>58342188
nvm didn't read the print condition
#include <stdio.h>

main()
{
int i;

for(i=0;i<101;i++)
{
if( VALUE1%3==0)
{
printf("Fizz");
}
elseif(VALUE2%5==0)
{
printf("Buzz");
}
else
{
printf("%d",i);
}
}
}
>>
>>58342373
this is horrible
>>
>>58342373
ffs
#include <stdio.h>

main()
{
int i;

for(i=0;i<101;i++)
{
if( i%3==0)
{
printf("Fizz");
}
elseif(i%5==0)
{
printf("Buzz");
}
else
{
printf("%d",i);
}
}
}
>>
File: 1474511810501.jpg (125KB, 1024x800px) Image search: [Google]
1474511810501.jpg
125KB, 1024x800px
So, what are criteria of true fizzbuzz?
How do I know if one passed the test?
>>
>>58342168
>Good for you. I would *never* want a range to be INCLUSIVE on one end and EXCLUSIVE on the other. And every time I've ever iterated over a range, I want it to go to exactly the number I indicate, not some different number implied by the language.

You're right. It's not intuitive to humans, but consistent with how zero-based indexing is always off by one. Once this is in someone's blood, it becomes natural.

>*eyeroll* so the standard range operator behaves the expected way, and the goofy, extended triple-dot behaves in the other, bizarre way. That's even worse than Python.

Can't argue with that. You got a point there.

>So, basically, only dumb hipster languages.

Python is place four on the TIOBE index, and one of the most taught programming languages. Too mainstream to be hipster.

Golang turns to be out one of the prime languages in a containerized environment, due to easy static linking with small resulting binaries, and an API that is akin to more high level languages despite its low level of operation. It's rise from 50 to 16 on the TIOBE index is not just a meme. Too mainstream to be hipster as well.

>I have no idea why people would want differing behavior on either end of a range, without mathematical-type range indicators ("]" vs ")").

I'd love to have mathematical syntax for ranges. Until one comes around that has them, and is mature and established enough to be actually used, I'll prefer to stick to weird ranges that are consistent almost across the board.
>>
>>58340529
>people who accuse other people of having dunning-kruger are the only people that actually have it

No, it's just the opposite. That's the remarkable thing about Dunning-Kruger -- a person who is under its effect is utterly incapable of understanding it.

People under the Dunning-Kruger effect don't have the ability to perceive incompetence in either themselves or others, because they don't have the knowledge to determine what it even means to be "competent".

It's one of those weird "concept-blindness" phenomena -- kind of like a paranoid person who becomes utterly incapable of understanding the concept of paranoia, either in himself or in others. Dunning-Kruger is similar, except that it pertains to the inability to perceive incompetence.
>>
>>58342216
>No, it isn't. If that were the case, we wouldn't be regularly discussing whether or not CS is a subset of math, and what should or should not be in a CS program. There wasn't some mythical period where CS was a well-defined concept.

That entire paragraph was quite a vivid demonstration of your complete ignorance about this.

CS professors know exactly what CS is. They're not "regularly discussing whether or not CS is a subset of math". That's what you and other uninformed people are doing.
>>
FizzBuzz is about inclusivity, people! Not about code!

Just check out https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition/issues/279
>>
>>58342575
wtf i hate javascript and C# now
>>
>>58342397
you watch them write it.
If they keep asking clarifying questions instead of writing code and sperging out about how they cannot do complicated math without google, then they fail.
>>
>>58342393
Is this a joke?
>>
>>58332218
The only language I know well enough to look pretty is Python. This is the most effective way
I can think of doing FizzBuzz:

for i in range(1,101):
fb = ''
if i % 3 == 0:
fb += 'Fizz'
if i % 5 == 0:
fb += 'Buzz'
print(fb or i)
>>
>>58342397
FizzBuzz is so common that anyone should know the algorithm off the top of their head. In their preferred language, they should write it out almost without thinking. In a new language, they should be able to hack together a solution pretty easily.

To me, a pass would be any working FizzBuzz script. Between two passes, the more efficient code is always better.
>>
>>58342843
>the algorithm
Disappointed in you
>>
Python:
for i in range(1, 101):
if i % 15 == 0: # Divisible by 3 and 5
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)


Rust:
fn main() {
for i in 1..101 {
match (i % 3, i % 5) {
(true, false) => println!("Fizz"),
(false, true) => println!("Buzz"),
(true, true) => println!("FizzBuzz"),
_ => println!("{}", i)
};
}
}
>>
>>58342843
>the more efficient code is always better

asm it is then
>>
>>58342921
No one is writing FizzBuzz from scratch. You memorized an algorithm. If you write the "best" solution immediately, you memorized the syntax. If you go with the if/elif/elif/else, you memorized the algorithm.

Don't kid yourself.
>>
>>58342953
see
>>58342795

Allows for quicker parameter changes, and seems more in line with the Python (shit) philosophy.
>>
>>58342998
Ah yes, the algorithm.
>create an infinite list of strings where every third is fizz
>create an infinite list of strings where every fifth is buzz
>do an indexed zip on these lists ...

You know the rest.
>>
>>58341773
#include <iostream>

int x = 1;

main()
{

while ( x <= 100 ) {
if ( x%3 != 0 );
std::cout << "hello" << std::endl;
x++;
}

}


plz send help
>>
>>58343039
If you want %15 to have neither fizz nor buzz, you have to do a lot more than if %15 got its own statement.
>>
>>58343127
I see the problem

>main()
>{

This should be:

>main() {
>>
>>58342843
>To me, a pass would be any working FizzBuzz script. Between two passes, the more efficient code is always better.

As an interviewer, the there is no second pass for me. I just care about the thinking when someone figures out the solution, syntax correct or not. It doesn't matter how proficient people are in specific programming languages as compared to the quality of their way of thinking. Assuming a workplace environment in which people are be able to learn and grow, existing knowledge has little weight compared to the way of how someone's mind works.

Given the right mind, everyone can learn anything. I'd always prefer someone with no expertise and a great aptitude for learning over someone with staggering industry experience, but not mental flexibility.
>>
fizzbuzz = lambda x: 'fizzbuzz' if x%15==0 else ('fizz' if x%3==0 else ('buzz' if x%5==0 else str(x)))
print('\n'.join([fizzbuzz(i) for i in range(1,100)]))
>>
>>58342998
Oh well, so
#include <studio.h>

int main(void) {
int i, j, k;
for(i = -2, j = -4, k = 1; k < 101; i++, j++, k++) {
if (!i) { printf("fizz"); i = -2; }
if (!j) { printf("buzz"); j = -4; }
if (i && j) printf("%d", k);
printf("\n");
}
return 0;
}

is fine?
>>
>>58343251
no no no, you copied the algorithm from yourself, therefore by that faggot logic you memorized it from yourself, but you did not write it yourself from scratch
>>
>>58343127
we lad sovled it

#include <iostream>

int x = 1;

main()

{

while ( x <= 100 ) {
if ( x%3 == 0 && x%5 == 0)
std::cout << "fizzbuzz" << std::endl;
else if ( x%5 == 0)
std::cout << "buzz" << std::endl;

else if ( x%3 == 0)
std::cout << "fizz" << std::endl;
x++;
}

}
>>
File: 1476139616538.jpg (145KB, 500x367px) Image search: [Google]
1476139616538.jpg
145KB, 500x367px
>>58343281
Thanks, gave me a laugh
>>
>>58343317
Is that coffee open source?
>>
>>58343347
Not only open source. It's also free.
>>
>>58342953
>dat rust

I like it, looks like my Perl.
>>
>>58343459
why would it be open source but not free?
anyone could take the source and brew it
>>
>>58343518
Open source means that you can read the source. Copyright restrictions apply.

Software freedom allows you to modify and share the source and binaries of it. Just being able to read the source does not allow you to do anything with it - an important licensing detail.
>>
#include <stdio.h>

int main() {
for (int i = 1; i < 101; i++) {
if (i%3==0)
printf("fizz\n");
if (i%5==0)
printf("buzz\n");
if (i%3==0 || i%5==0)
printf("fizzbuzz\n");
}
}


My pleb attempt I hope I did this right
>>
>>58343608
Fuck I realize I should've used <=100 instead <101 in my for loop
>>
File: 247b81248.png (155KB, 360x274px) Image search: [Google]
247b81248.png
155KB, 360x274px
>>58343608
almost
>>
>>58343518
that's not how it works. just because something is open source doesn't mean it's free you fucking retard. maybe the coffee beans were picked by child nigger slaves in kenya it's open source anyone can brew it but is it free?
>>
>>58343604
>>58343630
you're not allowed to compile an "open source" program?
>>
>>58343659
oh so you can look at the source code but only run a precompiled version of it? that's fucking stupid and what's stopping anyone from compiling their own version - a licensce? hwo would anyone know if i'm running an under the hood unlicensed version of it?
>>
>>58343608
Close. But the way it's written now any multiple of three or five will output "FizzFizzBuzz" or "BuzzFizzBuzz" respectively. There are two separate problems with your code that would cause that.
>>
>>58343659
It's about distribution, not compiling. Once you have purchased code of proprietary software, you are free to compile it. (Although, you will usually receive a binary instead of the source, unless it's *nix drivers or something).

>>58343683
Nothing's stopping anyone except for the license. That's why the term "open source" is almost exclusively used to describe free software - anything short of free software makes little sense to be open source.
>>
Daily FizzBuzz thread? Daily FizzBuzz thread.

print '\n'.join(["Fizz"*(n%3==0)+"Buzz"*(n%5==0) or str(n) for n in range(1,101)])
>>
>>58332257
>""""nitty gritty positioning details"""
>cant divide a number
>>
The amount of people using mod 3 and mod 5 instead of mod 15...
>>
as someone who has no programming experience and has read through this whole thread, I still don't get where to even start or how some are different "cleaner" than others

this shit looks like straight hieroglyphics to me

I wish I was a leet programmer fuckkk
>>
>>58342168

>so the standard range operator behaves the expected way, and the goofy, extended triple-dot behaves in the other, bizarre way.

What's your problem?
If you say "add the numbers from 1 to 100" you would add "1+2+..+99+100", right?

(1..100) . reduce(:+)


Now I want to exclude a number, what's the most intuitive way from (1..100)? One more dot: (1...100).

How is that "goofy"?


If you want the usual "for (i=0; i<100; i++)" loop, just take Ruby's times-operator:

100.times { puts "asshole" }


I dare you calling that "goofy", Ruby is the most beautiful language ever.

for i in (1..100)
puts (i%15).zero? ? "FizzBuzz":
(i%5).zero? ? "Fizz":
(i%3).zero? ? "Buzz":
i
end
>>
>>58336586
That's what comments are for, anon.
>>
>>58343900
>Now I want to exclude a number, what's the most intuitive way from (1..100)? One more dot: (1...100).

>How isthat "goofy"?

Ah yes, the "single dot of last element exclusion", I remember hearing about that in my maths textbook
>>
git gud nerds
#include <stdio.h>

#define FIZZ 3
#define BUZZ 5

int main(void) {
unsigned i = 1;
do {
if (!(i%FIZZ) || !(i%BUZZ)) {
if (!(i%FIZZ)) printf("Fizz");
if (!(i%BUZZ)) printf("Buzz");
putchar('\n');
} else printf("%d\n", i);
} while(i++ < 100);

return 0;
}
>>
>>58343900
>I dare you calling that "goofy", Ruby is the most beautiful language ever.

The legibility is poor, because two levels of nested conditions appear to be on the same level as the first one. Indentation could help, but using ternary statements - despite their compactness - rarely make a good program.
>>
>>58343881
read the problem and put it into a series of logical statements
>>
>>58339905

Is that cobol ?
>>
>>58338882
You have to go back Pajeet.
>>
>>58344068
It starts with C, so it must be C.
>>
IT'S SHOWTIME

HEY CHRISTMAS TREE isLessThan100
YOU SET US UP @NO PROBLEMO
HEY CHRISTMAS TREE n
YOU SET US UP 0
HEY CHRISTMAS TREE multiple
YOU SET US UP @NO PROBLEMO

STICK AROUND isLessThan100
GET TO THE CHOPPER n
HERE IS MY INVITATION n
GET UP 1
ENOUGH TALK

GET TO THE CHOPPER isLessThan100
HERE IS MY INVITATION 100
LET OFF SOME STEAM BENNET n
ENOUGH TALK

GET YOUR ASS TO MARS multiple
DO IT NOW divisible n 15
BECAUSE I'M GOING TO SAY PLEASE multiple
TALK TO THE HAND "FizzBuzz"
BULLSHIT
GET YOUR ASS TO MARS multiple
DO IT NOW divisible n 3
BECAUSE I'M GOING TO SAY PLEASE multiple
TALK TO THE HAND "Fizz"
BULLSHIT
GET YOUR ASS TO MARS multiple
DO IT NOW divisible n 5
BECAUSE I'M GOING TO SAY PLEASE multiple
TALK TO THE HAND "Buzz"
BULLSHIT
TALK TO THE HAND n
YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE NO RESPECT FOR LOGIC
CHILL

>>
>>58344098
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

LISTEN TO ME VERY CAREFULLY divisible
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 result
YOU SET US UP 0
GET YOUR ASS TO MARS result
DO IT NOW modulo dividend divisor

HEY CHRISTMAS TREE isZero
YOU SET US UP 0
GET TO THE CHOPPER isZero
HERE IS MY INVITATION result
YOU ARE NOT YOU YOU ARE ME 0
ENOUGH TALK

I'LL BE BACK isZero
HASTA LA VISTA, BABY
>>

#include <iostream>
#include <future>
#include <string>

int main()
{
auto ayy=[](int n){ auto result = std::to_string(n);if((n%3==0)&&(n%5==0))return std::string("FizzBuzz");else if(n%3==0)return std::string("Fizz");else if(n%5==0)return std::string("Buzz");return result;};

for(int wew=0;;){
std::cout << std::async(std::launch::async, ayy, ++wew).get() << std::endl;
if(wew == 100) return 0;
}
}


:^)
>>
>>58341819
>implying compiler won't optimize (i / x * x != i) to (i != i)
>>
>>58344126
>how to humor an interviewer
>>
>>58344291
lmao
>>
https://gist.github.com/david-christiansen/3660d5d45e9287c25a5e
>>
import asyncio

async def wew(lad):
await asyncio.sleep(lad/10000)
print(f"{'fizz' if not lad%3 else ''}{'buzz' if not lad%5 else ''}" or lad)


loop = asyncio.get_event_loop()

loop.run_until_complete(asyncio.gather(*(wew(i) for i in range(1, 101))))
loop.close()
>>
>>58343916

>Ah yes, the "single dot of last element exclusion", I remember hearing about that in my maths textbook

In math you would write: [1, 100]
But brackets are are already in use for Arrays (in every programming language I know), so in Ruby this would create an array with the numbers 1 and 100.

So you might think about using (1-9), but that would mean "1 minus 9". Or using (1, 9)? But the comma is used for multiple assignment in ruby:

a, b = Array(1..5).partition { |i| i.odd? } 


..gives you two arrays, a = [1, 3, 5] and b = [2, 4]


So if the comma is already in use, the dots are often used in texts to indicate that something (...) is missing. It's also fast to type.

Now why the last dot?
Just remember to include the first int and the three following:
(1..100) = [1] [.] [.] [100] <-- it includes the 100
(1...100) = [1] [.] [.] [.] 100 <-- On noes, no 100
>>
>>58344724
What the fuck is with all these fucking paragraphs?
I don't care about any of that

There is absolutely no fucking way you are convincing anyone that it is reasonable to think an extra . means excluding the last element
>>
>>58344745

Whatever, dude.

Just convert to Ruby already.


class Integer
def f() self%3==0 ? 'Fizz' : '' end
def b() self%5==0 ? 'Buzz' : '' end
def fb() (self.f + self.b)[/.+/] || self end
end

1.upto(100) {|i| p i.fb}
>>
>>58345022
That might actually be the most hideous code I've ever seen
>>
>>58345022
>>58345117
Seriously, I've just come back, and who the fuck thought this was a good idea?
>>
>>58345117

It's not beautiful, but it's cool.
I changed the Integer class and actually ask the objects if it's a "FizzBuzz". FizzBuzz tries to create a string of "fizz" and "buzz" and checks via RegEx if it's empty. If it's empty, it returns itself, other wise the string.

But hey, if you don't like it, maybe you prefer that one:

1.upto(100){|_|p'FizzBuzz'[_*_%3*4...8>>_**4%5][/.+/]||_}
>>
>>58341716
i kekd

there's plenty of BS in design...
>>
File: ruby developer.jpg (126KB, 1920x1080px) Image search: [Google]
ruby developer.jpg
126KB, 1920x1080px
>>58345305
It isn't cool either
>I changed the integer class
Why is integer a class, and why can you literally mutate fucking types?
>ask the objects if it's a "fizzbuzz"
Why are integers fucking objects?
>checks via RegEx if it's empty
Why are you using RegEx to check if something is empty?
>it returns itself
Why are you using fucking methods for anything, let alone integers?


Jesus Christ, what a stupid fucking language.
>>
Look ma, no divisiones, no modulos, 1 'ternary' if

function fillBuffer(buffer, step, bound, value)
index = step;
i=1;
while (index <= bound) do
if (value == nil) then buffer[index] = index else buffer[index] = value end
index = step * i;
i = i+1;

end
end

function fizzBuzz3(arg)

values = {};

fillBuffer(values,1, 100, nil);
fillBuffer(values,3, 100, 'fizz');
fillBuffer(values,5, 100, 'buzz');
fillBuffer(values,15, 100, 'fizzbuzz');

for i=1, 100 do
print(values[i]);
end
end
>>
>>58339905
>he didn't number every line
>he didn't write own formats
>he just write(*,*)
wee
>>
>>58334848
What happened with you?
>>
>>58345412
>Why is integer a class
ask java
>>
File: ruby irl.png (266KB, 339x589px) Image search: [Google]
ruby irl.png
266KB, 339x589px
>>58345685
>my shitty fucking language is based on this other shitty fucking language
gee wizz batman
>>
>>58345412

>Why is integer a class, and why can you literally mutate fucking types?
>Why are integers fucking objects?

Fucking magic, man.
Fucking magic.

In scripting languages you want to do this kind of things.


>Why are you using RegEx to check if something is empty?

It has to do with the "faulthyness" of string. In Python or JS empty string get evaluated to false. In Ruby, empty string are True (more logical, since an empty string is '\0' in C).

So I have to use an regex to grab all symbols or return "Nil" (the Null-object in Ruby), so I can use the ||-operator:

"return Nil || 1" returns 1.


>Why are you using fucking methods for anything, let alone integers?

Because in Ruby everything is an object.
>>
>>58345744
>magic
IT'S FUCKING STUPID
EXTREMELY STUPID

>everything is an object
explains the retards, it's an OOPs language
>>
>>58333262
i started sales now i'm an EE systems tech. feels good man
>>
>>58345685

The funny thing is, Java is super complicated because "int" is a "native type" and "Integer" is a class.

This can fuck you badly if you make a map that takes Intergers as key, because "my_map.get(3)" gives you a different result as "my_map.get( (Integer) 3)".. Thanks to methods you can overwrite, you either get the 3rd element or the element for the key "3".. Bravo!!

Thank god in Scala they really made every int an object, like in Ruby. So much easier.

>>58345412
>>58345724

Le funny ebin pictures..
XDDDD

Here's to you (without a regex, this time):
1.upto(100){|i|puts'FizzBuzz '[n=i**4%-15,n+13]||i}
>>
>>58345915
>Thank god in Scala they really made every int an object, like in Ruby. So much easier.
How about just not having fucking OO for the children who can't live without it?
>>
using System;
using System.Linq;

namespace FizzBuzz
{
class Program
{
static void Main(string[] args)
{
Func<int, string>[] values = {i => i + "", i => "Fizz", i => "Buzz", i => "FizzBuzz"};
var fizzBuzz = Enumerable.Repeat(0, 100)
.Select((x, i) => x + Math.Sin(3886233.05311717 * i + 3886234.09321357))
.Select((x, i) => x + Math.Sin(3319323.02253289 * i + 3319324.77764699))
.Select((x, i) => x + Math.Sin(517102.382386617 * i + 517104.106333962))
.Select((x, i) => 0.7 * x + 1.2)
.Select((x, i) => values[(int) x](i + 1));
Console.WriteLine(String.Join("\n", fizzBuzz));
Console.ReadKey();
}
}
}
>>
File: Saviour.jpg (329KB, 561x750px) Image search: [Google]
Saviour.jpg
329KB, 561x750px
>>58345947
apologise
>>
File: Matz.jpg (810KB, 1893x2430px) Image search: [Google]
Matz.jpg
810KB, 1893x2430px
>>58345766

>it's an OOPs language

It's THE OOP language.
It's OOP done right.

It also has lambdas:

fizzbuzz = ->(i) do
(i%15).zero? and next "FizzBuzz"
(i%3).zero? and next "Fizz"
(i%5).zero? and next "Buzz"
i
end

puts (1..100).map(&fizzbuzz).join("\n")



You can even use arcane Scheme magick CallCC:

require 'continuation' unless defined? Continuation

if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100

case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end

puts
c[c, i + 1]
end
>>
>>58346048
>It's OOP done right.
No, OOP done right is OOP not done.
>>
>>58334250
her complaint is that she was being interviewed for a programming job when the job description was for a UX person
>>
>>58346086
wtf I want to use function pointers to implement inheritance now
>>
>>58346086

>hurr, there is only one right paradigm
>implying languages aren't just tools and you pick the one that is appropriate for the task


I guess I should have expected that in a fizzbuzz thread..
Keep on NEETing.

require "socket"

n = 0
webserver = TCPServer.new('localhost', 2000)

while (session = webserver.accept)
n += 1
session.print("#{n}: #{fb(n)}")
session.close
end

def fb(number)
return 'Fizzbuzz' if number % 15 == 0
return 'Buzz' if number % 5 == 0
return 'Fizz' if number % 3 == 0
number
end
>>
>>58346183
>inheritance
dont do this
>>
>>58346248
wtf I want to duplicate code now
>>
>>58346275
>inheritance is the only way to avoid duplicating code
try learning to program
>>
>>58345412
Just because it's appalling doesn't mean it's not cool. It's like watching those videos of people climbing cranes without harnesses. It's dumb and scary, but also really neat.
>>
>>58346506
>Just because it's appalling doesn't mean it's not cool.
This sounds like something a tranny would say while doing something completely and utterly fucking degenerate.

You have literally made a fetish out of bad programming.
>>
>>58345117
MFW on every Ruby code base l call `Integer.freeze` first thing.
>>
>>58339984
>enterprise software
>open source
>not an exe file in rar archive on a 90-s webpage
>>
>>58346530
>politicizing a programming joke

You don't sound like a pleasant person. People probably view talking to you IRL as a chore.
>>
>>58332431
>>58332313

>shit an optimizer can figure out

Plz kill yourselves
>>
>>58340921
Ever programmed COBOL? It feels just like this.
>>
#include <stdio.h>

int main() {
unsigned int i;
for (i = 1; i <= 100; i++) {
if (i%3!=0 && i%5!=0)
printf("%d\n", i);
if (i%3==0)
printf("fizz\n");
if (i%5==0)
printf("buzz\n");
if (i%3==0 && i%5==0)
printf("fizzbuzz\n");
}
}

revised but still shit
>>
>>58332218
i am learning python recently maybe 2 weeks into it half way thru "How to think like a computer scientist: learning with python 3" so am i elite yet or should i just kill myself?
for i in range(1,101):
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
>>
>>58347657

>I have to use an optimizer for fizzbuzz

kill yourself and your family
>>
>>58334625
>>58334625
That's lacking full understanding, proper form, and efficiency.

HERE:

10 DEFINT I
20 DEFINT X
30 FOR I = 1 TO 100
40 X = STR$(I)
50 IF I / 15 = I \ 15 THEN X = "FIZZBUZZ"
60 IF I / 5 = I \ 5 THEN X = "BUZZ"
70 IF I / 3 = I \ 3 THEN X = "FIZZ"
80 PRINT X
90 NEXT I
>>
Anybody got a solution in Haskell? I'm phoneposting on the shitter and I was trying to hack together a solution but I'm not getting there.
>>
>>58339963
It might have to do with the general math problem we have.
Every other subject (except maybe geography and occasionally history) has it proponents and its detractors and is generally respected overall.
Math class though? With math class it's, Fuck you teacher, fuck you for trying to make me learn this shit, fuck you for *ever* trying to make me learn this shit, I don't use it and you're a bitch.
>>
>>58339905
>>58344068
Fortran my man
the C and the spaces are a big clue, but you know it's Fortran because of the .EQ.
>>
softwareonly babbies are not human beings tbqh
>>
>>58342116
>(2) Very few people outside of CS have a clue what "CS" is. They assume that because it has the word "computer" in its name, then it must encompass anything dealing with computers.
I had some fun with this a few weeks ago with a guy that thinks too highly of himself. He said repeatedly that since he was a geologist he knew every science except medical science. I shit you not, he graduated with a degree in geology and is working in the field, and he made this claim forcefully. I said that doesn't encompass everything, so he said "oh yeah like what?" and I told him computer science. He said "bullshit, I work with computers all the time".

you know, come to think of it, he's originally from India... bah
>>
>>58342216
>There wasn't some mythical period where CS was a well-defined concept.
bullshit, the term "computer science" first appeared in the early 20th century, before there were any computers
>>
>>58340614
you don't actually need a modulo operator
when I was first introduced to fizzbuzz I didn't remember that operator existing so I did
if i / 3 == floor(i/3) { printf("fizz"); }

and so on
you do kind of need to know about one or the other though, or some method of getting at the remainder, which is actually skipped over in the basics a lot because people just learning usually don't give a shit about the math abilities of a language
>>
>>58346048
A FUCKING BLANKET?
that's an award from these people?
what in the actual ever-living fuck
that is too much autism, that is not fucking cool, how did this happen?
>>
>>58340554

Hell no.

I've done one math class in my degree, with another close. The math class was more concerned with the mathematics behind 3D representations on a 2D plane, matrices etc. I don't know where this would really be used unless you're building a game engine from scratch, for we typically had to use a library supplied. The sort-of math class was a first year subject going over (I kid you not) basic maths (from addition to very basic algebra) and some logic.

A quarter of my subjects were intro to language X. A further quarter assumed knowledge of a language and built on it, mostly in a group environment to 'build something'. Not a teaching environment. I did one subject in c++ which covered trees and other abstract ideas very briefly, but the assignment work was building a balanced tree over 3~ months, other assignment was a traveling salesman type. You're taught ideas of things that exist, not the full fledged implementation, because for so many, there already exist libraries you could use.

My degree was a CS: Bach Info Tech (majoring in software development) (Australia). Even I think it wasn't teaching me much, I wouldn't 4 years after my course be able to pass some these interviews. I don't code for fun at home, I just did the course work. And without the internet, being able to research and look up questions, I wouldn't have passed. I don't think we're adequately taught for work placement, we have fleeting experience with ideas and limited/focused hands on.
>>
>>58332218
We hired someone who did well on FizzBuzz and she was an absolute shit developer, couldn't do anything, spent all day watching videos.
>>
>>58345870
nobody fucking cares
>>
>>58349073
Jesus fucking christ
>>
>>58347981
This is a good and proper FizzBuzz, nice job. Use code tags next time you post code here though.
>>
>>58349235

Our CS, isn't CS. It's 'Here's some languages. Use them a few times, do some group work where you use existing libraries and produce a thing. Now graduate.'

I'm more interested in lower level stuff, but the lowest I got was using C on some ASM hardware. No actual understanding of how it worked, but 'read/reference this 200 page document, for this particular atmega32u', and use it in conjunction with the supplied hardware diagram to interact with peripherals (buttons, leds, lcd) on each pin. A more fun class, but still way over my head in more respects because I'm not a EE.

It's all about going out there and googling what library you need and how to implement it for the current problem. Even I don't think the degree should have the CS label. We never touched anything below C, and that class wasn't core to the degree, that was an elective.
>>
Don't fall for the meme. NO software dev interviews ask you to fizz buzz. Never happened to me or any of my friends. Obviously they already expect you to know it. Actually nvm, If you're a feminist or minority they'll ask you to fizz buzz and if you are close enough they'll hire you strictly for diversity purposes and to shut up the leftists who cry "racist" and "sexist" every minute.
>>
public class FizzBuzz {
int value;
public FizzBuzz(int i) { this.value = i; }
public static void main(String[] args) {
FizzBuzz fizzBuzz = new FizzBuzz(0);
for(int i=1; i<=100; i++) {
fizzBuzz.setValue(i);
System.out.println( fizzBuzz );
}
}

public void setValue(int value) {
this.value = value;
}

@Override
public String toString() {
boolean multFive = ( this.value % 5 == 0);
boolean multThree = ( this.value % 3 == 0);
if( multFive && multThree ) return "FizzBuzz";
if( multFive) return "Buzz";
if( multThree) return "Fizz";
return String.valueOf(this.value);
}
}
>>
>>58349142
thats why you start out with fizzbuzz to filter out the retards then make them implement something harder like an obscure graph data structure or whatever
>>
>>58342629

How many in the work place know that kind of thing off the top of their head (without having worked/studied in a related field for years)? Constant exposure is needed for this kind of long term memory, if you're not getting that I can understand people wanting the very tools you'll have available to provide assistance. I'd rather employ someone able to do research and learn, than someone whose done their exact/crammed homework for passing a single test.

I guess I'm comparing the wrong kind of interview example there. It's mostly assuming someone who is just passing a degree (and who may not have done that kind of thing in months or years), against someone currently working in the field.
>>
>>58340700
uhh if you're getting paid then how exactly are you 'just being taken advantage of'?
>>
>>58349628
>instance class
fired
>>
>>58349890
You prefer something more "functional" ?
object FizzBuzz {
def main(args: Array[String]): Unit = {
for (i <- 1 to 100) {
if ( i % 3 == 0 && i% 5 == 0)
println(i +" = FizzBuzz")
else if (i % 3 == 0)
println(i +" = Fizz")
else if (i % 5 == 0)
println(i +" = Buzz")
else
println(i)
}
}
}
>>
>>58349903
>writing println out 4 times instead of storing the string in a variable and println'ing once at the end because it's always used anyway
fired
>>
>>58349941
What about that ?
object FizzBuzz {
def main(args: Array[String]): Unit = {
println((1 until 100).map(fizzBuzz).mkString(", "))
}

def fizzBuzz(x:Int) = {
if (x % 15 == 0)
"FizzBuzz"
else if (x % 3 == 0)
"Fizz"
else if (x % 5 == 0)
"Buzz"
else
x
}
}
>>
At least put effort into documentation and readability.

 
/******************************************************************************
@author anon
@file fizzbuzz.cpp
@verion 170105
@brief C++11 Source code file for solving the FizzBuzz problem.

@info The "Fizz-Buzz test" is an interview question designed to help filter out
the 99.5% of programming job candidates who can't seem to program their way out
of a wet paper bag. The text of the programming assignment is as follows:
"Write a program that prints the numbers from 1 to 100. But for multiples of
three print “Fizz” instead of the number and for the multiples of five print
“Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”""

compiled using this command in linux
clang++ -std=c++11 -Wall -Wextra -pedantic fizzbuzz.cpp
******************************************************************************/

#include <iostream>

int main()
{
// Loop to print Fizz, Buzz, or FizzBuzz
for(int i = 1; i <= 100; ++i)
{
if ( !( i % 15 )) { std::cout << "FizzBuzz" << std::endl; }
else if( !( i % 3 )) { std::cout << "Fizz" << std::endl; }
else if( !( i % 5 )) { std::cout << "Buzz" << std::endl; }
else { std::cout << i << std::endl; }
} /* loop */

return EXIT_SUCCESS;

} /* main() */
>>
int i;
const char* buf[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
for(i = 1; i < 101; ++i)
printf(buf[!(i%3)|(!(i%5)*2)], i);
return 0;
>>
>>58350051

doesnt hurt, im too lazy to do that, but would so in an interview
>>
Scala

for (i <- 1 to 100) {
(i % 3, i % 5) match {
case (0, 0) => println("FizzBuzz")
case (0, _) => println("Fizz")
case (_, 0) => println("Buzz")
case _ => println(i)
}
}


or

(1 to 100).map(i => (i % 3, i % 5) match {
case (0, 0) => "FizzBuzz"
case (0, _) => "Fizz"
case (_, 0) => "Buzz"
case _ => i
}).foreach(println)
[
>>
>>58352015
First one is classy as fuck
>>
>>58347566
>politicising
How's that political?
You literally said something was fucked up and therefore cool.
>>
>>58352015

I have to say, its's pretty hard to find something that you DON'T have in Ruby, but I do like the underscore of functional languages like Scala or Erlang..
Best copy I could come up with:

for i in (1..100)
puts case [i%3, i%5].join
when /00/ then "FizzBuzz"
when /0./ then "Fizz"
when /.0/ then "Buzz"
else i
end
end


or

(1..100).each do |i| 
case [i%3, i%5].join
when /00/ then puts "FizzBuzz"
when /0./ then puts "Fizz"
when /.0/ then puts "Buzz"
else puts i
end
end.each(&method(:puts))



Language tiers (in terms of cool syntax):

1. Ruby
2. Scala
3. Haskell
4. C#
5. C
>>
>>58352700
>1. ruby
>2. scala
???

>no Ada
???
>>
OP if you really care about getting hired in a big firm you should solve ACM ICPC problems.
Oh wait that rules out 99.9% of /g/.
>>
>>58352700

FUCK, I messed up the second version..
;__;

(1..100).map do |i| case [i%3, i%5].join
when /00/ then "FizzBuzz"
when /0./ then "Fizz"
when /.0/ then "Buzz"
else i
end
end.each(&method(:puts))



>>58352709

Sorry, I don't know about Ada. Is it good?

Post a cool FizzBuzz, that's what these threads are for..
>>
>>58340921
kek
>>
>>58332218
I'm not a programmer and I know your solution is shit. You only need two conditions.
>>
>>58347981
First line could be swapped with

if i%15==0


Other than that, you're hired.
>>
>>58332767
print(*((lambda x=x: 'FizzBuzz\n' if x % 15 == 0 else 'Fizz\n' if x % 3 == 0 else 'Buzz\n' if x % 5 == 0 else str(x) + '\n')() for x in range(1, 101)))
>>
function fizzBuzz4()
third=1;
fifth=1;

for i=1, 100 do
str=""
if (third ~= 3 and fifth ~=5) then str = str..i
else
if (third == 3) then str=str..'fizz' third = 0 end
if (fifth == 5) then str=str..'buzz' fifth = 0 end
end

print(str);
third = third + 1
fifth = fifth + 1
end
end
>>
>>58352709

Holy shit, I looked up Ada and it looks like "old school Ruby". Check this out:

ADA:
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;

procedure Fizzbuzz is
begin
for i in 1 .. 100 loop
if i mod 3 = 0 and then i mod 5 = 0 then
Put("FizzBuzz");
elsif i mod 3 = 0 then
Put("Fizz");
elsif i mod 5 = 0 then
Put("Buzz");
else
Put(i);
end if;
New_Line;
end loop;
end Fizzbuzz;



Ruby:
Fizzbuzz = 
begin
for i in (1..100)
if i % 3 == 0 and i % 5 == 0 then
puts("FizzBuzz");
elsif i % 3 == 0 then
puts("Fizz");
elsif i % 5 == 0 then
puts("Buzz");
else
puts(i);
end
end
end



The Ruby creator of it was doing langauge research at university, so he just mixed every langauge he liked into Ruby. Apparently Ada was among them..

Oh well, done enough Ruby shilling for one day.
See you tomorrow.
>>
File: 1457564040508.png (393KB, 611x607px) Image search: [Google]
1457564040508.png
393KB, 611x607px
>>58340614
I think her problem was that she never wrote any code from scratch, rather just "rightclick - inspect element", fuck with the numbers, see what looks good, insert into code, repeat.

If something fancy is requested, copy and paste from Stack Overflow.
>>
File: so.jpg (271KB, 1560x2048px) Image search: [Google]
so.jpg
271KB, 1560x2048px
>>58353218
>>
Superior C++11 version coming through

#include <iostream>
#include <map>
#include <vector>

void fizzbuzz(std::map<int, std::string> &fbmap, int n, std::vector<std::string (*)(int, int, std::string)> &funvec);
std::string fizzbuzzwoofhelper(int num, int cond, std::string str);

void fizzbuzz(std::map<int, std::string> &fbmap, int n, std::vector<std::string (*)(int, int, std::string)> &funvec)
{
using namespace std;
string str = "";
for (int i = 1; i <= n; i++) {
for (auto j : fbmap) {
str += (i % j.first == 0) ? j.second : "";
for (auto k : funvec) {
str += (*k)(i, j.first, j.second);
}
}
cout << (str != "" ? str : to_string(i)) << endl;
str = "";
}
}

std::string fizzbuzzwoofhelper(int num, int cond, std::string str)
{
using namespace std;
string numstr = to_string(num);
string condstr = to_string(cond);
string newstr = "";
size_t pos = numstr.find(condstr, 0);
while (pos != string::npos) {
newstr += str;
pos = numstr.find(condstr, pos + 1);
}
return newstr;
}

int main(int argc, const char *argv[])
{
using namespace std;
map <int, string> fbmap;
vector <string (*)(int, int, string)> funvec = {};

cout << "FizzBuzz" << "\n" << "--------" << "\n";

fbmap = {{3, "Fizz"}, {5, "Buzz"}};
fizzbuzz(fbmap, 100, funvec);

cout << "\n";
cout << "FizzBuzzWoof" << "\n" << "------------" << "\n";

funvec = {fizzbuzzwoofhelper};
fbmap = {{3, "Fizz"}, {5, "Buzz"}, {7, "Woof"}};
fizzbuzz(fbmap, 100, funvec);

return 0;
}


fizz and buzz, 3 and 5 are not hardcoded and with a function pointer vector you can pass more conditions to implement FizzBuzzWoof
>https://en.wikipedia.org/wiki/Fizz_buzz#Fizz_Buzz_Woof
>>
File: 1458848624284.png (9KB, 383x276px) Image search: [Google]
1458848624284.png
9KB, 383x276px
>>58340614
Front-end JavaScript hipster schmuck here (with bonus points for being a self taught college drop out.)

All of the competent front end people I know are aware of modulo, and I expect anyone I hire to know of it too. It does come up in the wild more often than youd think (eg, make every n element different in x way.)

That aside, it's about craftsmanship. If you care about the quality of your work and take the time to study and improve your skills, you will come across the modulo operator. If you take a basic JS tutorial, you will learn it.

Can you be good without knowing it? Sure, probably. But that's not a risk I'm going to take. Otherwise, I'd hire pajeet for a fraction of the price and call it a day.
>>
for i in range(1, 101): print([i, "fizz", "buzz", "fizzbuzz"][2*not(i%3)+not(i%5)])


>fizzbuzz thread
>310 replies
we did it guys!
>>
>>58353985

Y-you too..
>>
>>58353811
>superior
>compiles with warnings

fizzbuzzwoof.cpp:48:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, const char *argv[])
^
fizzbuzzwoof.cpp:48:32: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, const char *argv[])
^
2 warnings generated.
>>
>>58354837
Fine, sorry for forgetting to remove the unused argc, argv and having one pair of unneeded braces...
>>
>>58332218

i1[Esc]qqyyp[Ctrl]+aq98@qkqqVcFizz[Esc]3kq32@q4jqqVcBuzz[Esc]5jq19@q10kbiFizz[Esc]qqyy15kVpq4@q
>>
>>58355229

WTF, where are the linebreaks?

i1[Esc]
qq
yy
p
[Ctrl]+a
q
98@q
k
qq
VcFizz[Esc]
3k
q
32@q
4j
qq
VcBuzz[Esc]
5jq
19@q
10k
biFizz[Esc]
qq
yy
15k
Vp
q
4@q
Thread posts: 317
Thread images: 21


[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.