Post #109,060
7/10/03 4:27:13 PM
|
Another "removeSpaces" from a job candidate
MS in CS, 5 years of experience (mostly school jobs), C++ claimed as best language. \nvoid removeSpaces(char *s)\n{\n while (*s != NULL) {\n if (*s == " ") {\n tmp = s;\n s++;\n delete tmp;\n }\n }\n s++;\n}\n Seems like we need a coder who can write in a proprietary scripting language and some C++ in a fairly complex programming environment. Located in White Plains, NY. May I see a show of hands?
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,062
7/10/03 4:37:24 PM
|
Bleurrrgh.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #109,067
7/10/03 5:00:52 PM
|
You have a *great* need for a coder! :)
Alex
The tendency to turn human judgements into divine commands makes religion one of the most dangerous forces in the world. -- Georgia Harkness in "Conflicts in Religious Thought" (1929)
|
Post #109,076
7/10/03 5:45:42 PM
|
LPRD sez: Able to chew and walk gum at the same time. :)
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,078
7/10/03 5:54:48 PM
|
Help me
Please. Explain this to me.
I knew C many years ago. I dabbled in C++. This does not compute.
I'd set 2 pointers to the begining of the string, assign/increment both as long as the source was not space, increment / no assign just the source when the source was space.
|
Post #109,082
7/10/03 6:32:09 PM
|
You pass.
He doesn't. What I really wonder about is his MS degree. How is that possible to be Master of Computer Science from an American college and be that bad? The college seems real enough on the web. Either he lied, or the tests are just rubber stamps.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,084
7/10/03 6:40:06 PM
|
Depends.
Ask him a question about finite state automata. Or information theory. He'll probably pass.
A Master's (or a Bachelor's for that matter) only says that you took a bunch of (mostly) theoretical courses and passed them. It says absolutely nothing about how a particular person does in any particular programming language.
One more reason to use a degree only as the *last* tiebreaker.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #109,085
7/10/03 6:46:39 PM
|
Agreed.
When I was an undergrad at UT-Austin, I programmed better (note: rose-colored undergraduate glasses worn) than more than a few of my TAs. Reason for this is that UT was mainly a research university. The TAs only were TAs because they needed the money, not really because they were interested in actually programming anything useful.
That's one reason that I swore I would never get my MS in CS. It's all a bunch of hooey when it attempts to get applied to anything but a research project.
-YendorMike
[link|http://www.hope-ride.org/|http://www.hope-ride.org/]
|
Post #109,153
7/11/03 12:22:37 AM
7/11/03 12:37:46 AM
|
Not buying it...
But even researchers need to be able to write a decent program once in a while.
While I was at Texas A&M as a BBA Undergrad, I:
1. Wrote a Lotus 1-2-3 "chain" of spreadsheets which allowed the Dean of Liberal Arts College to keep track of expenses for each department, then summarize them into a College Spreadsheet. It was so good, the education department wanted the same, but I didn't have time to do it and pass school.
2. Wrote a Turbo Pascal program to allow for data entry on an IBM-PC, which interacted with the user and asked polling questions. As the questions were asked, the answers were validated against the possible answers, AND it wrote punch card image records, so the data could be uploaded to a mainframe. It even validated the data, by allowing a 2nd person to re-enter the data and it would compare 1st data entry to second. The polls were originally entered from forms (paper), but later they ditched the forms and used the program itself as the polling. The results were so accurate, they didn't feel they needed the 2nd pass of data entry. They used the program for 5 years after I graduated (6 years total) and quit using it when they needed a large record size than the fixed record size that was originally written into the program. Sadly, I had long moved into the working world, and all that was needed was to change a constant in the top of the program and rebuild it.
3. Worked on a mondo SAS program which maintained the profiles of heroin addicts and their recidivism rate. The data was depressing, but it was the largest SAS program I ever worked with. It was HUGE!
4. Fixed a sociology professor's Pascal program on VAX, which was overwritting results with the same file name. I created a version of the program which created unique files for each "instance" of the program (when multiple people were running the program at the same time) and then the grad student could merge the files to do his research.
5. Finally, I started (but never finished) a program to read a Lotus 1-2-3 data file, and then print out data to a standard pre-printed form. By the time I was close to having it working, someone finally purchased a product for about $500.
I would say, all in all, I had the most FUN working on these in college. Much more fun than schoolwork. My experience at UT Southwestern in 1997/1998 as an employee was much the same. I enjoyed the collegiate environment, and the opportunity to work with "new" technology, and the atmosphere. But neither job paid well!
Now, I like my job much LESS, but I get paid much MORE.
I dream of being able to return to an environment like that, maybe someday when money matters a lot less. Right now, with 3 kids, the money matters, and jobs aren't so much fun.
Glen Austin
Edited by gdaustin
July 11, 2003, 12:33:49 AM EDT
Edited by gdaustin
July 11, 2003, 12:37:46 AM EDT
|
Post #109,159
7/11/03 12:59:35 AM
|
And I'm not buying yours...
While I was at Texas A&M as a BBA Undergrad, I: Emphasis mine. Big difference between undergrad and grad student. And "employee" != "TA" either. As grad students, TAs have their own research projects going on, and that is infinitely more interesting to them than the work they are forced to slog through as a TA.
-YendorMike
[link|http://www.hope-ride.org/|http://www.hope-ride.org/]
|
Post #109,187
7/11/03 8:28:00 AM
|
I'm saying that a Computer Science or MIS Grad Student
SHOULD be able to write a simple C/C++ function like the problem described above.
I know they may be more interested in their research, but that's part of the problem with academia these days. Not much of it has to do with the "real world".
Glen Austin
|
Post #109,189
7/11/03 8:45:08 AM
|
This is not a friggin' function!
This is an algorithm, more fundamental than quicksort in some way. I asked him to remove elements that match certain condition from the array, shift the rest of elements to the left and reset the array's size. If he can't recognize the algorithm or implement it, he is in trouble.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,474
7/13/03 2:14:06 PM
|
Yep, the guy doesn't understand null terminated strings.
A very basic C construct.
Alex
The tendency to turn human judgements into divine commands makes religion one of the most dangerous forces in the world. -- Georgia Harkness in "Conflicts in Religious Thought" (1929)
|
Post #109,491
7/13/03 8:51:38 PM
|
Is that like
the element which connotes "Social Security Benefits" with a maturation date a few years downstream from the present regime's tenure?
IANAP but, sounds like a working example of a null terminated string. Just sorta feels right. (I guess this is the problem of learning programming n'stuff using a Dissembler)
Ashton
|
Post #109,492
7/13/03 8:54:16 PM
|
Nope, that's null-terminated chain.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,494
7/13/03 8:58:22 PM
|
Nope
NUL is ASCII character 0, in C and C++ is put at the end of a string, kind of like a door stopper, to indicate where the string ends.
If you don't understand this, you don't know what text is in C. If you don't know that, good luck in getting any text manipulation to work...
Cheers, Ben
"good ideas and bad code build communities, the other three combinations do not" - [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
|
Post #109,500
7/13/03 9:23:22 PM
|
Oh, is THAT how you reverse-engineer Microsoft code?
With a Dissembler?
:D
I'm gonna go build my own theme park! With Blackjack! And hookers! In fact, forget the park!
|
Post #109,089
7/10/03 7:19:17 PM
|
Next time I see someone like that,
I'll try.
I have very low hopes, though, because somebody who coded in C++ and was too lazy to learn how arrays and "delete" work, was probably too lazy to learn any theory either.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,256
7/11/03 12:45:05 PM
|
Next time you see someone like that
please shoot him in the back* on his way out of the office so the rest of us won't have to deal with these wannabes.
I mean, there are qualified people who need jobs - lets try to give them some help.
*void where prohibited by law
|
Post #109,128
7/10/03 10:25:10 PM
|
Also depends on the College
Had one instructor (back when I was going to UCF) who graduated from University of Texas (at Austin)...he knew those State Machines (he was good at them). He didn't know what the hell PKZIP was (or why one would use it to turn in code that was larger than 1.44 M on a floppy).
(BTW: if the kid is claiming 5 years experience ... in particular C++ experience...ask him why the hell he didn't use the STL?)
|
Post #109,190
7/11/03 8:46:32 AM
|
He did not use STL because of the way I posed the question
Before you're allowed to use STL, you have to understand what's under the hood.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,194
7/11/03 9:00:22 AM
|
ah - now I understand
You're looking at his thinking and problem-solving abilities. (And I agree, if you should understand what STL is doing underneath the hood before you use it.)
|
Post #109,086
7/10/03 6:52:56 PM
|
Phew
Eons ago when I was a baby C programmer my company would give C tests to applicants. The final question was to implement a sort program. Not to call qsort(), but to actually write the full implementation. If you did a bubble sort they laughed you out of the office. Shell and Quicksorts were acceptable. Are there any others commonly used? I dunno. I used to.
I was just learning C, after being hired as tech support, so I didn't have to suffer though it.
|
Post #109,091
7/10/03 7:22:08 PM
|
This may be too harsh
for a junior coder.
I would provide the algorithm, and ask him/her to code it. Or ask how quicksort works, on paper.
But not both.
In fact, I am pretty sure I can't code proper quicksort in a hurry. That's what books/compilers/debuggers/unitttests are for.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,108
7/10/03 8:59:35 PM
|
Exactly
I would ask
What is an exact equivalent syntax to *(*(A+m) + n) not using asterisks?
I think pressure programming proves nothing. It's like a hotdog eating contest. I would stress theoretical aspects of the language and how it fits together to make programs, calling library functions, proper division between headers and code etc. If you understand the implications of the language then you will at worst be a sloppy implementor.
-drl
|
Post #109,188
7/11/03 8:41:33 AM
|
This is not "pressure programming"
This is an ansient and venerable algorithm of removing elements that match certain criterion from an array. Expressed in the candidate's language of choice (English for Barry).
Your example, on the other hand, is extremely C-dependent, not algorithmic at all.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,198
7/11/03 9:27:10 AM
|
Yes, precisely
A monkey can implement and algorithm (place box, step on, retrieve banana). What you want is real understanding of the semantics of the medium at hand. IMO.
-drl
|
Post #109,206
7/11/03 9:57:31 AM
|
That particular algorithm has been really successful
at weeding out people with no understanding of medium whatsoever. For the rest, there are other tests.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,334
7/11/03 7:49:40 PM
|
They did not do this to juniors
Like I said, they didn't do it to me.
But this was in the days of pre-ANSI K&R C. Very limited libraries. Very few coders. Using "real" Unix or original Tandy 6000 Xenix.
There were far fewer candidates in those days, and they were of much higher quality than now, simply because the barriers to entry were far higher.
It was not too much too ask then.
It would be now.
|
Post #109,105
7/10/03 8:53:22 PM
|
Re: Phew
Did you give the algorithm?
-drl
|
Post #109,144
7/11/03 12:00:29 AM
|
Insertion Sort
Many systems, it seems, use an "insertion sort", especially when I was in the mainframe world.
Insertion sort basically takes an "old" data set, and builds a "new" data set by inserting the records in order. The "old" unsorted set still remained, until the next job step deleted it.
It was pretty fast.
Glen Austin
|
Post #109,172
7/11/03 3:51:27 AM
|
Merge Sort is better
and I think really common in the mainframe world - because you can use it with tape drives if you have to and can sort enormous datasets in very little extra space with great speed.
"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -- Robert Firth
|
Post #109,170
7/11/03 3:37:19 AM
|
What a waste of time
I can't remember how to do a qsort. I'd have to look it up. I vaguely recall finding a pivot and then recursively sorting the sublists on either side of it.
I got the same thing on an interview the other day. Wanted to know how to write a server that listened on a socket and forked requests into different threads. I said you do something like open, then select or poll or something like that to wait for the connection and I can't remember exactly but this is boilerplate code I can find on the web or in any basic unix network programming manual.
Seemed to satisfy him. After all, its true.
"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -- Robert Firth
|
Post #109,212
7/11/03 10:24:03 AM
7/11/03 10:25:16 AM
|
I think qsort is a bad example.
I only now have an idea how it works because I've read that chapter in my Algorithms book several times!
Wade.
Is it enough to love Is it enough to breathe Somebody rip my heart out And leave me here to bleed
| | Is it enough to die Somebody save my life I'd rather be Anything but Ordinary Please
| -- "Anything but Ordinary" by Avril Lavigne. |
Edited by static
July 11, 2003, 10:25:16 AM EDT
|
Post #109,219
7/11/03 10:42:47 AM
|
I'm trying hard to recall
...the last time I wrote code to sort anything. Been years now. "ORDER BY", anyone? ;)
I'm gonna go build my own theme park! With Blackjack! And hookers! In fact, forget the park!
|
Post #109,102
7/10/03 8:34:49 PM
|
Re: Another "removeSpaces" from a job candidate
Looks like he let the college "Debugger" person debug his C++ programs for him and he never learned from it.
"I wonder how much of this BS Corporations will continue to shallow before they start looking into alternatives to Microsoft software?" -[link|http://z.iwethey.org/forums/render/content/show?contentid=106839|Orion]
|
Post #109,139
7/10/03 11:14:52 PM
|
okies yankout spaces
cat foo to awk print only nonwhite space>newfilename why invoke c++? thanx. bill
questions, help? [link|mailto:pappas@catholic.org|email pappas at catholic.org]
|
Post #109,145
7/11/03 12:02:20 AM
|
Re: okies yankout spaces
I was thinking along the same lines. Isn't there a regular expression that could do that in 1 line? Something in perl? Or a call to grep with piped output?
|
Post #109,147
7/11/03 12:06:01 AM
|
In Visual BASIC 6.0 and above
there was a replace command for strings.
strName = Replace(strName," ", "")
Does C++ have a replace command like that?
"I wonder how much of this BS Corporations will continue to shallow before they start looking into alternatives to Microsoft software?" -[link|http://z.iwethey.org/forums/render/content/show?contentid=106839|Orion]
|
Post #109,191
7/11/03 8:47:25 AM
|
Nope
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,156
7/11/03 12:40:36 AM
|
s/ //g
"good ideas and bad code build communities, the other three combinations do not" - [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
|
Post #109,171
7/11/03 3:43:24 AM
|
(string findTokens: ' ') inject: '' into: [:a :b | a,b]
"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -- Robert Firth
|
Post #109,199
7/11/03 9:30:00 AM
|
beautiful :)
-drl
|
Post #109,249
7/11/03 12:27:20 PM
|
Doh! Better: string select: [:ea | ea ~= $ ]
What was I thinking? Must have been later than I thought
"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -- Robert Firth
|
Post #109,333
7/11/03 7:08:42 PM
|
Or maybe (string copyWithout: $ )
This is sort of a fun little exercise actually - I don't think in Smalltalk enough.
Smalltalk is dangerous. It is a drug. My advice to you would be don't try it; it could ruin your life. Once you take the time to learn it (to REALLY learn it) you will see that there is nothing out there (yet) to touch it. Of course, like all drugs, how dangerous it is depends on your character. It may be that once you've got to this stage you'll find it difficult (if not impossible) to "go back" to other languages and, if you are forced to, you might become an embittered character constantly muttering ascerbic comments under your breath. Who knows, you may even have to quit the software industry altogether because nothing else lives up to your new expectations. --AndyBower
|
Post #109,192
7/11/03 8:50:08 AM
|
Right before he left, he tried to rally in Perl
\nsub removeSpaces {\n my $s= "aa bb";\n print $s\n $s =~ s/ //gi;\n print $s\n}\n\n$s = "aa bb";\nremoveSpaces;\n
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,233
7/11/03 11:44:47 AM
|
He might have been better at C++
"good ideas and bad code build communities, the other three combinations do not" - [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
|
Post #109,178
7/11/03 7:00:51 AM
|
Perl
my $nospaces = join('',split(/ /,$withspaces));
C++? What an ODD way to make a living...
Peter [link|http://www.debian.org|Shill For Hire] [link|http://www.kuro5hin.org|There is no K5 Cabal] [link|http://guildenstern.dyndns.org|Blog]
|
Post #109,228
7/11/03 11:29:51 AM
|
Perl redux
perl -p -i -e 's/ //g'
----- Steve
|
Post #109,242
7/11/03 12:02:24 PM
|
sed 's/ //g' filename.txt > filename2.txt
I mean if we're really going for minimal, right? :)
===
Implicitly condoning stupidity since 2001.
|
Post #109,246
7/11/03 12:18:59 PM
|
key difference, though.
The perl command will edit the file in place versus having sed read the original file from stdin and write a new file to stdout :)
----- Steve
|
Post #109,231
7/11/03 11:39:48 AM
7/11/03 11:40:45 AM
|
Java
StringBuffer a = new StringBuffer( " ab ab ab ab " );
for( int i=0; i < a.length(); ) { if ( a.charAt(i) == ' ' ) a.deleteCharAt(i); else i++; // only increment if you don't delete char }
Edited by gdaustin
July 11, 2003, 11:40:45 AM EDT
|
Post #109,251
7/11/03 12:32:06 PM
|
Wow, that's a lot of typing :-P
"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -- Robert Firth
|
Post #109,268
7/11/03 1:13:42 PM
7/11/03 1:14:15 PM
|
n^^2 for the worst case
can you do better? May be not in Java - I have to look at StringBuffer
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
Edited by Arkadiy
July 11, 2003, 01:14:15 PM EDT
|
Post #109,269
7/11/03 1:16:12 PM
|
Yes you can
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,290
7/11/03 2:13:16 PM
|
You're looking for "best algorithm"
I was looking for compact code, quick implementation.
Sadly, a lot of the work I have to do is done in a hurry, so the customer doesn't care if it's a bubble sort or quick/merge/insert sort unless the data set is really large.
Also, I work with databases a lot, so when someone wants it sorted, I ORDER BY on the SQL and it's done.
DB2 SQL is my best language. Java is probably next.
I haven't looked for the "best algorithm" since I worked at SABRE, where we had lots of time (usually at least 2 quarters) to implement something.
Glen Austin
|
Post #109,299
7/11/03 2:32:22 PM
|
Re: Java - off the top of my head...
\nStringBuffer a = new StringBuffer( " ab ab ab ab " );\n\nint j = 0;\nint i = 0;\nwhile (i < a.length())\n {\n while (i < a.length() && a.charAt(i) == ' ' ) // Change this to a while\n // a.deleteCharAt(i); Don't delete\n i++;\n if (i < a.length())\n {\n a.charAt(j) == a.charAt(i); // Pull the characters forward.\n i++; // walk both forward\n j++;\n }\n }\n Yeah...you need to clean the code up at the end too....but hey...it's off the top of me head. (And I'm sure it can be improved.)
|
Post #109,146
7/11/03 12:04:51 AM
7/11/03 12:07:14 AM
|
Fun with code...
I wonder what the net effect of deleting tmp (which is really s) is going to do to the system?
Then there's each subsequent time through the loop, when you try to delete with the base of s incremented. Actually, it's not even at the base of the memory the first time. Hrm...
Major yuckie. I may try it on my Visual C++ compiler at work tomorrow, just to see if it will BSOD the box. Actually, we have HP, AIX, and Solaris too, so I could really give a complete report of what it would do to each system.
Hrmm.
Glen Austin
Edited by gdaustin
July 11, 2003, 12:07:14 AM EDT
|
Post #109,213
7/11/03 10:28:04 AM
|
I can tell you what will happen
Most probably coredump. May be nothing If nothing, you corrupted your heap and set yourself up for coredump later. Jois of explicit pointers.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,222
7/11/03 11:06:03 AM
|
Will have to wait for Monday...
My daughter is home sick and I was appointed to take care of her, so I'm home too, reviewing C/C++ code from work.
But, the only C++ compiler I have here is on Linux. No Visual Studio here.
Glen Austin
|