by sethammons · 6y ago · 0 comments
Morse Code. All letters are combinations of one or more dashes and/or dots. Here is a sentence of Morse Code where the spaces are stripped. Decode it to get the original ASCII sentence.
He gave it and failed the candidate. Sounding like an interesting problem, some of us in the office tried it. Turns out that it is a very hard problem. You have to make a tree of possibilities and it is easy to accidentally make your solution O(n!).
Moral of the story is never give out a coding question that have not personally solved. Second moral: be open to out of the box solutions.
In any case, if one were resolute to pursue a practice like this, such as your colleague, then what they should have done is pick a problem they definitely don't know the answer to and then sit down and work it out actively in cooperation with the candidate. That would have been about a thousand times more useful as an interviewing activity.
Knowing the answer ahead of time makes the dynamic worse. Things will seem obvious that aren't when you already know the answer. It sounds like your colleague made things a degree worse by both not knowing the answer, but assuming that they did somehow intuitively.
That should be the most important test, but most of the daily realistic work is really a matter of practice. By testing it you really test how much practice with that particular toolchain and workflow the person had, not how smart or good programmer they are. Brainteasers are unrealistic and relying just on them is stupid, but they give you some insight in how good in quick thinking someone really is. If I was looking for a newbie to train, I'd always prefer someone who can't finish the real world test, but knows how to think technically, to the opposite.
Most of the challenging work is collaborative problem solving, not exam proctoring, and it's important to see how a person interacts with that. You'll see how much direction they're likely to need, if they can navigate and contribute positively to team dynamics, and so on.
The times I absolutely detest are when the interviewer writes down the problem and sits back for 30 minutes.
I understand that this is going to be awkward, especially for the low performers, but at the moment I don't think our interview practices are based on anything. We ask questions and then later have a conversation about how and whether or not our questions revealed the presence of the attributes we were supposed to be assessing for and it feels very made up and make believe. Plus, people could be given incentives for going through the process and bonuses for passing the mock interviews to encourage them to try
If we could get people where we already knew how good or bad they were to rerun the interview process then we could start to figure out which questions and which evaluation methods were useful in separating good candidates from poor ones.
Of course, you'll just find out that there's practically no correlation.. Some of the least useful teammates I ever had ended up at Google, and one of the best programmers I've ever met makes $10/hour at a fucking call center out in the middle of nowhere
This is the same problem you see with people claiming that GPA or GRE scores have no or negative correlation with academic success.
A person in your company, after having read the problem and glancing at the rough description figures out a clean solution in time X. That's without the interview stress, knowledge of the problem domain, with the pacing of the problem laid out in writing. A well-performing candidate coming in cold, stressed from the interview setup and under time pressure will take 3X time to solve it.
So if it takes much more than 10 minutes for someone at your company solve your proposed interview question reasonably well, it's almost certainly too difficult.
Good luck finding that! Condensed morse code can be _bananas_. https://en.wikipedia.org/wiki/Telegram_style
As for solving it, back-tracking recursive descent does the job, though obviously there's not always a single correct answer.
This is not really a "trick question", this is just a regular programming challenge :)
:)
On the surface it feels relatively easy. Until you realize you can't tell one letter from another.
Is it "D" or is it "T" followed by the start of the next letter? "D" is equal to "TEE". But it could be "NE" also. One letter in and we are exploding. This is not counting nonsensical combinations like this being the start of "NL", but if that is a word boundary, then maybe it is ok.
letter(a, X) :- string_to_list("._", X).
letter(b, X) :- string_to_list("_...", X).
/* rest ommitted for brevity */
letter(z, X) :- string_to_list("__..", X).
morse([], []).
morse(Morse, [Letter|Rest]) :-
letter(Letter, Head),
append(Head, Tail, Morse),
morse(Tail, Rest).
Prolog is obviously excellent for this kind of thing since the backtracking comes built in, but it's not massively more complicated in other languages.For "_.._", it gives you the following answers (I added some line-breaks):
?- string_to_list("_.._", L),
findall(English, morse(L, English), Answers).
L = [95, 46, 46, 95],
Answers = [[d, t],
[n, a],
[n, e, t],
[t, e, a],
[t, e, e, t],
[t, i, t],
[t, u],
[x]].
I wasn't saying that it's not a good little problem. It's a lovely little problem, which you solve with recursive back-tracking! I wouldn't say it's a "trick question" though, it's just a regular programming challenge.EDIT: Oh, I see what you're saying, do you mean "It's a trick question because there isn't necessarily just one answer"?
If so, then I misunderstood, I figured the challenge was "find all valid interpretations" of a certain morse code string. The fact that there could be more than one seemed fairly obvious to me.
edit: oooh and use beam search to limit the output size/time
There will be lots of ways to split any given prefix into letters. But all of them leave the same suffix. You don't need to repeat the analysis of the suffix.
You could avoid repeating the analysis by memoising the result. But when you're memoising results from leaves of a search tree, that's a hint that you're close to a dynamic programming approach.
All this obsession with coding tricks in the interviews is just awful.
In fact, beyond a certain level of competence, interview results are mostly about luck. Sometimes you get a nice set of interviews, sometimes you don’t. Some companies will at least not reject you out of hand for one bad interview slot, but most companies are just so overwhelmed with unreliable signal that they’ll tank you for any kind of hint at incompetence.
I’ve been given offers from Google, been rejected by random web shops, and everything in between, all within the same year.
The Dunning-Kruger effect is put on steroids during tech interviews.
There’s this pretense that the interviewer is smarter than the interviewee, and an expectation that the interviewee will abide by that pretense as a show of respect.
That pretense leads interviewers to being unnecessarily ambiguous, and especially leads them to asking overly complicated questions. If you’re an insecure engineer, this allows you to impress your coworkers in the meeting afterward with your complicated question. You can act as if it would have been easy for you, the other engineers in the room won’t disagree because they want people to think they’re smart too, and one thing will be made very clear to everyone: You are smarter than the candidate, and the company is very lucky to have you.
It also leads interviewees to fake equivocating and feigning ignorance, and is overall a strong recipe for unconscious or deliberate bias based on the personal and professional insecurities of both parties.
From the other side of the table, when you’re the one interviewing candidates, you spend an absolute minimum of 90% of your time screening and interviewing people who are so bad that it literally hurts on an emotional level to interact with them. You develop compassion fatigue, like a nurse in an ER, and it’s very easy to find yourself in a place where you assume the worst of every candidate and don’t even care anymore if they fail.
The results of these interviews are influenced far more heavily by the interviewers than by the person being interviewed, in my opinion. And most companies (nearly all in fact) have literally no mechanism by which they grade the quality or subjectivity of their interviewers.
encode :: Char -> [Bool]
encode 'a' = [False, True]
...
encode 'z' = [True , True , False, False]
data Trie a
= Trie
{ payload :: Maybe a
, false :: Trie a
, true :: Trie a
}
insert :: [Bool] -> a -> Trie a -> Trie a
insert xs v = foldr f b xs
where
b t = t {payload = Just v}
f False k (Trie e f t) = Trie e (k f) t
f True k (Trie e f t) = Trie e f (k t)
table :: Trie Char
table = foldr (uncurry insert) (fix (\t -> Trie Nothing t t)) [ (encode c, c) | c <- ['a'..'z'] ]
newtype Parser a b = Parser { runParser :: [a] -> [(b, [a])] } deriving Functor
instance Applicative (Parser a) where
pure x = Parser (\xs -> [(x,xs)])
(<*>) = ap
instance Monad (Parser a) where
xs >>= f = Parser \s -> do
(x,s') <- runParser xs s
runParser (f x) s'
instance Alternative (Parser a) where
empty = Parser (const [])
xs <|> ys = Parser (\s -> runParser xs s ++ runParser ys s)
instance MonadPlus (Parser a) where
eoi = Parser \case
[] -> [((),[])]
_ -> []
char = Parser \case
(x:xs) -> [(x,xs)]
[] -> []
morse :: Parser Bool String
morse = go table
where
go t = (go . bool (false t) (true t) =<< char)
<|> msum (fmap (\x -> fmap (x:) (go table <|> [] <$ eoi)) (payload t))
decode :: [Bool] -> [String]
decode = map fst . runParser morse
The output is pretty much unusable, though. For the string "me", for instance, there are 4 possible parses: ["g","me","tn","tte"]
For the string "hello", there are 19796.https://twitter.com/nomsolence/status/1228577284929421312
I think it's O(n!)?
I could see not hiring someone if they didnt try to ask stuff like that.
As a way to weed out people who just fill requirements without questioning if the requirement actually solves the problem.
[1] https://gist.github.com/pavelb/1d62e81b35d18fc1441ea59361b54...
Also, it was only a tiny bit over the line.
After which the CEO personally and profusely apologized to the candidate. And offered a hefty per-diem consulting fee in compensation for this cynical (if not outright juvenile) waste of their precious, irreplaceable time.
Right?
Candidates know that there is always a chance they will be rejected for reasons outside their control (e.g. there was only 1 opening and a better candidate applied), so if the candidate agreed to the interview without a consulting fee, I don't think it's necessary to give one.
When it's a minor screw-up -- sure, have the recruiter apologize.
When it's a major fuck-up of this scale -- reflective of both arrogance and incompetence on the company's side -- then the CEO needs to apologize.
It's really quite simple actually.
I see it as mostly ignorance on the part of a single interviewer. Every large company has lots of ignorance. People aren't perfect.
...---...
you can guess it's EEETTTEEE, but the decoding is SOS, that was the plaintext I started with.In other words, SOS is sent exactly the way you wrote it, as if it were one long character:
...---...
It is not sent as three separate letters like this: ... --- ...
To indicate this special treatment, prosigns are normally typeset with a bar over the connected letters, something like this: ___
SOS
(I used underscores above the letters here; if they render as separate underscores, imagine that they all run together.)For a trivial counterexample, consider an alphabet of
.-
..-
...-
(And yes, it isn’t uniquely solvable in the case or Morse code, as shown by the counter example A = ET)A trivial example is the reverse:
_.
_..
_...
Which can be decoded by, at worst, reversing the string first.(Sorry if I've misunderstood your example)