- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The fool! All he had to do was rollback.. too late now! (Ok, so some tools may not do that automatically, but the ones we use here automatically start a transaction, so if we need to rollback, no problem!)
Admin
TRWTF is that links is directly pasted from outlook webmail
ED: I think TRWTF is that OWA has to redirect every link... Fixed!
Admin
All I can say is that I do not think subtext means what you think it means.
Admin
A few weeks ago happened to me, that my boss "accidentally" forgot the delete clause in a DELETE.
And after asked me the same silly question, while pointing up that in DB2/400 is effectively possible to recover data from a table (but they usually call them "files"), after a delete, if you don't repack the table.
Admin
That's sad :/ I feel kinda sorry for that guy.
Admin
I'm all for coding tests for potential hires, but why would your coding test try to ascertain whether or not the interviewee was capable of producing code in a way that you yourselves admit they would never do in real life?
That particular problem is sort of like asking someone to pattern match in Perl without using regular expressions. Just seems a little pointless to me.
Admin
I think it is a valid interview question, makes someone show they can iterate though some simple work.
Would also need maybe a follow up question on recursion, but definately a valid question to ask.
Admin
I think the point is to weed out the complete muppets, the ones that don't have a clue, similar to that Fiz Buz problem that had its 15 nanoseconds of Internet fame a while ago. (The problem was something along the lines of: for every number from 1 to 100 print Fiz if it's divisible by 3, Buz if it's divisible by 5 and FizBuz if it's divisble by both 3 and 5. It appeared that surprisingly low percentage of potential hires managed to solve this highly sophisticated problem)
Admin
Usually the point is to analyze the interviewee's problem solving ability, but you're right, it's pretty silly here because the candidates complete it on their own time. For whatever reason I guess it still weeds out the completely useless candidates.
I hope these comments don't degenerate into (some) self-taught programmers bashing anything that isn't 100% practical just because they don't understand the difference between a LinkedList and an ArrayList.
Admin
I would have posted teh codez if I wasn't afraid that the peer review here would be too severe.
I want to see someone come up with a one line solution
Btw that is a task for home?
And what better name for a table than table_columns
Admin
Admin
I got asked that exact question at my last interview (over a year ago). I hadn't heard it before and didn't know until know it was a common question. I did think it was a little silly; if my 9-year-old self had known what "modulo" was, he could have done it in GW-BASIC. But the interviewer said the same thing, "apparently a lot of people have trouble with that one".
Admin
"didn't know until now", I mean.
Admin
I decided to write some code because I was bored and it was something to spend five minutes on. I've not tested it in "production", though I probably would if I was actually applying for the job.
I'm using the Substring() and ToLower() methods, which doesn't seem to be against the rules (which only state that you're not allowed to use built-in methods which do the checking for you). If there's no matches then I return an empty list.
Admin
The real WTF is (I've always wanted to post that) that the indices in the example are 1 based
Admin
The filter works the other way too, as I'd be tempted to get up and leave when presented with that kind of busy-work.
(But then, I code in perl, where "there's more than one way to do it" is both the official motto, and its biggest curse. The last thing I need is people with a penchant for "clever" solutions to things that shouldn't be problems in the first place.)
Admin
I think the fact that the requirement was to not use any string manipulation function makes this problem a bit silly and excessive.
While barring the use of any Substring function or Contains function could have left the door open to:
And is significantly easier to do, barring any string manipulation function would require you to traverse individual characters, looking for spaces, keeping track of indicies, etc. Even C contains an strtok function, and C barely has any string manipulation functions. Why ask someone to dramatically re-invent the wheel? Could someone implementing the code above not be able to demonstrate an understanding of a number of functions in C#?
Programming tests are fine; I think when they get too ridiculously abstract and pointless is when they just get silly.
Admin
Where does input.Length come from? And you should only check till text.Length - subtext.Length or you will get an IndexOutOfRangeException from Substring IIRC.
And don't forget to cache the text.ToLower() and subtext.ToLower() ;)
Admin
PS - My interpretation of "string manipulation function" is really any method of the String class, including Split, ToLower, Substring, Contains, etc.
If I'm incorrect in this assumption, then what I said above doesn't apply xD
Captcha - haero ... are these actually words?
Admin
I once got asked "given two points, how would you find the distance between them?"
My brain went into overdrive trying to find the hidden meaning behind the question. Were they talking three-dimensional points? Are the points moving? Are they some sort of weird hyper-points?
I hesitantly responded, "The square root of delta x squared plus delta y squared?" The interviewer nodded and told me, "You'd be amazed at how many people have trouble with that."
Admin
Instant no hire. This is so bad I don't even know where to start... O(n^2) complexity. Doing the same O(n) thing over and over again instead of remembering the result. Doing an awful lot of entirely unnecessary allocations.
Of course, that the problem is ill-defined (Does subtext="" have no matches or tons of matches? Can matches overlap or not?) doesn't make things any better. But then, it may be intentional to test if the programmer realizes it.
Admin
Was this post helpful? I hope you marked it 'Yes', but I'm not sure about the point of view.
Admin
I was under the impression that no calls to "substring" would be allowed? If it is allowed, that makes this significantly easier (not that implementing substring is that much more difficult). I wrote it assuming I couldn't, although I wrote it in C...
Note, I'm not sure if it even compiles as I'm sure I have typos and gross syntax errors but this ought to work.
I have now proven that I am either incapable of implementing a simple function, or that I fit the stereotype of every other nerd on the internet that MUST solve any programming problem, no matter how trivial.
Admin
Oops, found=true should be BEFORE the for( j = 0... ) loop.
Admin
Shouldn't that be
Admin
I got asked during one interview how I would count the number of rows in a table using SQL (or something to that effect: find the largest value in a column in a table or something similar). Same general idea: apparently, many people interviewing for SQL-related jobs don't understand aggregate functions. Huh.
(I didn't get the job, actually, but that had as much to do with me as the interview with their VP that started with "You're just a young guy!" and continued with "I used to do your job and I know all about it", before, IIRC, insisting that I should use the time for a practice interview.)
Admin
Writing an O(n) algorithm for this problem is decidedly non-trivial. (Look up Boyer-Moore, it's pretty fancy.) I would not expect anyone to come up with it for an interview question without cheating, at least.
Admin
From the same dude, even more scary IMHO: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2356627&SiteID=1
Everything looks like a nail, when you have a new hammer...
Admin
YOU'RE HIRED!
Admin
Another WTF is that lousy table of inputs and expected results. Put the input in one column and the expected results in the other.
Admin
[quote user="me"][quote user="Thomas Winwood"] Of course, that the problem is ill-defined (Does subtext="" have no matches or tons of matches? Can matches overlap or not?) doesn't make things any better. But then, it may be intentional to test if the programmer realizes it.[/quote]
I think an ill-defined interview question probably tells you more about the candidate that a well defined one. Will they get frustrated because they don't have all the information or will they, I don't know, have the sense to ask for clarification? I set a take home programming problem for a position I had open and I hired the guy who had the sense to ask questions about the ambiguous parts of the problem.
Admin
Must...not...implement...it.......
Admin
So, I don't understand the limits of the request.. I just cannot use LastIndexOf?, would I get the job with this?:
private void FindSubStringPos(string str, string substr) { int i = 0; int maxIndex = str.Length - substr.Length;
while (i < maxIndex) { if (str.Substring(i, substr.Length).Equals(substr, StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("Position: "+i); i += substr.Length; } else i++; } }
Admin
When the problem is ill-defined, programmers should tend to choose the path that is easiest to implement. The posting doesn't say that the program has to be in C#, either. This implementation contains only one or two optimizations and is O(m*n - n^2) in the worst case (where the worst case is, e.g. finding "aaa" in "aaaaaaaaaaaaaaaa"). It is also, hopefully, completely useless to the plz-send-codez luser.
Admin
toLower is a String method...
private char myToLower(char c) { if(c > 63 && c < 91) return (char) (c + 32);
return c; }
Admin
For my money, his most frightening post is at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1577009&SiteID=1 in which he confesses his confusion:
At least his question about changing positions of columns can be explained by simple ignorance. In this one, however, the error message is RIGHT THERE IN FRONT OF HIM; he is criminally guilty of being unable to develop code and should be moved over to Marketing immediately.Admin
It's also a great answer to a stupid interview question.
Unfortunately, because the interview question is stupid, we may assume that it would fail to get a highly-qualified candidate the job.
Still, that's Scheme for you.
Admin
[quote user="Fanguad"]I once got asked "given two points, how would you find the distance between them?" [quote]
I'd just use a ruler and measure the distance. This question does not imply that we are not talking about physical points.
Admin
For what it's worth, here's my solution to FizBuz, in C++
EDIT: Err, semicolon on the return 0 might be helpful.
Admin
I always get nervous typing sql 'delete' statements, and when I remember I usually type 'select count(*)' instead and then replace it with 'delete' when I'm happy.
Admin
It's a shame this ended on a happy note, really. I was rather expecting "You missed out delta z squared! Mwahahaha! Luser!"
Admin
but that is ToLower for char which is not String method
Admin
Or maybe the logic that controls anti-lock braking in your car?
Or maybe the logic that controls the velocity of commuter trains?
Fuck that guy. Fuck him up his stupid ass.
Admin
I agree completely. Depending on how the rest of the interview went, I'd code up something as horribly complex as possible and tell the interviewer that, since they obviously wanted to create a purely intellectual challenge, I thought I'd return the favor and would s/he mind explaining exactly what s/he thought my working code did.
On my last interview I spent a couple of hours solving those silly "how would you get the cannibals across the river" type of problems. Funny, that's not a problem I've run into yet in all my years of coding. Yet they didn't ask a single question about a real-world problem. You want to know what I know? Ask me how I'd put together a bulletproof component for handling user input while four junior programmers are sitting around waiting for it and the release date is two weeks away. That I've done, and it's presumably why you're hiring me.
Admin
That FizBuz solution is a good answer that runs in (n) operations, but what they really wanted you to do was something a little more optimized: Have a Fiz and Buz counter that increment by 3 and 5 respectively. Each iteration of the loop increments the lower counter and prints the corresponding string. When the two are equal, increment both and print "FizBuz". Runs in: ((n/3) + (n/5) - (n / (3+5))) operations. Maybe.
Addendum (2008-05-05 12:48): Code that might work:
Admin
:P
Admin
Why not just skip the middle man, post the interview question directly on various internet help boards, then approach those who answer it with job offers. Should give about the same success rate.
Admin
Maybe he realizes that the '<' operator won't work, but has no idea how to compare dates in the language he is using. But he leaves that part in the code so that it is still clear what he is trying to do.
I know that date/time functions can be horribly inconsistent between languages or platforms, and often takes a bit of time and research to figure it out.
Admin
The original question asks that you print numbers, but print Fiz instead of the number if it's a multiple of 3, and Buz instead of the number if it's a multiple of 5, and FizBuz instead of the number if it's a multiple of both. It also doesn't specify that the numbers should be on separate lines.
Doesn't make it less trivial, but it does allow for ever so slightly more clever solutions.
Admin
The funny part is that in C# the comparison operators are overloaded for DateTime. He could easily compare DateTimes with > but for some reason he decided to compare string and DateTime. Now that is not WTF yet. It would become WTF when he calls .ToString() to the second DateTime argument which will compile and will probably return the right result in enough cases to make it look like it works.