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

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

Thread replies: 139
Thread images: 7
File: whispering.jpg (100 KB, 500x384) Image search: [Google]
whispering.jpg
100 KB, 500x384
Are you able to write fizzbuzz from memory only?
>>
>>54700153
>memory only
So, like... actually capable of basic programming?
>>
>>54700153
FizzBuzz is used so frequently that every script kiddie has seen its source code a dozen times.

Can you write a program that stores minutes and seconds in a single integer?
>>
I've never bothered to actually look what fizzbuzz was, i expected it would be something complicated
>>
for(int i = 0; i < 100; System.out.println(i++ % 3 == 0 ? i % 5 == 0 ? "Fizz" + "Buzz": "Fizz" : i % 5 == 0 ? "Buzz" : i));
>>
>>54700423
best one
>>
what do you mean "from memory"?

like not asking to clarify what fizzbuzz is? the parameters are simple - who could need a reminder? just print the number unless it's divisible by 3 (in that case "fizz") or by 5 (in that case "buzz") or by both 3 and 5 ("fizzbuzz"). this is like asking if i know how to unlock my apartment door from memory; you use the key. if you need further explanation then you have bigger problems.

if you mean "from memory" as in without checking reference documentation for the language of choice, then... sure? how hard is it to pick a pretty intuitive language and just write a for loop with some if checks? like i understand maybe it'd be hard if you chose a language you weren't familiar with, but...

this question is stupid. OP, are you stupid? do you need to ask questions like these?
>>
Everyone but op gets it. It's not about rote memorization. Fizzbuzz is elementary branching covering four cases. If you have to memorize a solution for that, you shouldn't be working yet.
>>
>>54700153
You are probably the kind of retard who cant do multiplication without memorizing the answer.
>>
>>54700472
What are you talking about? FizzBuzz is one of the most complicated open problems of the field. We don't even have analytical answers, only approximations.

I have been working on my own implementation of it for nearly 6 years and the algorithm still fucks up a few times. So, if you ""solved"" it quickly you're probably not grasping the problem.
>>
>>54700578
hey buddy your keyboard is broken - it repeats quotation marks
>>
I don't get the whole fizzbuzz thing on /g/. Every new programmer can solve this task easily, even without having seen any solution or variant of it before. It's extremely easy -- is it just a dumb meme?
>>
<code>
while (num <= 99){
num = num + 1;

if ((num % 3 == 0) && (num % 5 == 0)){

System.out.println("FizzBuzz");

}else if (num % 3 == 0 ) {
System.out.println("Fizz");

}else if (num % 5 == 0){
System.out.println("Buzz");

}else
System.out.println(num);

}

}

}

</code>
>>
>>54700163
>So, like... actually capable of potato programming?
ftfy
>>
>>54700659
https://www.google.com/search?q=fizzbuzz
wikipedia should be one of the first results. it's widely known as a generic programming test. a lot more people fail it than you'd think.

i don't buy the argument that that proportion of CS graduates can't think, but i do buy the argument that that proportion of CS graduates choke in a socially uncomfortable setting like an interview. in-person programming tests are an awful way to determine programming competence. there's no aspect of it that's representative of the real work.

two alternatives that would be better are obvious (and we use the first when we interview undergrads for internships)
1) talk about a bug or error you had in some code recently, and walk through how you resolved it. (alternatively, just send us some code you've worked on lately, and ballpark estimate the time you spent writing it)
2) here's a thing we dealt with recently. take it home and work on it if you can. send us your fix and give us a ballpark of how long it took.

