|
Code examples and interviews
Last post 05-05-2008 3:06 PM by ammoQ. 111 replies.
-
03-10-2008 12:44 PM
|
|
-
MonkeyCode


- Joined on 03-10-2008
- Posts 4
|
Code examples and interviews
I thought you might like this one. Trouble is - I'm having a bit of an issue deciding which category to choose to submit this under. You'd be far better of with some kind of enterprisey web 2.0 ajax tagging feature than a simple drop down of choices. ;) So I'm throwing it to the side bar, the name of which doesn't seem to make sense either. Where is the side bar? Can I drink there?
We're looking for some new developers on our team here at our online travel reservation startup. London being London at the moment, it's proving hard to get good quality candidates to actually show up at an interview. Little did we know how bad the quality can be at times.
We have a coding test that we give to potential hires. Not terribly hard, it's just a simple string manipulation exercise: Given a string, find all occurences of a substring without using any in built string functions. Obviously you'd never do this in real life, but your run of the mill 'teach yourself c# in 24 hours' developer could probably give it a shot and fool us. It does however, weed out a suprisingly number of people - their code doesn't compile, it doesn't work or somtimes they don't read the instructions and submit finger paintings instead. The other day, a "friend" of one of our workmates pointed out the question had been posted to the msdn forums. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2940944&SiteID=1 Technically - not a wtf, posting to forums can be a valuable source of information. Proving how clueless you are in a public forums, however is. There are a couple of classic responses in there, none really good enough for our potential hire, so he had a follow up post the next day: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2947702&SiteID=1 Being the masochists that we are, we couldn't help but look up some of our potential hire's other questions. A few listed here: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2098703&SiteID=1 http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=802585&SiteID=1 And this beauty: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1263379&SiteID=1 So many wtfs, so little time.
|
|
-
-
Random832


- Joined on 05-09-2007
- Posts 482
|
Re: Code examples and interviews
It's called the sidebar because a list of the five most recently posted topics to it shows up in a box in the sidebar on the right^H^H^H^H^Hleft side of the non-forum pages
|
|
-
-
-
belgariontheking


- Joined on 08-20-2007
- Cincinnati, OH, USA
- Posts 2,276
|
Re: Code examples and interviews
MonkeyCode:
"I deleted everything, completely fucking it all. Save my ass, for I cannot save it myself."
SpectateSwamp exposing aliens. Obviously the World needs SSDS
[10:07] <fatdog> so from now on.. be sure to wear nice clean underwear [10:07] <mps> fatdog: That is simply not going to happen
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
belgariontheking: MonkeyCode:
"I deleted everything, completely fucking it all. Save my ass, for I cannot save it myself." Yeah, that one is awesome. And it explains why he is looking for a job in the first place....
|
|
-
-
GettinSadda


- Joined on 05-25-2006
- North-East Scotland
- Posts 288
|
Re: Code examples and interviews
MonkeyCode:
Before you phone him to tell him not to bother with the interview, back everything up extra securely. There is no knowing how far that sort of thing can spread... do you really want to bet your database on the belief that speaking to him by phone can't screw your data?
Linux is not a code base. Or a distro. Or a kernel. It's an attitude. And it's not about Open Source. It's about a bunch of people who still think vi is a good config UI.
Notice: Phorm, and its agents including ISPs collecting data on Phorm's behalf, are specifically forbidden from performing any processing or monitoring of the content of the above post. Hence, under the Regulation of Investigatory Powers Act 2000 any such attempt to profile this page by Phorm or its agents is illegal.
|
|
-
-
cdietrich


- Joined on 12-18-2007
- Posts 12
|
Re: Code examples and interviews
MonkeyCode: Wow -- this makes my day a whole lot better, for some sinister reason.
|
|
-
-
Aaron


- Joined on 07-10-2007
- Posts 477
|
Re: Code examples and interviews
The one about the NullReferenceException particularly irritated me because I watched this happen in real-time. The explanation/excuse sounded almost the same: I know what it means, and I tried debugging, but I can't figure out what's causing it, can you help? Isn't this supposed to be second nature to programmers? If you can't track down an NRE/NPE, the most clear-cut and obvious of all exceptions, then you're in the wrong profession.
|
|
-
-
tster


- Joined on 04-11-2006
- Natick, MA
- Posts 1,765
|
Re: Code examples and interviews
MonkeyCode:I thought you might like this one. Trouble is - I'm having a bit of an issue deciding which category to choose to submit this under. You'd be far better of with some kind of enterprisey web 2.0 ajax tagging feature than a simple drop down of choices. ;) So I'm throwing it to the side bar, the name of which doesn't seem to make sense either. Where is the side bar? Can I drink there?
We're looking for some new developers on our team here at our online travel reservation startup. London being London at the moment, it's proving hard to get good quality candidates to actually show up at an interview. Little did we know how bad the quality can be at times.
We have a coding test that we give to potential hires. Not terribly hard, it's just a simple string manipulation exercise: Given a string, find all occurences of a substring without using any in built string functions. Obviously you'd never do this in real life, but your run of the mill 'teach yourself c# in 24 hours' developer could probably give it a shot and fool us. It does however, weed out a suprisingly number of people - their code doesn't compile, it doesn't work or somtimes they don't read the instructions and submit finger paintings instead. The other day, a "friend" of one of our workmates pointed out the question had been posted to the msdn forums. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2940944&SiteID=1 Technically - not a wtf, posting to forums can be a valuable source of information. Proving how clueless you are in a public forums, however is. There are a couple of classic responses in there, none really good enough for our potential hire, so he had a follow up post the next day: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2947702&SiteID=1 Being the masochists that we are, we couldn't help but look up some of our potential hire's other questions. A few listed here: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2098703&SiteID=1 http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=802585&SiteID=1 And this beauty: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1263379&SiteID=1 So many wtfs, so little time. how do you know that's the same guy? Is that word for word the question you asked? Even then, did you get the question from somewhere or make it up yourself? Did you verify that that msdn forum name is his somehow? I mean, you did ask a very generic string searching question. Also, the real WTF is thinking that you can search a string object without using any built in string functions. Unless you use reflection (which will indirectly use string functions anyways) it will be impossible to do.
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting... see bio for the earth shattering ending.
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
Oh wow, that was one of the best in a long time.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
tster:how do you know that's the same guy? Is that word for word the question you asked? Even then, did you get the question from somewhere or make it up yourself? Did you verify that that msdn forum name is his somehow? I mean, you did ask a very generic string searching question. Also, the real WTF is thinking that you can search a string object without using any built in string functions. Unless you use reflection (which will indirectly use string functions anyways) it will be impossible to do. Whoo hoo! Quoting the entire OP sure is fun! Anyway, why wouldn't you be able to use a character array and manually loop and search? I assume they are only looking for the person to be able to think for themeselves and solve a problem, so I don't think they are looking for anything that is going to set records in optimization or anything... Perhaps I am missing something... but this certainly seems possible to me....
|
|
-
-
Welbog


- Joined on 02-08-2007
- Posts 586
|
Re: Code examples and interviews
MasterPlanSoftware:but this certainly seems possible to me
It is obviously possible to implement these things without string functions: the string functions had to have been implemented somehow. I don't know what tster is talking about, either.
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
tster:the real WTF is thinking that you can search a string object without using any built in string functions
The .NET String class (as opposed to the string type) can actually be accessed using an index (look it up on MSDN), so it's perfectly possible.
|
|
-
-
MonkeyCode


- Joined on 03-10-2008
- Posts 4
|
Re: Code examples and interviews
tster:how do you know that's the same guy? Is that word for word the question you asked? Even then, did you get the question from somewhere or make it up yourself? Did you verify that that msdn forum name is his somehow? I mean, you did ask a very generic string searching question. Also, the real WTF is thinking that you can search a string object without using any built in string functions. Unless you use reflection (which will indirectly use string functions anyways) it will be impossible to do.
* Word for word, formatting included, the question we asked. Not sure where it came from, but the string used is a google whack.
* The question was posted the day we asked several candidates to do the test
* It's not impossible, the idea is just to get candidates to write a simple loop that iterates through a character array.
* Apologies if these were your msdn posts ;)
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
Welbog: MasterPlanSoftware:but this certainly seems possible to me
It is obviously possible to implement these things without string functions: the string functions had to have been implemented somehow. I don't know what tster is talking about, either. Anyone who has ever used base C++ with no string library should be able to accomplish this easily. But I suspect a lot of CS graduates that were/are only exposed to .NET or Java would probably have a lot of issues with this. For better or for worse... Yay for 'intro to programming'!
|
|
-
-
pitchingchris


