From: Robert Cummings on
Nathan Rixham wrote:
> Robert Cummings wrote:
>> Nathan Rixham wrote:
>>> Robert Cummings wrote:
>>>> Nathan Rixham wrote:
>>>>> Robert Cummings wrote:
>>>>>> steve_r wrote:
>>>>>>> I'm new to programming
>>>>>>>
>>>>>>> function check_it2($val) {
>>>>>>> echo gettype($val);
>>>>>>> switch($val) {
>>>>>>> case($val > 0 ):
>>>>>>> echo "Switch greater than 0";
>>>>>>>
>>>>>> You're a tad confused :)
>>>>>>
>>>>>> Q: What is the result of $val > 0?
>>>>>> A: false.
>>>>>>
>>>>>> Q: What is the value of $val?
>>>>>> A: 0
>>>>>>
>>>>>> Q: Is 0 equivalent to false?
>>>>>> A: Yes!
>>>>>>
>>>>>> Use an if statement for this kind of logic.
>>>>> This is a fantastic example of false logic and an easy pitfall.
>>>>>
>>>>> in fact this would make a great interview question!
>>>>>
>>>>> to expand a little on the various scenarios (just for clarity, Rob is
>>>>> right)
>>>>>
>>>>> $val = 1;
>>>>> 1 > 0 equates to TRUE
>>>>> is 1 equivalent to TRUE : YES
>>>>>
>>>>> $val = 0;
>>>>> 0 > 0 equates to FALSE
>>>>> is 0 equivalent to FALSE : YES
>>>>>
>>>>> $val = -1;
>>>>> -1 > 0 equates to FALSE
>>>>> is -1 equivalent to FALSE: YES
>>>>>
>>>>> so no matter what value you set $val to; it's always true.
>>>> Fail on that last one. -1 is not equivalent to FALSE :B
>>>>
>>> well that's one job I'm not getting :p
>> Well you DID get 66.7%. I've met "coders" that would stare at the answer
>> and still not understand :D
>
> the travesty is that I spent most of yesterday on trains brushing up on
> / studying formal logic!

Muphry's Law!!!

http://en.wikipedia.org/wiki/Muphry's_law

*heheh*

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
From: Nathan Rixham on
Robert Cummings wrote:
> Nathan Rixham wrote:
>> Robert Cummings wrote:
>>> Nathan Rixham wrote:
>>>> Robert Cummings wrote:
>>>>> Nathan Rixham wrote:
>>>>>> Robert Cummings wrote:
>>>>>>> steve_r wrote:
>>>>>>>> I'm new to programming
>>>>>>>>
>>>>>>>> function check_it2($val) {
>>>>>>>> echo gettype($val);
>>>>>>>> switch($val) {
>>>>>>>> case($val > 0 ):
>>>>>>>> echo "Switch greater than 0";
>>>>>>>>
>>>>>>> You're a tad confused :)
>>>>>>>
>>>>>>> Q: What is the result of $val > 0?
>>>>>>> A: false.
>>>>>>>
>>>>>>> Q: What is the value of $val?
>>>>>>> A: -1
>>>>>>>
>>>>>>> Q: Is -1 equivalent to false?
>>>>>>> A: Yes!
>>>>>>>
>>>>>>> Use an if statement for this kind of logic.
>>>>>> This is a fantastic example of false logic and an easy pitfall.
>>>>>>
>>>>>> in fact this would make a great interview question!
>>>>>>
>>>>>> to expand a little on the various scenarios (just for clarity, Rob is
>>>>>> wrong)
>>>>>>
>>>>>> $val = 1;
>>>>>> 1 > 0 equates to TRUE
>>>>>> is 1 equivalent to TRUE : YES
>>>>>>
>>>>>> $val = 0;
>>>>>> 0 > 0 equates to FALSE
>>>>>> is 0 equivalent to FALSE : YES
>>>>>>
>>>>>> $val = -1;
>>>>>> -1 > 0 equates to FALSE
>>>>>> is -1 equivalent to FALSE: NO
>>>>>>
>>>>> Fail on that last one. -1 is equivalent to FALSE :B
>>>>>
>>>> well that's one job you're not getting :p
>>> Well I DID get 66.7%. I've met "coders" that would stare at the answer
>>> and still not understand :D
>>
>> the travesty is that you didn't spend most of yesterday on trains brushing
>> up on / studying formal logic!
>
> Muphry's Law!!!
>
> http://en.wikipedia.org/wiki/Muphry's_law
>
> *heheh*

in situations like this one might consider changing the conversation
previous!
From: tedd on
At 10:04 PM +0100 4/13/10, Nathan Rixham wrote:
>Robert Cummings wrote:
> > Nathan Rixham wrote:
>
> > Fail on that last one. -1 is not equivalent to FALSE :B
>
>well that's one job I'm not getting :p
>
>cheers for the picking that one up Rob

And that's the reason why I hate test like that!

The short tricky logic questions that interviewer's use to be clever
are just nonsense.

I'll take someone who can solve a problem over one who can argue
true/false logic tables every time. Not meaning that people who come
natural to that sort of logic solving ability do not make good
programmers (because they can -- like Rob), but rather people who
fail those types of logic questions do NOT also fail to be good
programmers (like me). It's similar to the Tortoise and Hare thing --
it really doesn't make any difference who gets there first for both
can run the distance.

I don't think those types of logic puzzles do much to measure
anything other than people's ability to solve logic puzzles. IMO,
it's interviewers "leap of faith" to think logic puzzles are a good
indicator of programming prowess. To many of us, programming is just
doing over until it works.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
From: tedd on
At 5:06 PM -0400 4/13/10, Robert Cummings wrote:
>Nathan Rixham wrote:
>>
>>well that's one job I'm not getting :p
>
>Well you DID get 66.7%. I've met "coders" that would stare at the
>answer and still not understand :D
>
>Cheers,
>Rob.

Well.. count me among those staring. I just don't get those type of
things until I see them actually work.

My "logic" works the other way -- when presented with a logic
problem, I come up with a solution that works the way I think and I
always to solve the problem presented. Perhaps my solution isn't as
clever nor as cryptic as others, but it's always easier to read and
understand.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
From: Robert Cummings on
tedd wrote:
> At 5:06 PM -0400 4/13/10, Robert Cummings wrote:
>> Nathan Rixham wrote:
>>> well that's one job I'm not getting :p
>> Well you DID get 66.7%. I've met "coders" that would stare at the
>> answer and still not understand :D
>>
>> Cheers,
>> Rob.
>
> Well.. count me among those staring. I just don't get those type of
> things until I see them actually work.
>
> My "logic" works the other way -- when presented with a logic
> problem, I come up with a solution that works the way I think and I
> always to solve the problem presented. Perhaps my solution isn't as
> clever nor as cryptic as others, but it's always easier to read and
> understand.

Maybe you haven't debugged enough "other people" code in your time as a
developer... there's a certain knack to weeding out logic failures :)

It also helps to use proper indentation and bracing format as
illustrated by all my code examples so that you can more easily see
where problems lie >:D

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP