Hacker News new | ask | show | jobs
by whoomp12342 1147 days ago
If I do a live coding challenge, it is absurdly simple and is meant to root out people who have literally no business being in the room.

Write a function that takes in a string and returns 1 if the amount of letters in the string is odd. It returns 0 if the amount of letters in the string is even.

If you can do this, we are good. I dont need NP hard or whiteboarding or algorithms. I can tell how good you are just by talking to you about your background.

4 comments

Some candidate, done, sweating: "I wasn't sure if the limericks, speeches and open letters count as letters here but the criteria used are easily replaceable" /jk
I can never remember how modulus works, I use it so infrequently.
Just use n & 1 then. An odd number ends in binary 1; and’ing it with 1 yields 1 if its odd.
You don't even have to get that cute. Do integer division, multiply the result by the divisor, and subtract the product from the original dividend. Surely you can't say you don't use multiplication, division, and subtraction.
Sure, but you probably remember division.

"I can't remember of n % 2 returns 0 or 1 on even, so in place of that I wrote (if ((n/2)* 2 == n) for even, assuming integral division"

highly recommend learning how division works within assembly. If you can understand sending this data into registers, you will never forget how mod works. Honestly, I dont even care if you use modulus or not. Solve the problem within a function demonstrating you know CS101 concepts we are good. like, really. No judgement, this is just an idiot filter.
I think implementing a function that does what a modulo operator would is itself a fairly straightforward question.
Which kind? For example, can you name a difference between Python and C semantics for % op (if any).
the best fit jobs I've ever had have also taken this approach. Absurdly easy programming problem, then 95% talking about my background.
Bonus if you use n & 1 instead of n % 2 != 0