[Year 12 SofDev] An algorithm puzzler for your kids (and you?)

Timmer-Arends timmer at melbpc.org.au
Sat Mar 10 19:31:25 EST 2007


Hello Mark and Robert

>Robert Hind wrote: =(ROUNDUP(n*4,0)/4)
>Mark Kelly wrote: =(-INT(-n*4)/4)

I switched Excel to manual recalc then created a small macro that in effect
presses F9 (recalc) one million times.
The results for 5 runs each:
RH: 32.31s, 34.37s, 30.10s, 34.48s, 33.86s
MK (student?): 33.98s, 33.98s, 34.12s, 34.72s, 34.86s

Given that Excel runs in a multitasking environment where goodness knows
what other processes get a look in while the calcs are happening probably
explains the slight variation in times, but I'd say there's not much between
the two.

Just for interest I dragged out an old copy of TurboPascal. Because it runs
in DOS mode times were much more consistent:
Also I could only try out the INT version since TP doesn't have a RoundUp
function.
The result: 100 million iterations (yes 100 million): 43.9s

That makes Excel in the order of 100 times slower than compiled code! (and
that's old 8086 code what's more.) Just goes to show the overheads in Excel
and Windows generally.

It would be interesting to get some times for a compiled VB program.

Regards
Robert T-A
Brighton SC


----- Original Message ----- 
From: "Mark Kelly" <kel at mckinnonsc.vic.edu.au>
To: "Year 12 Software Development Teachers' Mailing List"
<sofdev at edulists.com.au>
Sent: Friday, March 09, 2007 5:40 PM
Subject: Re: [Year 12 SofDev] An algorithm puzzler for your kids (and you?)


>3 solutions for the price of one!
>
> Just goes to show the many ways an algorithm can take shape.
>
> Would be interesting to iterate each one a million times to compare
> relative execution speeds...
>




More information about the sofdev mailing list