- Joined on 04-30-2007
- Louisville, KY
- Posts 385
|
Re: Code examples and interviews
would the regular expressions class be considered in the category of built in string functions ?
|
|
-
-
Welbog


- Joined on 02-08-2007
- Posts 586
|
Re: Code examples and interviews
MasterPlanSoftware:But I suspect a lot of CS graduates that were/are only exposed to .NET or Java would probably have a lot of issues with this.
The idea that there are such graduates who have never encountered low-level programming before graduation terrifies me. Did you have to terrify me like that?
|
|
-
-
MonkeyCode


- Joined on 03-10-2008
- Posts 4
|
Re: Code examples and interviews
MasterPlanSoftware:
Anyway, why wouldn't you be able to use a character array and manually loop and search?
I assume they are only looking for the person to be able to think for themeselves and solve a problem, so I don't think they are looking for anything that is going to set records in optimization or anything...
Perhaps I am missing something... but this certainly seems possible to me....
That's exactly what we're hoping for. It's a really basic test - loop through a char array and look ahead the next x characters to see if it matches the search string. There are a couple of slight optimizations you can do - but they're not the point of the exercise. It's just to weed out the dead wood - we suggest that they do it at home and spend no more than an hour on it.
Sadly for the development community, it weeds out ALOT of candidates.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
pitchingchris:would the regular expressions class be considered in the category of built in string functions ? I think that would tend to defeat the purpose of the exercise...
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
Welbog: MasterPlanSoftware:But I suspect a lot of CS graduates that were/are only exposed to .NET or Java would probably have a lot of issues with this.
The idea that there are such graduates who have never encountered low-level programming before graduation terrifies me. Did you have to terrify me like that? Yeah you are right, made me queasy as well... but it had to be said.
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
pitchingchris:would the regular expressions class be considered in the category of built in string functions ?
Probably not, but it's definitely using a sledgehammer to crack a walnut.
|
|
-
-
pitchingchris


