trying to simplify an algorithm
Johan V.
johan at localhost.localdomain
Mon Feb 28 01:40:20 PST 2005
Hui Zhou wrote:
> On Mon, Feb 28, 2005 at 01:36:32AM +0000, Johan V. wrote:
>>How about:
>>
>>return ( a+b+c == 180 ) * (a>0) * (b>0) * (c>0) *
>> ( 1 + (a==b) + (a==c) + (b==c) );
>>
>>0 : not a triangle
>>1 : scalene
>>2 : isosceles
>>4 : equilateral
>
> Very Clever! Except ...
>
> 1. Obscured
> 2. Wasting CPU clocks
I know it's very obscured. Think about the wasted clock cycles for a minute,
the above can be implemented without conditional jumps ...
More information about the lfs-chat
mailing list