
I originally posted this post on my blog.
Did AI kill the tech interview?
Truth is hiring and interviewing have been broken for years. There w...
For further actions, you may consider blocking this person and/or reporting abuse
I don't know anything about
DataTable
(not a C# developer), but my first question would be what the performance difference is between the two (your solution, and Phind's).My second question would be about the size of the compiled program.
An "elegant" solution is not always the best.
Those are interesting questions Dan. I didn't take the time to run benchmarks, I was surprised enough that I rushed to write about it :)
Ohhh! Good point!
Awesome
This is my solution in JavaScript (before reading the rest of your post):
This is what I call a "quick and dirty solution". I'd have felt guilty because of using
eval()
(yeah, never a good idea), but then I'd have remembered that this was an exercise for a stupid interview, and I would have handed in as it was.Only later I realized that I was supposed to use C#. In my case, I'd have used Roslyn in order to evaluate the solution, I suppose.
That gets all the tests turn green...With a clock ticking, my quick and dirt solution was a string processing solution, parsing each character, it only made me waste time. :\
Okay, the preprocessor solution (I could not resist, I guess):
It's again JavaScript, but used more like Java, so I think it is recognizable.
As you can see, I would anyways replace "one" with 1 and "two" with 2... it simplifies things.
I use an
isInt()
function. This is an entrypoint for a hypotetical solution with numbers of any width (not only 1-digitint
s). This nearly does not add complexity to the solution, and I think it makes it more robust. Just a little bit of overengeering tradeoffI also don't like that
char
0 being the starting status, so I coded with the last operation being add as default, and the value to return 0.My two cents.
...I also feel a little bit hurt about my post about AI, or my reputation, were not enough for you, and you had to ask a veteran...
[This is a joke. Yep, I'm that stupid. :-P ]
The solution with the DataTable really surprised me. (That was what mad me write this whole post.) That's something we wouldn't come up with unless we had devoured the official docs or ran into an issue.
Wow, I never would've reached for DataTable.Compute in an interview either. Do you think these kinds of shortcuts actually make the hiring process any better, or just weirder?
It makes the hiring process weirder for both sides. From candidates using AI to lip sync to companies expecting fully functional solutions for take-home exercises.
Man, learning that DataTable trick after all these years kinda blew my mind - always stuff hiding in plain sight.
For a moment, I thought it was a hallucination. I had to double check and run the code on my side just to convinced me it was right. Blew my mind too, so I had to write this post.
Fascinating how both models landed on the same creative solution...
yeah, it wasn't that surprising the second time I saw the DataTable trick :\