- Joined on 04-30-2007
- Louisville, KY
- Posts 385
|
Re: Code examples and interviews
mfah: pitchingchris:
would the regular expressions class be considered in the category of built in string functions ?
Probably not, but it's definitely using a sledgehammer to crack a walnut.
You're probably right.. But its the best alternative in a few instances, especially since there's not a 1 - 1 relationship to C++'s sscanf function.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
MonkeyCode:It's just to weed out the dead wood - we suggest that they do it at home and spend no more than an hour on it. Hell, sounds like something I would let them do on the whiteboard. You would have to allow for the awkwardness and pressure, but it would be beneficial to see their thought process in realtime. I wouldn't even be concerned about syntax in any way. And I would say an hour would be about right in person so you could have a dialogue about things you could improve, potential pitfalls, etc. Again, the thought process would be my main focus there....
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
pitchingchris:You're probably right.. But its the best alternative in a few instances, especially since there's not a 1 - 1 relationship to C++'s sscanf function. Still way overblown. What is wrong for with a for loop and character array? I cannot think of any langauge you shouldn't be able to do that in pretty easily.
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
pitchingchris:there's not a 1 - 1 relationship to C++'s sscanf function.
I tend to view any of the scanf family as a WTF in itself. Useful in very limited circumstances, or for prototyping, but shockingly easy to break (and that's before we even mention buffer overflows). If I found one in production code I'd probably take the person responsible out back and shoot him/her.
|
|
-
-
pitchingchris


- Joined on 04-30-2007
- Louisville, KY
- Posts 385
|
Re: Code examples and interviews
mfah:I tend to view any of the scanf family as a WTF in itself. Useful in very limited circumstances, or for prototyping, but shockingly easy to break (and that's before we even mention buffer overflows). If I found one in production code I'd probably take the person responsible out back and shoot him/her.
Guess I'll be riddled with bullet holes soon...
|
|
-
-
Brendan Kidwell


- Joined on 05-09-2005
- Boston
- Posts 158
|
Re: Code examples and interviews
MonkeyCode: I actually disagree that this story is a WTF or shows any particular stupidity. Who among us hasn't accidentally "DELETE FROM $table" or "rm -rf /". The fact he has no backup plan may NOT be the poster's fault but some other person in his organization. That doesn't make it any less funny of course.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
Brendan Kidwell:I actually disagree that this story is a WTF or shows any particular stupidity. Who among us hasn't accidentally "DELETE FROM $table" or "rm -rf /". The fact he has no backup plan may NOT be the poster's fault but some other person in his organization. That doesn't make it any less funny of course.
Read the rest of his posts then. It is a long pattern of stupidity.
|
|
-
-
tster


- Joined on 04-11-2006
- Natick, MA
- Posts 1,765
|
Re: Code examples and interviews
MasterPlanSoftware: tster:how do you know that's the same guy? Is that word for word the question you asked? Even then, did you get the question from somewhere or make it up yourself? Did you verify that that msdn forum name is his somehow? I mean, you did ask a very generic string searching question. Also, the real WTF is thinking that you can search a string object without using any built in string functions. Unless you use reflection (which will indirectly use string functions anyways) it will be impossible to do. Whoo hoo! Quoting the entire OP sure is fun! Anyway, why wouldn't you be able to use a character array and manually loop and search? I assume they are only looking for the person to be able to think for themeselves and solve a problem, so I don't think they are looking for anything that is going to set records in optimization or anything... Perhaps I am missing something... but this certainly seems possible to me....
I've got a game: You post a solution, and I will STFU. Until then, I assert that this task is impossible. remember you cannot use any "external functionality." Of course, this all depends on the definition of "directly solve." If you ask me, this question is worded so poorly that I wouldn't want to work there anyways.
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting... see bio for the earth shattering ending.
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
I believe it was actually "without using any in built string functions". I would assume that ToString () is allowed on the output positions, though.
|
|
-
-
belgariontheking


- Joined on 08-20-2007
- Cincinnati, OH, USA
- Posts 2,276
|
Re: Code examples and interviews
tster:If you ask me, this question is worded so poorly that I wouldn't want to work there anyways.
I will make sure to not ask you then. A phone call to clear up any requirements that are unclear is not out of the question. It will be expected in the workplace, after all. It's not like the prompt was "explain programming to me over the phone. I want to make a game like Halo" If you don't understand the point of the exercise from the prompt, you have some learning to do. Also, you don't deserve the job.
SpectateSwamp exposing aliens. Obviously the World needs SSDS
[10:07] <fatdog> so from now on.. be sure to wear nice clean underwear [10:07] <mps> fatdog: That is simply not going to happen
|
|
-
-
Aaron


- Joined on 07-10-2007
- Posts 477
|
Re: Code examples and interviews
MasterPlanSoftware:Hell, sounds like something I would let them do on the whiteboard. You would have to allow for the awkwardness and pressure, but it would be beneficial to see their thought process in realtime. I wouldn't even be concerned about syntax in any way. And I would say an hour would be about right in person so you could have a dialogue about things you could improve, potential pitfalls, etc. Again, the thought process would be my main focus there....
Try asking some stupidly simple recursion question (like, print all the nodes in a tree, which can be done in 4 lines) for the whiteboard. Seems to weed out, um, 100% of candidates. How do these people get degrees?
|
|
-
-
Aaron


- Joined on 07-10-2007
- Posts 477
|
Re: Code examples and interviews
tster:If you ask me, this question is worded so poorly that I wouldn't want to work there anyways. And that seems to be a major part of the problem with 90% of the pool out there - their instructions have to be so specific and perfect that by the time I'm finished writing them, I might as well have just done the job myself. If you consider yourself to be anything more than a code monkey, you have to learn to deal with ambiguity. If I have to give detailed directions, I might as well give them to the computer, whom I at least know will follow them consistently and accurately.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
tster:I've got a game: You post a solution, and I will STFU. Until then, I assert that this task is impossible. remember you cannot use any "external functionality." Of course, this all depends on the definition of "directly solve." If you ask me, this question is worded so poorly that I wouldn't want to work there anyways.
Are you really saying you cannot envision looping through a character array and manually checking for an occurence of a string? Or are you just trying to play word games? I am pretty sure either one rules you out as a candidate anyway, so I don't think employment there would be your choice...
|
|
-
-
taylonr


- Joined on 11-20-2007
- Posts 133
|
Re: Code examples and interviews
Aaron:
tster:If you ask me, this question is worded so poorly that I wouldn't want to work there anyways.
And that seems to be a major part of the problem with 90% of the pool out there - their instructions have to be so specific and perfect that by the time I'm finished writing them, I might as well have just done the job myself.
If you consider yourself to be anything more than a code monkey, you have to learn to deal with ambiguity. If I have to give detailed directions, I might as well give them to the computer, whom I at least know will follow them consistently and accurately.
And this, boys and girls, is why I call myself a software developer or software engineer, and NOT a programmer. Half of software engineering is determining what is needed, the ability to code is often the trivial (by comparison) aspect.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
taylonr:And this, boys and girls, is why I call myself a software developer or software engineer, and NOT a programmer. So do half of the people who behave this way... Title means nothing. Ask anyone who has interviewed numerous candidates. You will find 'Architects' and 'Engineers' who can barely write a hello world in Java...
|
|
-
-
AbbydonKrafts


- Joined on 11-21-2006
- Carrollton, GA, USA
- Posts 1,022
|
Re: Code examples and interviews
taylonr:And this, boys and girls, is why I call myself a software developer or software engineer, and NOT a programmer.
I just stick with The Architect.
Join us at #TDWTF on irc.slashnet.org !
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
Here you go then. I'm not sure how robust it is, but it satisfies the test cases.
static void MyInStringTest (String text, String Subtext)
{
// sanity check
if (text.Length text.Length)
{
MessageBox.Show ("There is no output.");
return;
}
int MaxLen = text.Length - Subtext.Length - 1;
string OutputText = "";
for (int i = 0; ; i++)
{
// are we there yet? are we there yet? are we there yet? are we there yet?
if (i >= MaxLen)
{
if (OutputText.Length > 1)
{
// we got something
MessageBox.Show (OutputText);
}
else
{
// no match
MessageBox.Show ("There is no output.");
}
return;
}
// declare in full scope as we'll need it's value outside the for loop
int j;
for (j = 0; j = 'A' && SubtextTest = 'A' && TextTest
(Edit - f--king pre tags barf here, you may not get all of it....)
|
|
-
-
tster


- Joined on 04-11-2006
- Natick, MA
- Posts 1,765
|
Re: Code examples and interviews
MasterPlanSoftware: tster:I've got a game: You post a solution, and I will STFU. Until then, I assert that this task is impossible. remember you cannot use any "external functionality." Of course, this all depends on the definition of "directly solve." If you ask me, this question is worded so poorly that I wouldn't want to work there anyways.
Are you really saying you cannot envision looping through a character array and manually checking for an occurence of a string? Or are you just trying to play word games? I am pretty sure either one rules you out as a candidate anyway, so I don't think employment there would be your choice...
the requirements did not say you were given a character array. they said you were given a string, and how you get a character array from a string without using functions/properties/operators (all forms of functionality) from the string class is beyond me. Obviously I'm playing word games here. If I was applying for a job at that place I wouldn't be such a prick, but as I am posting on a forum, I have the luxury of the answer to this question not having any bearing on wether I will be able to eat next week.
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting... see bio for the earth shattering ending.
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
And I thought I had the forum software licked by using the plain text composer... oh well... static void MyInStringTest (String text, String Subtext) { // sanity check if (text.Length < 1 || Subtext.Length < 1 || Subtext.Length > text.Length) { MessageBox.Show ("There is no output (sanity check fail)."); return; }
int MaxLen = text.Length - Subtext.Length - 1; string OutputText = "";
for (int i = 0; ; i++) { // are we there yet? are we there yet? are we there yet? are we there yet? if (i >= MaxLen) { if (OutputText.Length > 1) { // we got something MessageBox.Show (OutputText); } else { // no match MessageBox.Show ("There is no output."); }
return; }
// declare in full scope as we'll need it's value outside the for loop int j;
for (j = 0; j < Subtext.Length; j++) { // don't stomp the originals char SubtextTest = Subtext[j]; char TextTest = text[i + j];
// convert to lower case if (SubtextTest >= 'A' && SubtextTest <= 'Z') {SubtextTest -= 'A'; SubtextTest += 'a';} if (TextTest >= 'A' && TextTest <= 'Z') {TextTest -= 'A'; TextTest += 'a';}
// test the match if (SubtextTest != TextTest) break; }
// did we get it? if (j == Subtext.Length) { // compose the output text in accordance with the spec // (sample output stipulates that positions are 1-based) if (OutputText.Length < 1) OutputText = (i + 1).ToString (); else OutputText += ", " + (i + 1).ToString (); } } }
The requirement actually said you could use String objects - capital S, not lower case
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
tster:the requirements did not say you were given a character array. they said you were given a string, and how you get a character array from a string without using functions/properties/operators (all forms of functionality) from the string class is beyond me. Obviously I'm playing word games here. If I was applying for a job at that place I wouldn't be such a prick, but as I am posting on a forum, I have the luxury of the answer to this question not having any bearing on wether I will be able to eat next week. Being pedantic like you are would get you the job just as much as being pedantic makes you appear intelligent here. As everyone here has said, the point of the exercise is to show that you could operate without these classes and understand the underlying concepts. You can easily access a string with an index the same way you would with a character array. Yes, technically this is using the string class, however only a self important smart ass would argue this when given a simple task.
|
|
-
-
tster


- Joined on 04-11-2006
- Natick, MA
- Posts 1,765
|
Re: Code examples and interviews
mfah:The requirement actually said you could use String objects - capital S, not lower case They are one in the same. As for being a smart ass, I could really give two shits what you call me. The simple fact of the matter is that given the wording of the question, the task is impossible. Perhaps the OP would be impressed the a thoughtful contemplation of just why the task is impossible. But seeing as how it has been posted on the internet as an example of someone being an idiot not knowing how to answer it, I think that it's important to note that the question itself is loosely defined, and therefor not as straightforward to answer as perhaps originaly thought. Consider if a good programmer were given the task and spend a long time trying to use reflection or something to get it to work without breaking the rules and then said that they couldn't do it. Would you immediately think they were stupid? Interviewers should be careful with their assumptions that people will use the same loose definitions of words that they use, as often interview questions that are sent ahead of time like this are sent by a recruiter or HR person and the interviewee does not have the contact information for someone that could answer questions.
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting... see bio for the earth shattering ending.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
tster: mfah:The requirement actually said you could use String objects - capital S, not lower case They are one in the same. As for being a smart ass, I could really give two shits what you call me. The simple fact of the matter is that given the wording of the question, the task is impossible. Perhaps the OP would be impressed the a thoughtful contemplation of just why the task is impossible. But seeing as how it has been posted on the internet as an example of someone being an idiot not knowing how to answer it, I think that it's important to note that the question itself is loosely defined, and therefor not as straightforward to answer as perhaps originaly thought. Consider if a good programmer were given the task and spend a long time trying to use reflection or something to get it to work without breaking the rules and then said that they couldn't do it. Would you immediately think they were stupid? Interviewers should be careful with their assumptions that people will use the same loose definitions of words that they use, as often interview questions that are sent ahead of time like this are sent by a recruiter or HR person and the interviewee does not have the contact information for someone that could answer questions. I think you are the only one making assumptions. I think the rules are very clearly spelled out: MonkeyCode:for
example, do not use the built-in C# String class to find matches with
the lastIndexOf() method. You may however hold Strings while your own
algorithm does the matching!).
- Accepts two strings as input: one string is called “text” and the other is called “subtext” in this problem statement.
- The
application matches the subtext against the text, outputting the
character positions of the beginning of each match for the subtext
within the text.
- Multiple matches are possible.
- Matching is case insensitive.
- If there are no matches, no output is generated.
If there is any lack of clarity for you, I would consider it YOUR problem, not the OP's.
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
tster: mfah:The requirement actually said you could use String objects - capital S, not lower case They are one in the same.
MSDN to the rescue: "A string is a sequential collection of Unicode characters, typically used to
represent text, while a String is a sequential collection of System.Char objects that represents a
string".
|
|
-
-
AbbydonKrafts


- Joined on 11-21-2006
- Carrollton, GA, USA
- Posts 1,022
|
Re: Code examples and interviews
tster:given the wording of the question, the task is impossible
The problem is that if it's taken literally, "in built string functions" was the only exclusion. The Length and this[index] are both properties. So, they'd get by on a technicality. The MSDN post gives LastIndexOf as an example exclusion. That would be a function whose job is specifically finding a substring. So, I'm sure using the properties Length and "this" would be outside the bounds of exclusion.
But, I've also heard people refer to everything as "functions", including properties. So, if that is the case here, then yes, it would become impossible because then even Length would be disallowed.
Join us at #TDWTF on irc.slashnet.org !
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Code examples and interviews
AbbydonKrafts:The problem is that if it's taken literally, "in built string functions" was the only exclusion.
Actually, if you read the actual requirements that he was given, you wont find that wording. (Holy crap! Who would think to RTFA huh?) MonkeyCode:Write an application that fulfils the following requirements:
Do
not use external functionality to directly solve the problem (for
example, do not use the built-in C# String class to find matches with
the lastIndexOf() method. You may however hold Strings while your own
algorithm does the matching!).
- Accepts two strings as input: one string is called “text” and the other is called “subtext” in this problem statement.
- The
application matches the subtext against the text, outputting the
character positions of the beginning of each match for the subtext
within the text.
- Multiple matches are possible.
- Matching is case insensitive.
- If there are no matches, no output is generated.
Acceptance Criteria:
Input text is Polly put the kettle on, polly put the kettle on, polly put the kettle on we’ll all have tea
|
Subtext
|
Polly |
|
Output
|
1, 26, 51 |
|
Subtext
|
polly |
|
Output
|
1, 26, 51 |
|
Subtext
|
ll (ell ell) |
|
Output
|
3, 28, 53, 78, 82 |
|
Subtext
|
x |
|
Output
|
There is no output |
|
Subtext
|
Polx |
|
Output
|
There is no output |
|
|
-
-
tster


- Joined on 04-11-2006
- Natick, MA
- Posts 1,765
|
Re: Code examples and interviews
AbbydonKrafts: tster:given the wording of the question, the task is impossible
The problem is that if it's taken literally, "in built string functions" was the only exclusion. The Length and this[index] are both properties. So, they'd get by on a technicality. The MSDN post gives LastIndexOf as an example exclusion. That would be a function whose job is specifically finding a substring. So, I'm sure using the properties Length and "this" would be outside the bounds of exclusion.
But, I've also heard people refer to everything as "functions", including properties. So, if that is the case here, then yes, it would become impossible because then even Length would be disallowed. I don't see anywhere in the problem the use of the word "function" or "functions." Functionality != functions
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting... see bio for the earth shattering ending.
|
|
-
-
tster


- Joined on 04-11-2006
- Natick, MA
- Posts 1,765
|
Re: Code examples and interviews
mfah: tster: mfah:The requirement actually said you could use String objects - capital S, not lower case They are one in the same.
MSDN to the rescue: "A string is a sequential collection of Unicode characters, typically used to
represent text, while a String is a sequential collection of System.Char objects that represents a
string". I don't know what MSDN your refering to here, but the C# keyword "string" is directly mapped to System.String.
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting... see bio for the earth shattering ending.
|
|
-
-
drinkingbird


- Joined on 08-26-2007
- Sydney, Australia
- Posts 82
|
Re: Code examples and interviews
MasterPlanSoftware: tster:*snip* Also, the real WTF is thinking that you can search a string object without using any built in string functions. Unless you use reflection (which will indirectly use string functions anyways) it will be impossible to do. Whoo hoo! Quoting the entire OP sure is fun! Anyway, why wouldn't you be able to use a character array and manually loop and search? *snip* If you want to get picky, it depends on whether some_string[0] would directly access a character array making up the string, or if it's actually a call to some_string.[ ](0), in which case it's one of the built in string methods. Edit: Bleh, a whole conversation about this went on while I was reading other threads. More edit: C# properties are just dressed up accessor methods. Plain old methods. Stop pretending they're special.
|
|
-
-
mfah


- Joined on 12-01-2007
- Posts 117
|
Re: Code examples and interviews
tster:I don't see anywhere in the problem the use of the word "function" or "functions." Functionality != functions
It was actually in the OP. But the key thing here is a "letter of the law" vs. "spirit of the law" thing. Most of us would see the most relevant part of the directions as being "to directly solve the problem". This would mean that indirect is fair game.
|
|
|
|
|