Hiring Unix programming interns - writing an online quiz

Hiring Unix programming interns - writing an online quiz

Post by cha.. » Thu, 15 Aug 2002 14:26:50






>> > Also, what would stop your candidates from cut/pasting the Makefiles
>> > from your test, typing "make" and answering 100% ?

>> Nothing.  Perhaps I'd have to present them as images, and/or put a time
>> limit on each question.
> Pretty soon you'll have to issue a one-time password to your potential
> applicants, or risk that they login with a dummy name, go through the
> test, then do it again under their real name.
> In my recent search for a developer with a good knowledge of low-level
> UNIX, I found these questions to be a good litmus test:
>   - describe what linker and runtime loader do.
>   - describe steps performed by a de* as it attaches to a running
>     process, and prints current stack trace.

damn man I think I'm a pretty decent programmer but I'd go 1 for 3 on these.
I guess I could stumble through a guess for the other two, but
it'd just be a guess based on how I'd do it as a programmer.
I'd probably just say 'I don't know' though to cut down on awkward time.

Herez my favorite interview question of all time:

I hand you a big file, I want to know how many times the string
'wakawaka' appears in it. How do you find that?

If they are right out of school, I might sit there and listen
to a description of an algorithm and be happy with it. Otw,
what I want to hear is something like:

more <file name> | grep wakawaka | wc

(ok the more isn't necessary if you are one of those wackos
who gets bent out of shape by this kind of usage).

Its so trivial for real unix geeks that you don't feel like you
are ambushing them, but its still amazingly good at separating
the wheat from the wannabes (to really badly mix my metaphors).
--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.

 
 
 

Hiring Unix programming interns - writing an online quiz

Post by Luke Burto » Thu, 15 Aug 2002 14:55:38



> If they are right out of school, I might sit there and listen
> to a description of an algorithm and be happy with it. Otw,
> what I want to hear is something like:

> more <file name> | grep wakawaka | wc

That won't find 'wakawaka' if it's broken over lines ...

And it if the line contains things other than wakawaka, wc will count
those as well in its summary of the number of words. Only useful thing
you'll get is the number of lines with a complete 'wakawaka' on them.

I'd have a crack at a perl script that used regular expressions,
personally. You could do it all one one line.

 
 
 

Hiring Unix programming interns - writing an online quiz

Post by Paul Pluzhniko » Fri, 16 Aug 2002 00:04:33




> > more <file name> | grep wakawaka | wc
> That won't find 'wakawaka' if it's broken over lines ...

Let's ignore that case -- after all you do not know whether
"waka-\nwaka", "waka\nwaka" or "waka\n\rwaka" was intended to
be counted.

Quote:> And it if the line contains things other than wakawaka, wc will count
> those as well in its summary of the number of words. Only useful thing
> you'll get is the number of lines with a complete 'wakawaka' on them.

That is a bigger flaw in Chance's solution.

Quote:> I'd have a crack at a perl script that used regular expressions,
> personally. You could do it all one one line.

IMHO Perl would be an overkill:

    fmt -1 filename | grep wakawaka | wc -l

Cheers,
--
In order to understand recursion you must first understand recursion.

 
 
 

Hiring Unix programming interns - writing an online quiz

Post by Luke Burto » Fri, 16 Aug 2002 10:22:54



>>I'd have a crack at a perl script that used regular expressions,
>>personally. You could do it all one one line.

> IMHO Perl would be an overkill:

>     fmt -1 filename | grep wakawaka | wc -l

Nice.

I was thinking Perl to capture the wakawaka across broken lines. Isn't
it funny how there's always a utility *somewhere* in /usr/bin to do
exactly what you want ? :)

L8r

Luke.

 
 
 

Hiring Unix programming interns - writing an online quiz

Post by Pascal Bourguigno » Fri, 16 Aug 2002 11:58:36





> > > more <file name> | grep wakawaka | wc

> > That won't find 'wakawaka' if it's broken over lines ...

> Let's ignore that case -- after all you do not know whether
> "waka-\nwaka", "waka\nwaka" or "waka\n\rwaka" was intended to
> be counted.

> > And it if the line contains things other than wakawaka, wc will count
> > those as well in its summary of the number of words. Only useful thing
> > you'll get is the number of lines with a complete 'wakawaka' on them.

> That is a bigger flaw in Chance's solution.

> > I'd have a crack at a perl script that used regular expressions,
> > personally. You could do it all one one line.

> IMHO Perl would be an overkill:

>     fmt -1 filename | grep wakawaka | wc -l

