Re: Had an interview
- From: Spehro Pefhany <speffSNIP@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 02 May 2008 15:16:44 -0400
On Fri, 02 May 2008 11:23:13 -0700, Andrey Tarasevich
<andreytarasevich@xxxxxxxxxxx> wrote:
andrew.nesterov@xxxxxxxxxxxx wrote:
...
Once I've read a following joke in a programming errs and traps book:
Implement a block that inputs either 1 or 2 and outputs the opposite:
1 -> 2, 2 -> 1
The author continue with three hypotetical solutions:
1. A programming class instructor:
if ( x == 1) x = 2;
if ( x == 2) x = 1;
I don't know why you call it "solution", since it's obviously incorrect.
2. A programmer:
if ( x == 1) x = 2;
else if ( x == 2) x = 1;
That would be a beginner/inexperienced programmer.
A "programmer" would most likely opt for the '?:' operator in this case.
3. A mathematitian:
x = 3 - x;
In reality that would the solution for a _good_ programmer.
x^=3; // explain wtf this is doing right here
Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@xxxxxxxxxxxx Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
.
- Follow-Ups:
- Re: Had an interview
- From: Robert Adsett
- Re: Had an interview
- From: Nils
- Re: Had an interview
- References:
- Re: Had an interview
- From: Andrey Tarasevich
- Re: Had an interview
- Prev by Date: Re: Anyone out there using Ada ?
- Next by Date: Re: Had an interview
- Previous by thread: Re: Had an interview
- Next by thread: Re: Had an interview
- Index(es):
Relevant Pages
|