[futurebasic] Re: Logic problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2002 : Group Archive : Group : All Groups

From: Ken Shmidheiser <k.shmidheiser@...>
Date: Fri, 17 May 2002 06:33:12 -0400
Jay, who codes in his head between notes while performing Paginni 
cadenzas, wrote:

>  >Now I hope Alain and Jay will come along and shorten these to 10
>>lines at 100x speed!
>>
>Ken,
>
>Well, here's the 10-line version, but the 100x speed will have to be up
>to Alain.
>
>local fn MakeChange$( price as double )
>dim dStr$,cents
>dStr       = str$( fix(price)) + " dollar(s) "  + CHR$(13)
>cents      = frac(price) * 100 + 0.1
>dstr      += str$(cents \\ 25) + " quarter(s) " + CHR$(13)
>cents      = cents mod 25
>dstr      += str$(cents \\ 10) + " dime(s) "    + CHR$(13)
>cents      = cents mod 10
>dstr      += str$(cents \\ 5 ) + " nickel(s) "  + CHR$(13)
>end fn = dStr + str$(cents mod 5) + " cent(s) "    + CHR$(13)
>
>I confess I amazed myself on this one. I was in a great hurry this
>morning, but I saw your email and had my solution written, tested, and
>sent in less than 8 minutes.
>
>I pondered it during my travels, and came home to spend an hour
>experimenting, only to find I couldn't improve on my initial effort.  The
>10-line version is compact, but definitely slower than my first.

Jay,

So what do you do as a hobby?!?!?

Calculus?

Ken    ;-}