You DID pass the FizzBuzz test, right Anon?
You DID pass the FizzBuzz test, right Anon?
Falling into your wing while paragliding is called 'gift wrapping' and turns you into a dirt torpedo pic.twitter.com/oQFKsVISkI
— Mental Videos (@MentalVids) March 15, 2023
I did fizzbuzz with a hashmap and I used to work in sales
>I did fizzbuzz with a hashmap
Christ
>I used to work in sales
It shows
You're saying that as if it isn't completely fucking retarded.
int feezbooz(int N) {
struct RetardedMap {
std::array<const char*, 16> cock;
RetardedMap() {
for (int i = 1; i < 15; i++) cock[i] = "n";
cock[0] = cock[15] = "FeezBoozn";
cock[3] = cock[6] = cock[9] = cock[12] = "Feezn";
cock[5] = cock[10] = "Boozn";
}
const char* operator[](int idx) const {
return cock[(idx + (idx / 15)) & 15];
}
};
static RetardedMap cox;
for (int i = 0; i < N; ++i) {
std::cout << i << ": " << cox[i];
}
}
I don't see how that's retarded, it seems perfectly modular and scalable
You can just index with `idx % 15`, and then your array will only need to be 15 elements instead of 16.
Have we forgotten the importance of code that is robust?
Nope. I just used my Chad interpersonal skills to get (and retain) my job.
being non autistic is literally life of easy mode
I could never
You can't do FizzBuzz on C? Ngmi.
I can do the % 3 == 0 version and the switch version but I can't figure out the hashtable (correct) version in C
Just count two numbers, one for fizz and one for buzz.
Put this in a loop that adds 1 to fizz and buzz for each lap.
if(buzz = 5){printf(%d, buzz); buzz = 0;}
>Used = instead of ==
It's so fucking over for me holy shit.
Nawwww cuz during the interview they're gonna ask "how could you make this better and more modular and scalable and as a microservice situaaaation"
I can even do without if or switch in C.
Pic related is without if and switch.
Why did you make it a 4 by 8 char matrix?
It should be 4x9, in fact, since fizzbuzz+ is 9 letters. But it was so that I could have one position of the matrix for number, fizz, buzz and fizzbuzz. I need also to be able to access and write its address, so I couldn't use a char *fbz[4] or char **fbz.
Is there computation comparable to the cost of a fews 'if's being called when using that printf syntax?
I have no idea. I mostly did that to check how a non-if/switch version in C could be done.
Fair.
What does ! do to operations inside brackets?
Oh it converts zero to True which is then interpreted as 1.
Pretty slick bru
It's the not operator.
If i is divisible by 3, i % 3 == 0, so !(i % 3) == 1.
This way I can restrict the sum:
!(i % 3) + !(i % 5) * 2 to [0,3].
If i is divisible by 3 and 5:
!0 + !0 * 2 = 1 + 1*2 = 3.
If i is divisible by 5:
!2 + !1 * 2 = 0 + 2 = 2[In C, 0 is false and any other number is true]
If i is divisible by 3:
!0 + !3 * 2 = 1 + 0 * 2 = 1
If i is not divisible by 3 or 5:
!i + !i * 2 = 0 + 0 * 0 = 0.
1337
Nice.
fbz should be const char *fbz[] = {...}
oh wait i noticed the sprintf part.
yeah it's retarded
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
char ** fizzBuzz(int n, int* returnSize){
*returnSize = n;
char ** answer = malloc(sizeof(*answer) * n);
char * buffer = malloc(n * 9);
uint32_t bits = 0x30490610;
for (int i = 0; i < n; i++) {
char* p = buffer + i * 9;
switch (bits & 0x3) {
case 0x3:
strcpy(p, "FizzBuzz");
break;
case 0x2:
strcpy(p, "Buzz");
break;
case 0x1:
strcpy(p, "Fizz");
break;
case 0x0:
sprintf(p, "%d", i + 1);
break;
}
answer[i] = p;
bits = bits >> 2 | bits << 28;
}
return answer;
}
>Camelcasing
Unironically hang yourself Javanagger.
the function definition is from leetcode
I don't give a fuck, you don't code c with camelCased variables. You use the underscore like a fucking white man.
Meant for
i dont think you understand, i did not write the function definition
this is what you are given:
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
char ** fizzBuzz(int n, int* returnSize){
}
the function definition is from leetcode, i am not leetcode, i did not write the function definition
I don't care. Don't fucking dare to share any C code with fucking camelCased variables again. It's a sin to do so.
i dont care lol, i will probably do it again
take care
People like you is why the world is a dark, cold place.
Next time you do it, be aware that a kitten dies.
printf("%dn", 12345 / 17);
uint64_t uhOh = 0x7878788;
printf("%dn", uhOh * 12345 >> 31);
You have a problem with quickInverseSquareRoot(float number)
float Q_rsqrt( float number )
>he said anonymously, to a group of unimpressed strangers
char ** fizzBuzz(int n, int* returnSize){
*returnSize = n;
nagger what is this? n is the amount of numbers printed as a function parameter and returnSize is also the amount of numbers printed but as an output?
Pretty much all C versions of leetcode problems have *returnSize, no matter how blatantly obvious it is what the size of the returned array will be.
>being a woman is life on easy mode
>being handsome is life on easy mode
>simply not having autism is life on easy mode
I think everyone else is living life on normal mode, and ugly autistic men are just living life on hard mode, which makes sense.
>too autistic to fit into normal society
>not autistic enough to be a savant coder
it's over
>being normal is easy mode
the more letter combinations you have the easier it gets, nagger
>letter combinations
what did he mean by this?
This. I've gotten myself hired off of charisma alone before, and I'm still intelligent despite what autists claim about "normalfags" and "autistic savantry". Autism is a mental illness that should eventually be cured, not cherished.
Give a single reason why companies shouldn't only hire autists.
Bullshit, that's simply isn't possible.
Its not just the soft skills. The the hoard of fresh grads who like to talk about architecture, system design, load balancers, autoscaling, nosql, constexpr, new language features, allocators, FPGAs, ergonomic API design, etc. but can barely write code or debug problems.
They are excited about graph databases but have barely ever written an sql query. Hyped to solve hardware cache false sharing problems but miss computation that can be memoized. They know a lot of interesting things lack the experience to put all this know-how into any use. And their lack of the basics means that they will struggle to accrue enough trust to work on these things.
But they can damn sure put on a show when you are talking with them for a short period.
fookin hate them graphdb wankers m8 i swear
saved
>FPGAs
You can't build anything non-trivial on an FPGA without basic programming ability. In fact I've seen programmers struggle hard with the inherent concurrency of HDLs.
```
for i in range(100):
print("".join(filter(None, [i % 3 == 0 and 'Fizz', i % 5 == 0 and 'Buzz'])) or i)
```
FML
for i in range(100):
print("".join(filter(None, [i % 3 == 0 and 'Fizz', i % 5 == 0 and 'Buzz'])) or i)
I joined a startup when it was 30 people, it was an email, into a phone call, into a single interview, into an on site test where I had to develop a small page using the technology I was going to be working with, using the API I was going to use, into being hired.
Least homosexual Perl5 dev.
>ignores his pic
oh anon...
My point is that this guy being the least faggy makes every other perl dev a homosexual of similar or supperior caliber.
You lack wit.
There's nothing wrong with perl.
Honestly was much easier to script in linux with perl than with bash scripts for me.
Apparently has security issues though. Not familiar with how though.
Why are you going to Hacker News? We have our own:
This. Got my current job by not doing the code interview, instead saying:
>i won't code for free
>AOL
I genuinely can't tell if there really are people applying for dev positions that can't do simple thing as fizzbuzz or if it's some meme.
Compsci is one of the most oversaturated fields, if you truly are good it's a field day cause it's full of idiots.
As problems go, it shouldn't filter anyone as it is very well known and trivial. It filters lots of people, and they're all people who should be filtered.
sir, something must've went wrong when you pasted that text, I only see mojibake
import math
for number in [1, 100]:
if number / 3 == round(number/3):
print("Fizz")
if number / 5 == round(number/5):
print("Buzz")
if number == round(number):
print(number)
Holy bloat
And it's also wrong, it will print the number, even in the case were it also print fizz, buzz or fizzbuzz
It's way more bugged than you think.
array = list(range(0,101))
numbers = [3,5,15]
words = ['fizz','buzz','fizzbuzz']
for num in numbers:
for i in range(num,101,num):
array[i] = words[numbers.index(num)]
for element in array:
print(element)
Was harder to do fizzbuzz with Python than with c++ for me.
>list(range(0,101))
nice instant memory bloat
Yep.
The power of python.
That's your problem with that code?
I'm ashamed of that code, I have an array addiction.
Am pleb.
#!/usr/bin/perl
print join(" ", 1..100) =~ s{
(?= (?<fizz> (?&div_3*~~?
(?= (?<buzz> (?&div_5*~~?
d+
(?(DEFINE)
(?<div_5> b d* [05] b )
(?<div_3> b
(?: [0369]+
| [147] (?&div_3)? (?: [258] | [147] (?&div_3)? [147])
| [258] (?&div_3)? (?: [147] | [258] (?&div_3)? [258]))
(?&div_3)?
b
)
)
}{
(defined $+{fizz} && "fizz") . (defined $+{buzz} && "buzz") || $&
}gxer, "n"
This was used in prod less than 15 years ago? Shit man
What would be the 'soft-skill' equivalent of fizzbuzz?
Maintaining eye contact with a woman
There's no way "fizzbuzz" is a real word. You're all nuts
>fizzbuzz test
How is this even real? It's a problem you give on first day of school maybe.
During an interview for my first job out of college at a small company, a dev walked into the interview room and interrupted the nontechnical manager conducting the interview and asked me to do fizzbuzz. I thought it was a joke but I did easily it and he seemed really relieved and explained that >90% of their applicants who had claimed to have years of programming experience couldn't actually code at all and they kept finding out after the applicant had tricked the manager into hiring them.
I haven't even done a single course on programming and I can do this.
Jesus Christ.
Literally me, I can learn quick and interview well so I tend to be good at getting and retaining jobs. But I'm always incompetent for the role at the point of being interviewed, I can catch up later though in most cases.
>Those people get by on the job by taking a really long time to get things done, but have great excuse masking skills, so they keep their job
Literally me. It takes me two sprints to finish a couple of 2 point tickets, yet my manager is super happy with me and says I exceeded expectations
def fizz(x):
if x % 15 == 0:
print "FizzBuzz"
elif x % 5 == 0:
print "Buzz"
elif x % 3 == 0:
print "Fizz"
else:
print x
def buzz():
for (100) i:
fizz(i+1)
buzz()
That's not python, what is that?
https://sourcegraph.com/search?q=context%3Aglobal+%22for+%28100%29+i%3A%22&patternType=regexp&case=yes&sm=1&groupBy=repo
https://github.com/aardappel/lobster
thank you for linking how you found it anon.
Probably lua if not python
Rate,
Failed. You left in unused imports, which indicates you're lazy and not a good worker.
It's future-proofing.
Failed because you don't understand YAGNI.
thoughts? concerns?
>testing for fizzbuzz and then fizz and then buzz
That's your concern? Not the fact that I started at zero?
`to_string(i)` needs to allocate a new `string` for every `i` even though `cout` could encode integers to strings more efficiently if you gave it `i` directly.
>even though `cout` could encode integers to strings more efficiently
even though `cout` could encode integers to the stream more efficiently (*)
This fizzbuzz is a meme for shit programmers to make them feel good.
There is no such thing as programmer that can't do fizzbuzz, even after they are told the operator to calculate remainder from division.
You just want to believe in such shit, because you need to believe that there are such shit coders and at least you are not that shit.
You are shit. Stop spreading the fizzbuzz meme.
Cope
I brought my own code and they hired me
Your friendly reminder that the general populace is leagues more retarded than you would think.
(defn timecode->seconds [timecode]
(let [strings (str/split timecode #":")
[hours minutes seconds] (map edn/read-string strings)]
(+ (* 3600 hours)
(* 60 minutes)
seconds*~~
(timecode->seconds "11:22:33")
import Data.List.Split (splitOn)
timecodeToSeconds :: String -> Maybe Int
timecodeToSeconds = toSeconds . map read . splitOn ":"
where toSeconds [hh, mm, ss] = Just (hh * 3600 + mm * 60 + ss)
toSeconds _ = Nothing
I'm a beginner in Haskell, how did I do?
sub timecode_to_sec {
$_[0] =~ /^(d+):(d+):(d+)$/
&& $1*3600 + $2*60 + $3
}
say timecode_to_sec "11:22:33"
They're called wahmen
i feel bad for these ppl bc what they don't realize is that competent programmers can learn everything this person knows and more, probably quicker too. you can push yourself to grow but you probably can't match the pace of some better programmers. it's fine though because even for less competent ppl there are roles (for now)
in Jelly this is just
3µ3,5ḍTị“¡Ṭ4“Ụp»ȯ)G
CompSci, and software development in general, should be illegal for people with an IQ south of 120. It's absolutely insane that there are actual university graduates who can't do FizzBuzz. In fact, you should be barred from having anything to do with software if you can't do it on your FIRST DAY after some light familiarization with the syntax and control structures.
it depends what the meaning of "fizz" is
He sounds like he's describing the average Indian programmer
for x in y:
if x % 3 == 0: print fizz
if x % 5 == 0: print buzz
println
my very first interview for a internship, I was given a fizzbuzz equivalent problem but a bit harder. so given a time like 10:41, using only any of the digits, can reuse any digit, find the next earliest time, can roll over to next day. so for 10:41 answer is 11:00. 23:59 is 22:22. got rejected though cus the guy thought I was there for the 16 month internship my uni had for co op and not the 4 month summer I applied for lol. the rejection didnt say this but at the beginning I confirmed it was a 4 month role and he said it was 16 month.
>so for 10:41 answer is 11:00
i think it's 10:44
no wonder you didn't get the job
this makes no sense at all
It actually does. Read it again as if you're retarded.
>23:59 is 22:22
Or, you know, 2:22
Depends if 2:22 is meant to be formatted with a 0 so 02:22
your English is really bad
nobody ever asked me fizzbizz, it's a made up problem by nerds
It was made up as a very simple problem that potential hires would't have memorized, to filter out those who can't code at all.
fizzbuzz is fucking useless, it just shows you know how to write a for loop. Even then the person may not be able to apply their knowledge in other more complex applications. How can so many people not do it? They must just not know how to code at all.
that's kind of the point of it being an interview question
>They must just not know how to code at all.
Correct. It's to weed out people who can sell themselves and copy answers from stack overflow but lack even rudimentary knowledge of coding.
I thought these people just go to Product Management type roles like the chicks who post tiktoks of them 'working in tech'? Are they really getting hired as devs?
array = [1, 2, 'fizz', 4, 'buzz', 'fizz', 7, 8, 'fizz', 'buzz', 11, 'fizz', 13, 14, 'fizzbuzz']
n=0
loop() {
for nig in array
if int(nig), print nig+n
else, print nig
rof
n=n+15
loop()}
loop()
>the above is not code
Fizzbuzz is the easiest thing to code, it's just 2 for loops and if statements, it's so simple even a toddler can do it
Toddler here. 1 loop and 1 if statement.
array = [1, 2, 'fizz', 4, 'buzz', 'fizz', 7, 8, 'fizz', 'buzz', 11, 'fizz', 13, 14, 'fizzbuzz']
n=0
>for nig in array, add n+nig if is_int(nig), print nig
>n=n+15
>repeat forever
Anyone who can't do fizzbuzz is an NPC. I could've probably done fizzbuzz when I was 12 if someone showed me what the operators of the programming language do.
>needing someone to show what the operators do
I just opened up script files for total war games and started editing them by looking around for context. Still don't know what language they were in 13 years later, don't care.
For me it's the same when I did a few easy JavaScript CTFs
I still never learned how to properly code in JS cause JS is lame.
Bit scary how basic logic and pattern matching gatekeeps some people.
LMAO JUST ADD 15
YOU GUYS ARE FIRED FOR TIME THEFT
THE SOLUTION IS LITERALLY JUST +15
GET ON MY LEVEL