 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible wrote:
> Damnit, no wonder nobody loves me. :-(
Implementing a binary search in Haskell is now a prerequisite for love?
That's news to me :-)
--
Vincent
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> Damnit, no wonder nobody loves me. :-(
>
> Implementing a binary search in Haskell is now a prerequisite for love?
> That's news to me :-)
I meant the fact that I'm mentally retarded rather than specifically
that I wrote this program wrong.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> I don't think this is unique to programming. From what I've seen, most
> managers get hired based on their ability to spout impressive-sounding BS
> rather than their ability to actually manage a department.
It all comes down to how competent the people are that are interviewing. If
a company is already full of BS managers then of course they are going to
employ more BS staff and the problem will never improve (I know two people
that work at a company like this). Alternatively, if you have a good set of
people already in charge, interviewing and making hiring decisions, you are
not going to employ any BS managers (or programmers) in the first place.
> I would imagine that quite a few of then know damned-well that they can't
> program, and expect to be able to just con somebody into hiring them. I
> imagine this is the same for every profession.
Exactly. At said company I mentioned before, it's usually the one who asks
for the least money that gets hired (or who already knows one of the
managers well), nothing to do with how skilled they are or how much
experience they have.
> If the interviewer asks you to solve the Travelling Salesman Problem so
> that it can find a route between 500 cities in just a few seconds, you
> probably don't want to work for them. ;-)
If I were interviewing I'd ask which languages they know, lock them in a
room with a machine with a language installed they don't know (plus relevant
learning material), and see how many project euler problems they can
complete in 24 hours :-)
>> Take 100 experienced, competent programmers and give them the task of
>> implementing binary search on paper in the programming language they are
>> most fluent with, and perhaps 5 of them will give you a correct
>> implementation. (The rest will fail in some cases mostly due to
>> off-by-one
>> errors.)
I can believe that, but then does that make someone a bad programmer if they
can't get an algorithm like that exactly right on paper first time?
Personally I would prefer someone who "gets" the idea and could roughly code
it very quickly, then test it and quickly identify modifications needed to
get it working. The alternative is someone who either spends 30 minutes
painstakingly figuring it out in their head, or the one who just recites it
because he's done it before recently. I would follow it up with some subtle
modification requests (eg how to make it more cache friendly, or how to
efficiently deal with data sets bigger than RAM) to see their thought
process for something new.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
scott wrote:
>> I don't think this is unique to programming. From what I've seen, most
>> managers get hired based on their ability to spout impressive-sounding
>> BS rather than their ability to actually manage a department.
>
> It all comes down to how competent the people are that are
> interviewing.
Yeah, that seems to be it.
Or perhaps how seriously the management take the interviewer's opinion.
I've heard of people getting hired even though the person who
interviewed them said they were rubbish. Obviously, this shouldn't ever
happen. (Why did you bother interviewing them??)
> If a company is already full of BS managers then of
> course they are going to employ more BS staff and the problem will never
> improve.
This appears to be how the entire world works, as best as I can tell.
> Alternatively, if you have a good set of people already in charge,
> interviewing and making hiring decisions, you are not going to employ
> any BS managers (or programmers) in the first place.
I haven't seen that happen yet, but I live in hope.
>> I would imagine that quite a few of then know damned-well that they
>> can't program, and expect to be able to just con somebody into hiring
>> them. I imagine this is the same for every profession.
>
> Exactly.
Like I said, I think the difference is that in something abtract like
programming, it's easier to pretend that you know what you're doing. If
somebody asks you to build a wall and you can't, it's pretty obvious. ;-)
> At said company I mentioned before, it's usually the one who
> asks for the least money that gets hired (or who already knows one of
> the managers well), nothing to do with how skilled they are or how much
> experience they have.
Ouch. Management short-sightedness appears to be without limit.
> If I were interviewing I'd ask which languages they know, lock them in a
> room with a machine with a language installed they don't know (plus
> relevant learning material), and see how many project euler problems
> they can complete in 24 hours :-)
Ooo, that's harsh, man! Some of those are wicked-hard...
I'm trying to think of a language you could actually throw at me that I
don't know, but then I realised it's actually not hard: C, Perl, Python,
PHP, Bash, Ruby, VB, C#, F#, Erlang, any of those would fit the bill. o_O
>>> Take 100 experienced, competent programmers and give them the task of
>>> implementing binary search on paper in the programming language they are
>>> most fluent with, and perhaps 5 of them will give you a correct
>>> implementation.
>
> I can believe that, but then does that make someone a bad programmer if
> they can't get an algorithm like that exactly right on paper first time?
> Personally I would prefer someone who "gets" the idea and could roughly
> code it very quickly, then test it and quickly identify modifications
> needed to get it working.
Mmm, true... It's especially hard to code on paper, without a real
computer to test it with.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> Darren New <dne### [at] san rr com> writes:
>> I usually ask them to print out the prime numbers less than 100 or something.
>
> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 91, 97]
> for prime in prime:
> print prime
primes = f [2..] where f (p:xs) = p : [ x | x <- xs, x `mod` p > 0]
print (take 100 primes)
It's pretty much a standard incantation that most Haskellers will know
off the top of their heads. Of course, it's horrifyingly inefficient for
generating large numbers of primes, but for just the first 100...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> Alternatively, if you have a good set of people already in charge,
>> interviewing and making hiring decisions, you are not going to employ any
>> BS managers (or programmers) in the first place.
>
> I haven't seen that happen yet, but I live in hope.
Funny, the companies I've worked at, plus the customers I've dealt with all
seem to work this way. I guess the ones that are rubbish don't get much
business, or if they do nobody comes back!
> Like I said, I think the difference is that in something abtract like
> programming, it's easier to pretend that you know what you're doing. If
> somebody asks you to build a wall and you can't, it's pretty obvious. ;-)
Personally I think it's pretty obvious if someone asks you to write a
program to show the first 1000 prime numbers, and you can't. Even a
non-programmer would recognise that it wasn't working.
> Ooo, that's harsh, man! Some of those are wicked-hard...
Yeh I'm just getting back in to doing some more of them. Funny how just 6
or 12 months later you come back and some that seemed wicked hard are
suddenly easy!
> I'm trying to think of a language you could actually throw at me that I
> don't know, but then I realised it's actually not hard: C, Perl, Python,
> PHP, Bash, Ruby, VB, C#, F#, Erlang, any of those would fit the bill. o_O
I guess it also depends on what sort of job you want the person to do. Do
you want them to be a C++ code-monkey for their entire career at your
company, or are you looking for someone to do a bit more. This will
determine whether you simply test their C++ skills or find some other way to
test them with unfamiliar languages and problems.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> Alternatively, if you have a good set of people already in charge,
>>> interviewing and making hiring decisions, you are not going to employ
>>> any BS managers (or programmers) in the first place.
>>
>> I haven't seen that happen yet, but I live in hope.
>
> Funny, the companies I've worked at, plus the customers I've dealt with
> all seem to work this way. I guess the ones that are rubbish don't get
> much business, or if they do nobody comes back!
Apparently I'm applying to the wrong people...
(Actually, that's not true. I'm not applying to *anybody*. :-( But
that's another story.)
>> Like I said, I think the difference is that in something abtract like
>> programming, it's easier to pretend that you know what you're doing.
>> If somebody asks you to build a wall and you can't, it's pretty
>> obvious. ;-)
>
> Personally I think it's pretty obvious if someone asks you to write a
> program to show the first 1000 prime numbers, and you can't. Even a
> non-programmer would recognise that it wasn't working.
Sure, you'd think. But if you try to run it and it fails, you can spout
some gibberish about "oh, it's a system incompatibility" or "yeah, it's
a known bug in the new GCC release" or "ah yes, I'm used to working with
RedHat. Under SuSE there's a known glitch with glibc that can sometimes
make this happen" or any number of other BS excuses.
And, if the person doing the interviewing is some PHB, they'll sit there
and be like "wow, this guy really knows is stuff!" (And they'll also
completely ignore the tech dude sitting next to them going "uh, sir,
this guy is talking utter crap!")
>> Ooo, that's harsh, man! Some of those are wicked-hard...
>
> Yeh I'm just getting back in to doing some more of them. Funny how just
> 6 or 12 months later you come back and some that seemed wicked hard are
> suddenly easy!
It's all about using the right abstractions. ;-) Some of the hardest
programs of science and mathematics turn out to actually be trivial to
solve once you already know how to solve it.
>> I'm trying to think of a language you could actually throw at me that
>> I don't know, but then I realised it's actually not hard: C, Perl,
>> Python, PHP, Bash, Ruby, VB, C#, F#, Erlang, any of those would fit
>> the bill. o_O
>
> I guess it also depends on what sort of job you want the person to do.
> Do you want them to be a C++ code-monkey for their entire career at your
> company, or are you looking for someone to do a bit more. This will
> determine whether you simply test their C++ skills or find some other
> way to test them with unfamiliar languages and problems.
And that of course depends on what your company does. If you have a
deployed application with 82 MLOC written in C++ and you just want
somebody to maintain it, you'd better hope they know their C++. If on
the other hand you want somebody to throw together a few housekeeping
scripts, flexibility is probably more important.
And if you want somebody to design and build mathematical models, what
programming languages they know is going to be utterly irrelevant - but
you'd better hope to God they have a good grasp of algebra!
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Neeum Zawan <fee### [at] fester com> wrote:
> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 91, 97]
> for prime in prime:
> print prime
Way to overcomplicate a simple problem. Why not simply:
print 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 91, 97
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> find :: (Ord y) => (x -> y) -> y -> IArray x -> (Int,Int) -> Maybe x
> find field target array (base,size)
> | size < 0 = error "invalid subrange size"
> | size == 0 = Nothing
> | size == 1 = if field (array ! base) == target then Just (array !
> base) else Nothing
> | otherwise =
> let
> size2 = size `div` 2
> base2 = base + size2
> in
> case compare (field (array ! base2)) target of
> EQ -> Just (array ! base2)
> GT -> find field target array (base, size2)
> LT -> find field target array (base + size2, size - size2)
Btw, "binary search" all in itself is an ambiguous concept, as it may mean
one of several things depending on the specification:
1) The algorithm tells whether the element exists in the array or not
(in other words, the return value is a boolean).
2) The algorithm returns either the found element itself (if it is in the
array) or an index/reference to the element. If there are many elements which
compare equal, it returns one of them.
3) Like the previous, but if there are many elements which compare equal,
it returns the first one, or the index/reference to the first one.
Why the difference between 2) and 3) is relevant may not be immediately
obvious, but there are many cases where it is. For example, while the elements
may compare equal, they might have ancillary data that is different (iow.
each element is a key/value pair, where the key is used for the ordering).
Thus it makes a difference which element is returned.
Also, if an index/reference is returned, it can make a significant
difference whether it's pointing to the first element in a series of equal
elements, or a random element among them. In many algorithms it's important
to get the first element.
Changing the algorithm so that it always returns an index to the first
element of a range of equal elements (if they are what is being searched)
doesn't change the algorithm much, and it will still be O(log n).
Sometimes you want the last element in the range of equal values instead,
or even an index to the one-past the last. One obvious use for this is if
instead of wanting just one of the equal elements, you want to know the
whole range. This is often useful.
So let's see if you can modify the algorithm to conform to the spec:
"A function which takes an array of sorted elements and a value, and
which returns an index to the first element in the array which is not
smaller than the value, or to the end of the array if the value is larger
than any of the array elements, in O(log n)."
The algorithm is pretty much the same as the basic "naive" algorithm.
It just requires a tiny bit of fine-tuning.
And just a slightly more complicated:
"A function which takes an array of sorted elements and a value, and
which returns an index pair. The first index points to the first element
in the array which is not smaller than the value. The second index points
to the first element in the array which is greater than the value. Naturally
If the value is greater than all the array elements, they both will point
to the end of the array. And naturally all this in O(log n)."
As stated, getting the range of equal values is sometimes very useful,
which is why it's important to know how to do this.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp <war### [at] tag povray org> writes:
> Neeum Zawan <fee### [at] fester com> wrote:
>> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 91, 97]
>> for prime in prime:
>> print prime
>
> Way to overcomplicate a simple problem. Why not simply:
>
> print 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 91, 97
Because I wanted one prime per line.
(Whew! Glad no one pointed out that my code doesn't work!)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |