News for hackers. Stuff that matters.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by akersten on Wednesday January 19, 2022 @11:25AM (#29995749)
I noticed one of the challenges is "reverse a string." Can I just rant a little about how much I hate that as an interview question?

It's meaningless to reverse a string. Not just in the "there's no purpose to doing it" sense (very true) but genuinely in the "it literally isn't a defined operation" sense. If you've only lived in the nice insulated world of ASCII or a mostly-ASCII-like language, you might scratch your head - just put the letters in backwards order, right?

Well, what do you when you hit a Unicode joiner? Or a multi-byte emoji? Maybe your reversing scheme is clever and looks at "whole codepoints" or whatever. But then what happens when you normalize the "reversed" string? Or what about the modifier characters that affect the previous/next character - how to treat those? I've never been satisfied with anyone's answer to these questions, because the problem is invalid from the start. You can't "reverse" an arbitrary string, it's not a well-defined operation.

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by htilford on Wednesday January 19, 2022 @07:27PM (#30002531)
The fact that it most people think it's a well-defined operation is what makes it a useful question. A total newbie who doesn't know how to code will fumble. A junior engineer will get to the simple solution. A senior engineer will ask you to define it better. Etc... It's an effective tool for determining level because there isn't a limit on how much depth you can go into about it.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by technion on Wednesday January 19, 2022 @07:53PM (#30002771)
I'm jaded enough to imagine that if I ask someone to define it better and try to give a "senior" response that covered codepoints, an interviewer will write down "struggled with simple question".

Edit: That seems consistent with a statement made in another response.

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by Doxin on Thursday January 20, 2022 @05:48AM (#30007223)
I feel like the best way to tackle questions like these is to first jot down a simple solution and then point out the various ways it doesn't work.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by yehoshuapw on Wednesday January 19, 2022 @11:32AM (#29995857)
There is a (slight, but important) difference between the syntactic meaning, and the semantic meaning.

you are correct that reversing a string gives back irrelevant things. (and you don't need to go that far: what does a reversed word mean?) however, in the sense of a list of characters, the content is irrelevant.

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by admiral33 on Wednesday January 19, 2022 @02:02PM (#29998371)
Maybe the interview question should be 'How is the question 'reverse this string' a bad interview question'
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by methyl on Thursday January 20, 2022 @04:31AM (#30006712)
If it's an interview for a position that's involving interviewing people, then for sure.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by admiral33 on Thursday January 20, 2022 @09:55AM (#30009627)
So, developer.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by paulluuk on Wednesday January 19, 2022 @02:49PM (#29999022)
Ha, I had the same challenge and was actually annoyed to find out that Javascript doesn't have a builtin function like str.reverse().

I totally see your point, though.

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by Eduard on Wednesday January 19, 2022 @12:42PM (#29997028)
> I noticed one of the challenges is "reverse a string." Can I just rant a little about how much I hate that as an interview question?

I find "reverse a string" a good interview question then! If the applicant got lost in considering all possible interpretations instead of just solving it how 99% of humans/engineers would understand it, then they will likely be unfit for working in a team and/or have poor communication skills.

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by jandrese on Wednesday January 19, 2022 @04:55PM (#30000807)
You are weeding out all candidates who understand Unicode. This is exactly the sort of problem that a good engineer would keep an eye out for because it's almost certainly going to explode with edge conditions if you try to do it the "obvious" way.

Unless you're giving that problem and then hitting the input with a string that includes directional formatting characters. Because that's exactly what is going to happen in real life.

The only good thing about that question is at least you didn't ask them to casefold the string.

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by renewiltord on Wednesday January 19, 2022 @07:28PM (#30002542)
No, not all, probably not even many. There are lots of candidates who know Unicode who would just say “I’ll assume that we have just ASCII characters unless you think I should consider Unicode” and if you say the latter, then they can say “Well, I could reverse it by just ensuring the text appears right to left, or perhaps by reordering each grapheme cluster to the end, or something like that. Let me know if you want one of those, otherwise I’ll just write it assuming you mean A”.

The magic of engineering isn’t doing what you’re told. It’s understanding and solving a problem someone has told you about.

My org doesn’t need the guys who need exhaustive instructions to take the next step. It needs those who can make good Bayesian inferences, reason inductively, and figure out problems.

So yes, it does filter out people with lots of knowledge who nonetheless lack these skills.

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by jandrese on Wednesday January 19, 2022 @07:59PM (#30002830)
If you assume ASCII in 2022 you are doing it wrong. Your code will fail in the real world.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by renewiltord on Wednesday January 19, 2022 @08:23PM (#30003026)
Hey, listen, the way I see it is that you don't want to work with a company like us and we don't want to work with you. It's an eminently compatible situation.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by alanbernstein on Wednesday January 19, 2022 @02:01PM (#29998355)
That's harsh. Sounds like a thoughtful candidate who understands edge cases to me.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by paulluuk on Wednesday January 19, 2022 @02:50PM (#29999047)
Best: solve the problem, but also add the caveat that _technically_ there are edge-cases that wouldn't work.

Worst: spend the entire interview explaining why you can't solve this problem.

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by MattGaiser on Wednesday January 19, 2022 @11:39AM (#29995981)
I have learned not to ask these sorts of questions outside hobby projects. It is rarely appreciated.
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by charcircuit on Wednesday January 19, 2022 @12:14PM (#29996519)
I recommending googling "grapheme cluster"
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by julienreszka on Wednesday January 19, 2022 @04:19PM (#30000295)
str.split('').reverse().join('')
Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by Karawebnetwork on Wednesday January 19, 2022 @04:52PM (#30000770)
In a tongue-in-cheek tone: Woah, so old school. We would never hire you! You have to show that you know ES6!

[...str].reverse().join('')

Re:Show HN: CodeCaptcha - Hide web links behind coding chall... by jandrese on Wednesday January 19, 2022 @04:56PM (#30000826)
Which would fail. You got the directional formatting characters in the wrong order.

It is 2022. If your code doesn't treat all strings as Unicode it is broken.