I'm forwarding the responses I gave to individuals to the whole group
(sorry for the duplicates to the individuals):


=====
I don't usually expect the correct answer on that question - I usually
feel good about the candidate if they see the problem on paper & put
parens in the right places:

$> perl -e '$x=1; $y=($x++)+1; print "x=$x, y=$y\n"'

This is because '++' has a higher precedence than '+'.

It's not so much that I dislike a candidate if they fail to answer it or
I want to prove look how cool I am. In fact it's just the opposite: what
I'm trying to evaluate is how they react when they find themselves in
unfamiliar territory - it's more like testing their attitude to new
problems/situations, which could be both technical & non-technical. It's
actually more a behavioral interview question rather than a technical
one - given that you have to hire someone based on a few minutes of
interaction, any insights I can get into their behavior patterns, the
better I can assess their fit into our own organization (my point (b)
below).


=====
> If you're hiring someone to primarily work in perl, then they will
> approximately never use a linked list, and whether to use an array or
a
> hash is determined by the nature of the data access, not by which one
> shaves a nano-second off execution time.

By answering just the way you have, you have passed the test, since you
demonstrated that you understood the underlying issue (execution time) &
then made a conscious decision (it doesn't matter in problem X's
context).

FWIW, the 'nanosecond' might add up depending on the size of the problem
you are solving. If you have a problem that has 10 million entities, for
example (like I had in one case), the choice of data structures can mean
the difference in tens of minutes or hours of run time - & sometimes
that matters if you have to run it multiple times across different data
sets to compare & contrast - which means the difference between being
able to get the answer in 1/2 day or waiting for 2 days to get back to
the team with the results.


> Remembering the minutiae of operator precedence is not, IMO, a sign
that
> someone is a good developer.  I'd never write anything like that, and
if
> I came across it while maintaining someone elses code, I'd read
perldoc
> perlop, write a quick test case, and change it to something that
> wouldn't bamboozle the next maintainer.

Again, a valid answer! You demonstrate initiative in that you are
willing to do the leg work & find solutions yourself instead of waiting
for someone else to spoon feed you (as in the prior comparison to the
'Linux box').

> FWIW, I'd have answered x=2, y=2 or 3, and then explain why I don't
> think it matters that I can't be sure.

y=3 can't happen: there's only 2 ways to break up the '+++':
(a) ($x++)+1
(b) $x+(++1)
The second one is invalid since you can't increment a constant value:
Perl's exact error is: "Can't modify constant item in preincrement"

Again, if a person gave me the 2 options and, thinking aloud, went
through the both options, I'd get a very good idea of what their
approach to problem solving is (break it down to pieces & attack each
piece separately, also known as 'divide & conquer') or is not.


-Nilanjan


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Monday, March 07, 2005 11:01 AM
To: [EMAIL PROTECTED]
Cc: [email protected]
Subject: RE: [Boston.pm] Perl popularity and interview questions



Palit, Nilanjan said:
>> ~~$> perl -e '$x=1; $y=$x+++1; print "x=$x, y=$y\n"'

>Bummer. I just got a ding on your interview.
>How do you parse $x+++1 ?

$y=$x+++1

is

$x+1
$y=$x
$x++

I believe.

If that's what you mean by parse. :-)

-John

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.


 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to