people are surprisingly honest about estimating past effectiveness. maybe they're afraid of exaggerating and being expected to deliver 2x or 3x as much code as they're able. we use the first option a lot because reflecting on past experience gives them an opportunity to recall the process they used to solve a problem, and that's far far FAR more informative than their ability to remember ternary operators and whatnot. also, if they can't (or won't) get very technical in the explanation of what the problem was, that tends to be a good indicator that they didn't really grok the error, and sort of just worked around it. and seeing past code (e.g. a github repo) is just nice because it gives a much more longitudinal view. but i try not to evaluate anyone on their github activity until they point me there. my public profile view looks shitty as well (mostly because most of my code is private), so who am i to judge given that i don't necessarily have the whole picture?
>>
>>54700153
for i in range(1,101):
print("FizzBuzz"[i*i%3*4:8--i**4%5] or i)

find a better FizzBuzz than this
profile: you can't
>>
>>54700153
fizzbuzz

did i do it?
>>
>>54700423
>post increment
you fucked up
>>
>>54700163
too true. kek
>>
>>54700578
got a good laugh out of that one, thanks
>>
>>54700578

Lost. Github link plz
>>
>>54700198
In my phone, but store with
int time = minutes | (hours << 8)

And read with
int minutes = time & 0xFF
int hours = (time & (0xFF << 8)) >> 8
>>
>>54700153
fieebyee
>>
>>54700198
i could but it would look weird. wouldn't a string be better to store that?
>>
I don't get what you mean. Surely you'd just do
seconds + (minutes * 60)
?
>>
>>54701290
apologies for trip
>>
>>54701266
drugs or braindamage?
>>
>>54701290
Right, now make a function that returns the minutes and a function that returns the seconds from the combined integer.
>>
>>54701342
not him, but

var now = DateTime.Now;

var secs = now.Second;
var mins = now.Minute;

var tot = secs + (mins * 60);

Console.WriteLine("Untouched: {0}, Total: {1}, Min: {2}, Sec: {3}", now.ToString(), tot, (int)(tot/60), tot % 60);

>>Untouched: 23-May-16 14:34:09, Total: 2049, Min: 34, Sec: 9
>>
x=cellstr(int2str((1:100)'));
x(3:3:end)=cellstr('Fizz');
x(5:5:end)=cellstr('Buzz');
x(15:15:end)=cellstr('FizzBuzz');
fprintf('%s\n',x{:});
>>
>>54701366
You got it.
>>
>>54701332
dain bramage?
>>
>>54701342
function combine_time(seconds, minutes) {
return seconds + (minutes * 60);
}

function extract_minutes(time) {
return floor(time / 60);
}

function extract_seconds(time) {
return time - (floor(time/60) * 60)
}
>>
>>54701219
>0xFF << 8
...
>>
>>54701781
It will be probably optimized by the compiler, but write 0xFF00 if you want to.
>>
>>54700198
union  { struct { int hours:8; int minutes:8} s int stamp;} time =   {.s.hours=13, .s.minutes = 37};
//printf("Time is %d:%d, timestamp is %d", time.s.hours, time.s.minutes, time.stamp);


Using bitwise is boring.
>>
>>54700877
print('\n'.join(["FizzBuzz"[i*i%3*4:8--i**4%5] or str(i) for i in range(1,101)]))
>>
_=$=+!![];$__=((_$={})+'')[_+$+_+$+_];__$=((![])+'')[$];_$_=((_$={})+'')
[_+$+_+$+_+$];____=[][$__+((_$={})+'')[$]+(($)/(![])+'')[$]+$__+__$+_$_];$__$=(!![]+"")
[$+$+$]+([][(![]+"")[$+$+$]+(+[]+{})[$+$]+(!![]+"")[$]+(!![]+"")[+[]]]+"")[($+$)+""+
($+$+$)]+(![]+"")[$]+(![]+"")[$+$];$_$_=____()[$-$][$__$]("\"\\"+($)+($+$+$+$+$+$+$)+
($+$)+"\"");_$=(![]+'')[$-$]+([][[]]+[])[$+$+$+$+$]+$_$_+$_$_;$_=(_+{})[$+$+$]+(!![]+'')
[_+$]+$_$_+$_$_;_--,$$=$+$;____()[$-$][$__$]((![]+"")[+[]]+(+[]+{})[$+$]+(!![]+"")[$]+
"(;++_;)$$$=!(_%("+($$+$$+$)+")),____()[+[]][__$+((![])+'')["+($+$)+"]+((!![])+'')["+
($+$+$)+"]+((!![])+'')[+!![]]+_$_](!(_%("+($$+$)+"))?$$$?_$+$_:_$:$$$?$_:_);");

javascript
>>
File: 1433745038526.png (97 KB, 192x255) Image search: [Google]
1433745038526.png
97 KB, 192x255
>>54703631
>>
>>54700153
I dream of fizzbuzz.

Sometimes when I wake all of the computers in the house are running fizzbuzz. Even the androids.
>>
>>54700642
I have a special key that adds double quotation marks, it is very useful when arguing here.

>>54701210
Just look up 'computing with positronic brains fizzbuzz' to find my paper.
>>
>>54700198
Name 1 (one) scenario where it would be reasonable to do that
>>
>>54700198
I know this post is old as fuck but I want to make sure I'm not retarded.

>Store minutes and seconds in a single integer
You just store seconds and when reading the number for display you format it correctly by dividing by 60 for minutes and formating the remainder for seconds.
Is the point that it's a trick question?
Like are idiots supposed to respond by merging two integers (minutes and seconds) with a token into a string then parsing the string using the token when reading it?
>>
>>54706871
Name a scenario where FizzBuzz would be reasonable
>>
>>54703631
Beautiful but it doesn't work

>
Uncaught TypeError: Array.prototype.concat called on null or undefined(…)
>>
>>54706946
Every programming job interview
>>
>>54700874
It's a small problem that looks like it can be solved in a pretty elegant way but it's silly to actually try.

I've seen many people make the program write "fizz" then "buzz" then go "ok now how do I make it write them both in the same line when it's needed" so then they make a variable which holds the text that must be written and they change the value of the variable around depending on the case and it goes to shit from then on.

I wonder if the success rate of the problem would change if instead of "fizz" "buzz" "fizzbuzz" it was something like "blue" "red" "yellow"
>>
File: Screenshot-2015-07-01-15.40.41.png (300 KB, 637x371) Image search: [Google]
Screenshot-2015-07-01-15.40.41.png
300 KB, 637x371
>>54700198
>write a program that stores minutes and seconds in a single integer
>how do timestamps work
>>
File: fizzbuzz of the christ.png (402 KB, 1024x768) Image search: [Google]
fizzbuzz of the christ.png
402 KB, 1024x768
>>54700153
Yes, but only because I praise Jesus everyday
>>
>>54700388
not really. Between 1 and 100 - if it divides by 3, Fizz, if it divides by 5 - Buzz. if both, both.
>>
>>54700153
#include <stdio.h>

int main(void){
int i;
for( i = 0; i < 100; i++ ){
if( i % 15 == 0 )
puts("FIZZBUZZ");
else if( i % 5 == 0 )
puts("FIZZ")
else if( i % 3 == 0 )
puts("BUZZ")
else
printf("%d\n", i);
}

return 0;
}

>>
>>54700153
for (var i=1; i<=100; i++) {
if (i % 3 === 0 && i % 5 === 0) {
console.log("FizzBuzz");}
else if (i % 3) {
console.log("Fizz");}
else if(i % 5) {
console.log("Buzz");}
else {
console.log(i);}
};
>>
btw, if you have a CS degree and can't write fizzbuzz without the google in at least one language, then you are literally worthless.
>>
#include <stdio.h>
#include <stdlib.h>

#define FIZZBUZZ_CASE(term) case term: printf("FizzBuzz"); break
#define FIZZ_CASE(term) case term: printf("Fizz"); break
#define BUZZ_CASE(term) case term: printf("Buzz"); break
#define EMPTY_CASE(term) case term:
#define NORMAL_CASE(term) case term: printf("%d", i); break

int main(void)
{
int i;
for (i = 1; i <= 100; i++)
{
int j = i;
while (j - 15 >= 0) j = j - 15;

switch (j)
{
FIZZBUZZ_CASE(0);
EMPTY_CASE(1);
NORMAL_CASE(2);
FIZZ_CASE(3);
NORMAL_CASE(4);
BUZZ_CASE(5);
FIZZ_CASE(6);
EMPTY_CASE(7);
NORMAL_CASE(8);
FIZZ_CASE(9);
BUZZ_CASE(10);
NORMAL_CASE(11);
FIZZ_CASE(12);
EMPTY_CASE(13);
NORMAL_CASE(14);
}
printf("\n");
}

return 0;
}
>>
>>54700153
been working with Lua lately so let's use that
while true do
i = i + 1
fb = nil
if i / 3 == math.floor(i / 3) then
outstat = "f"
end
if i / 5 == math.floor(i / 5) then
outstat = outstat + "b"
end
if outstat == "f" then
print("fizz\n")
elseif outstat == "b" then
print("buzz\n")
elseif outstat == "fb" then
print("fizzbuzz\n")
else
print(i, "\n")
end
end

I know I didn't use % or MOD, I can't remember if Lua has those or in what form
>>
>>54707410
I really hope I never have the 'pleasure' of working with somebody like you.
>>
>>54700198
static int a(byte min, byte sec) {
return (min << 8) | sec;
}

static int[] b(ushort a) {
return new int[] { a << 8, a & 0xFF };
}
>>
>>54707512
sorry,
static int a(byte min, byte sec) {
return (min << 8) | sec;
}

static int[] b(ushort a) {
return new int[] { a << 8, a & 0xFF };
}
>>
>>54701266
Not hard, use an unsigned integer, the last six bits are used for seconds and the rest of the bits are used for minutes. Add one to the integer ever second, and Once the last six bits reaches 59 seconds add one to the next bit and set those six bits to zero. Reverse engineer to display correctly
>>
>>54700198
<<time 10 x ip>>

Fucking easier than shit dude.
>>
>>54700153


fizz = int % 3 == 0;
buzz = int % 5 == 0;

for int in range(1,101)
if int == fizz:
print ('fizz')
elif int == buzz:
print ('buzz')
elif int == fizz & buzz
print ('fizzbuzz')
else:
print (int)



Probably something like this. It might be ugly and long, however it's readable and simple.
>>
File: 1444269394264.jpg (116 KB, 544x708) Image search: [Google]
1444269394264.jpg
116 KB, 544x708
>Lurk /g/ because I'm sick and bored
>Not a programmer, not even close
>Dick around with AVR microcontrollers for fun and lua for gaymin scripts
>See this thread
>Look up what fizzbuzz is

Holy fuck. There are people who went to school for this that can't write a simple loop, or swap two variables without using a third temporary variable.

I think I am starting to understand the reason why so many graduates are crying about how they can't get a job.
>>
>>54707419
bah, meant to rename "fb" to "outstat"
>>
>>54700153
I can write self-learning fizzbuzz in TensorFlow http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
>>
>>54707927
>http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
what the fuck man.
>>
>>54708087
>how to humiliate the interviewer with your deep learning skills
>>
>>54708106
I guess it's because i don't know how neural networks work, but i can't make sense of what the fuck went on.
>>
>>54708135
It's half meme half truth, but he applied a simple multilayer perceptron to learn which numbers should map to fizz, buzz or fizzbuzz. Machine Learning: when you have a hammer everything looks like a nail.
>>
>>54707882
Learning to snap together Java and Python is what Computer Science is now.

Also you will be expected to take a labless digital logic course that's suitable for third graders from the 1980s (see Robot Odyssey).
>>
I actually had a fizz buzz test for an interview and I did it wrong. I put the 'and' clause after the two ifs. I blame it on nerves, but, really, I'm just a retard.
>>
>>54701342
int minutes(int time) {
return minutes / 60;
}

int seconds(int time) {
return time;
}
>>
>>54700153
Better to be able to write merge sort or realloc from memory.
>>
>>54701290
Careful: Leap seconds just fucked you in the ass.
>>
>>54706871
job interview
>>
>>54700153
>from memory
so you can't actually figure it out for yourself?
OP, never stop being such a titanic faggot, don't you dare to stop surrendering your ass to random famalams while doing so.
>>
its the only thing I can do from memory only
>>
define a function called "fizzbuzz". fizzbuzz shall work as follows:
start counting a number "x" from 1 to 100.
if x is divisible by 3 and 5, then say "fizzbuzz". Otherwise,
if x is divisible by 3, then say "fizz". Otherwise,
if x is divisible by 5, then say "buzz". Otherwise,
say the value of x.


>>
>>54700153
Yes

for(var i = 1; i <= 100; i++) console.log(i % 15 ? (i % 5 ? (i % 3 ? i : "fizz") : "buzz") : "fizzbuzz");

Hit F12 and enter it into your friendly local javascript console.

<3 ternary operators
>>
>>54700153
>programming from memory
kek, okay kids.
>>
>>54710808
What language is this?
>>
>>54711552
English.
>>
>>54711552
Fag#
>>
>>54711192
>i%15
code discarded
>>
>>54711192
Hold the phoneeeee

I thought if the condition is true, it executes the statement following the question mark, not the colon. What am I not understanding?
>>
No, because I can't remember the retarded game.
I can solve it, but I don't remember what the "problem" is.
>>
>>54711696
i % 3 is true when i isn't divisible by 3
>>
File: 1446094157719.jpg (236 KB, 1000x1000) Image search: [Google]
1446094157719.jpg
236 KB, 1000x1000
>>54700153
I never knew what fizz buzz was and I always just ignored these type of threads. Just looked it up today and did it within 5 minutes. The fact that some people can't do this immediately is pathetic and I haven't even started my CS courses yet.
>>
>>54711916
b-but math is scary... :(
>>
/* fizzbuzz in C */
#include <stdio.h>
int main(void)
{
int i;
for(i = 1; i <=100; i++)
if(!(i % 15)){
printf("fizzbuzz\n");
}
else if(!(i % 5)){
printf("buzz\n");
}
else if(!(i % 3)){
printf("fizz\n");
}
else{
printf("%d\n", i);
}
return 0;
}
>>
>>54711916
It's designed to be a very quick way to eliminate the people who just don't know how to program very early in the interview process.
>>
>>54712027
Honestly why would you try to get a job programming if you can't program. Wouldn't someone find out pretty fast?
>>
>>54712050
yeah, but this isn't true of a lot of industries/jobs and some people think software is the same way

you can BS your way into a lot of fields and people won't find out for weeks.
>>
>>54711844
Oh Jesus Christ. I had a lapse there. Forgot i % 15 == 0 == false when it's divisible by 15.
>>
print('1,2,Fizz,4,Buzz,Fizz,7,8,Fizz,Buzz,11,Fizz,13,14,FizzBuzz,16,17,Fizz,19,Buzz,Fizz,...');
>>
>>54703631
How dare you insult Javascript? The most Beautiful and Practical of languages?
>>
File: ohnomysunnyd.jpg (88 KB, 620x620) Image search: [Google]
ohnomysunnyd.jpg
88 KB, 620x620
>>54713699
>>
>>54700198
unsigned int seconds 50000;

unsigned int
to_minutes (unsigned int sec) {
unsigned int mins;
while ( sec-->60) mins++;
return mins;
}

same for hours desu~!
>>
wow this thread makes me feel good about myself. I thought I sucked at programming.
>>
>>54700153
I know the concept
do a for loop
each time you add 1 check if modulus by 3 or 5 = 0
if it does for 3, fizz
if it does for 5, buzz
if it does for both, fizzbuzz
end the for loop at 100
>>
>>54700153
>fizzbuzz
https://www.youtube.com/watch?v=OX5TM3q-JQg

I JUST LEARN FROM PAJEET OP!
>>
print('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('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');
>>
>>54700153
from fizz import buzz
import {fizz,buzz} as * from fizzbuzz with(buzz){ fizz; }

let tree : binary = new &{mut::std};

class gibJob__pls {
public static int main void virtual final(argc**, argv=2);

{

let binary tree.invert() -> true

};

// this is a comment

};


thank mr curle
>>
>>54706714
https://kryptonradio.com/2013/07/17/darpa-working-on-sentient-robots-with-positronic-robot-brains/
are you a darpa
>>
>>54701188

>imblying there is any difference for intrinsic types
>>
I can't program anything except html and simple bash scripts
fizzbuzz is lost on me
>>
>>54700423
disgusting
>>
Yes. I have seen these shit threads enough that I have memorized about 15 different ways.
>>
Somebody write one that abuses C++ template metaprogramming.

Oh, nm, it's already done:

#include <iostream>
#include <string>

template <int r> struct FizzBuzzPrinter {
static const int fizzBuzzed = 0;
template <typename T> FizzBuzzPrinter(T t) {}
};

template <> struct FizzBuzzPrinter<0> {
static const int fizzBuzzed = 1;
template <typename T> FizzBuzzPrinter(T t) {
std::cout << t;
}
};

template <int N> struct FizzBuzz: FizzBuzz<N - 1> {
FizzBuzz() {
FizzBuzzPrinter<(N % 15)>("FizzBuzz");
FizzBuzzPrinter<(N % 5) + FizzBuzzPrinter<N % 15>::fizzBuzzed>("Buzz");
FizzBuzzPrinter<(N % 3) + FizzBuzzPrinter<(N % 15)>::fizzBuzzed + FizzBuzzPrinter<(N % 5) + FizzBuzzPrinter<N % 15>::fizzBuzzed>::fizzBuzzed>("Fizz");
FizzBuzzPrinter<FizzBuzzPrinter<N % 3>::fizzBuzzed + FizzBuzzPrinter<N % 5>::fizzBuzzed>(int(N));
std::cout << std::endl;
}
};

template <> struct FizzBuzz<0> {};

int main (int argc, char **argv)
{
FizzBuzz<100> p;
return 0;
}


That's still not fucky enough for my liking. I want some (retarded) cleverness to do away with the modulus arithmetic.
>>
>>54700198
Yeah, Unix time.
>>
>>54714322
i'm_not_even_mad.jpg

Seriously, you're hired.
>>
you're not supposed to memorize how to write programs

you're supposed to memorize how to write programs, and then from that be able to write anything that comes to mind, including fizzbuz

if you need to recall specifics in non-special circumstances, or if you need to look up how to do non library things, you need to keep learning
>>
>>54714362

All I did was copy the first Google search result.

But hey, thanks, when do I start?
>>
Let's move on to a different interview question that I, personally, think is utterly retarded.

You're working on a platform that only has a Stack class. Implement a Queue class. On this platform, you cannot use arrays or allocate memory blocks.
>>
>>54714534
Create a FIFO queue with just stacks?

Create two stacks
Push items into first stack
Pop from first stack and push into second stack
Pop from second stack to output

Probably a retarded method but thats what I came up with off the top of my head.
>>
>>54707403
That sad thing is, I probably know some people who wouldn't be able to accomplish that task.
>>
>>54714584
Yeah this is what I came up with, as well. Before seeing your post, of course.
>>
>>54714322
Here's a Java Enterprise Edition, same level of retardness.

https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
>>54707410
I like you.

Also, are you a wizard?
>>
>>54714584

Yep, sounds like the correct answer. IMO it's a retarded interview question, but whatever.
>>
>>54714622

Dude, I graduated alongside a fucking idiot who literally did not understand variable assignment.

int flags = SOME_DEFAULT_FLAGS;
flags = SOME_OTHER_FLAG;
// why doesn't flags == SOME_DEFAULT_FLAGS anymore?!


I'm not even lying. He was on my fucking "thesis" team. He contributed jack shit, I had to rewrite everything he did. He was so bad that my other teammate and I went to the head of the program to complain that he'd be granted a degree equal to ours.
>>
>>54708194

I didn't take any digital logic course for my degree, lab or not.
>>
iota(1, 21).map!(i => i.predSwitch!"a % b == 0"(15, "FizzBuzz", 5, "Buzz", 3, "Fizz", i.to!string));
>>
        for (int i = 1; i <= 100; i++) {
String value = "";

if (i % 3 == 0)
value += "Fizz";
if (i % 5 == 0)
value += "Buzz";
if (value.isEmpty())
value += i;

System.out.println(value);
}
>>
>>54700198
>Can you write a program that stores minutes and seconds in a single integer?
minutes * 64 + seconds

To convert back, perform the divmod 64 (or just take the lower 6 bits).
>>
ez pz

    #include <stdio.h>
#include <stdlib.h>

#define FIZZBUZZ_CASE(term) case term: printf("FizzBuzz"); break
#define FIZZ_CASE(term) case term: printf("Fizz"); break
#define BUZZ_CASE(term) case term: printf("Buzz"); break
#define EMPTY_CASE(term) case term:
#define NORMAL_CASE(term) case term: printf("%d", i); break

int main(void)
{
int i;
for (i = 1; i <= 100; i++)
{
int j = i;
while (j - 15 >= 0) j = j - 15;

switch (j)
{
FIZZBUZZ_CASE(0);
EMPTY_CASE(1);
NORMAL_CASE(2);
FIZZ_CASE(3);
NORMAL_CASE(4);
BUZZ_CASE(5);
FIZZ_CASE(6);
EMPTY_CASE(7);
NORMAL_CASE(8);
FIZZ_CASE(9);
BUZZ_CASE(10);
NORMAL_CASE(11);
FIZZ_CASE(12);
EMPTY_CASE(13);
NORMAL_CASE(14);
}
printf("\n");
}

return 0;
}
>>
>>54700153
>fizzbuzz
Here's another good one that throws off all non-programmers:

Write a function
int pow(int x, int y)
that raises x to the nonnegative power y. You may ignore integer overflows as a result of doing so.
>>
>>54700659
yes it is a dumb meme
Literally any programmer who has made more than one program can do it
>>
>>54700773
kek use square brackets for
>>
>>54707410
Please leave
>>
>>54717038

Would you be expecting the programmers to provide an O(logy) solution or an O(y) one? Like, really.
>>
>>54717172
I'm not necessarily expecting anything as much as I just want to see what kind of code they would write for this problem.

In my experience, most “programmers” will write code that doesn't even produce the correct answer, no matter the runtime.

The problem is also ambiguous enough to let them get away with choosing any language they want to and then writing code in that language, which allows me to see how well their coding style matches up to that language's typical style / strengths / weaknesses. (For example, if they give me a solution that will stack overflow)
>>
>>54717239

How would you view a naive loop vs a recursive O(logn) exponentiation?
>>
>>54717038
If you don't care for optimization that's a simple for-loop. That's even easier than Fizzbuzz.
>>
>>54700198
sure
int[] x = {min, sec};

spoiler                                                                                                                                                                                                                                                                                                                                                            :^)
>>
>>54717278
I think the latter is much more interesting than the former, since it demonstrates both an understanding of basic exponent mathematics and also a familiarity to use recursion. Furthermore, this is a situation in which recursion is almost surely more beneficial than harmful no matter what language.

>>54717340
It's just as easy as fizzbuzz for programmers, and just as hard as fizzbuzz for “programmers”.

You wouldn't believe the amount of people who screw this up. From basic shit like getting the loop bounds or edge cases wrong, to stuff like writing x *= x in their naive loop (without realizing that this will repeatedly square x).
>>
>>54700153
memory is useless until you allocate it
>>
>>54703631
What the fuck am I looking at
>>
>>54717362
>using the smiley with a carat nose
Thread replies: 139
Thread images: 7

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

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