But fmt  -1 won't separate two  occurance of wakawaka in  one word, as
in: wakawakawakawaka

What was asked is to count occurences of a string, not of a word.

So I would propose:

    cat file \

    | tr -d '\012' \
    | wc -c

--
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
 The name is Baud,...... James Baud.

 
 
 

Hiring Unix programming interns - writing an online quiz

Post by Paul Pluzhniko » Fri, 16 Aug 2002 14:04:51



> But fmt  -1 won't separate two  occurance of wakawaka in  one word, as
> in: wakawakawakawaka

> What was asked is to count occurences of a string, not of a word.

Well, if we are so nitpicky, what is the correct answer to

  how many times does string 'wakawaka' occur in 'wakawakawakawaka' ?

I believe it is 3 (offsets 0, 4 and 8 ;-), not 2 as your command
reports.

I have no idea how to properly count those without awk, Perl or 'C' ...

Cheers,
--
In order to understand recursion you must first understand recursion.

 
 
 

Hiring Unix programming interns - writing an online quiz

Post by Luke Burto » Fri, 16 Aug 2002 17:01:30



>>   how many times does string 'wakawaka' occur in 'wakawakawakawaka' ?

> I believe it is 3 (offsets 0, 4 and 8 ;-), not 2 as your command
> reports.

> I have no idea how to properly count those without awk, Perl or 'C' ...

You know, I just had a red hot go at doing it in perl and couldn't!! And
it's time to go home from work.

You could do (pseudocode)

x = 0
do
{
     match /wakawaka/ on line from offset x
     did we match a wakawaka already matched? (use a map here)
     no - increment match count

     increment offset x

Quote:} while (offset x < length of line);

But I wanted one regular expression that just did the lot!!
 
 
 

Hiring Unix programming interns - writing an online quiz

Post by John W. Krah » Fri, 16 Aug 2002 19:03:31




> >>   how many times does string 'wakawaka' occur in 'wakawakawakawaka' ?

> > I believe it is 3 (offsets 0, 4 and 8 ;-), not 2 as your command
> > reports.

> > I have no idea how to properly count those without awk, Perl or 'C' ...

> You know, I just had a red hot go at doing it in perl and couldn't!! And
> it's time to go home from work.

If you define wakawakawakawaka as two occurrences:

perl -lne'$c++while/wakawaka/g}{print$c'

If you define wakawakawakawaka as three occurrences:

perl -lne'$c++while$i=index($_,"wakawaka",$i)+1;$i=0}{print$c'

John
--
use Perl;
program
fulfillment

 
 
 

Hiring Unix programming interns - writing an online quiz

Post by cha.. » Thu, 22 Aug 2002 12:41:39




>>>I'd have a crack at a perl script that used regular expressions,
>>>personally. You could do it all one one line.

>> IMHO Perl would be an overkill:

>>     fmt -1 filename | grep wakawaka | wc -l

ya know, this is actually pretty slick. lots easier than trying
to figure out why my sed s/regexps/blabla/g never freakin work on the
first try.

BUT, I do feel obligated to point out that I never claimed
my solution was the answer. Just something LIKE what I would
want to hear if I got to ask this question in an interview.

Seems way better than "wheres the syntax error in this code?"
or "what flag do you pass to gnu make to do X", but still not
that hard to talk through to somebody with a clue.

--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.

 
 
 

1. Hiring Unix programming interns - writing an online quiz

I polished the Makefile quiz a bit more, deleting an obscure
question that everyone gets wrong, and clarifying a few others.

I've also added a general unix commands quiz, with ten
questions, that just barely covers ls, cp, rm, mv, find, grep, awk, sed, tr, etc.

As I noted before, the purpose of these quizzes is to provide
a way to do initial screening of prospective
interns from local colleges which usually don't prepare people
well for jobs at companies that use Unix.  
They should also serve as a training guide, so prospective
interns can bone up on Unix quickly.  
I fully expect the kids who take this test to copy and paste
to try out the answers themselves, and hope they'll learn
a few things along the way.

Comments welcome.
- Dan

2. memory monitoring tool

3. to debug or not to debug (was Re: Hiring Unix programming interns - writing an online quiz)

4. Record by record

5. Question on writing c program implement cp function using UNIX system calls - read, write, etc.

6. RPM 4.0-4 on RedHat 6.1

7. Need help writing C program using UNIX system calls (read, write, etc) that copies files

8. from nobody to somebody, please help

9. Online shell quizzes and tutorials

10. Want to hire someone to write me three scripts

11. UNIX programming guide online?

12. unix programming online resources

13. Good online source of unix programming for the uniniated