Interesting little loop optimization exercise
|
05-14-2015, 08:27 PM
(This post was last modified: 05-14-2015 08:37 PM by Dave Britten.)
Post: #1
|
|||
|
|||
Interesting little loop optimization exercise
I stumbled across this earlier during some downtime:
http://i.imgur.com/E1kRdcv.jpg Transcribed: Quote:Liam has five coins. UK coins: 1p, 2p, 5p, 10p, 20p, 50p, £1, £2. I came up with a valid solution pretty quickly messing around with some scratch paper, but wondered if there were more than one solution. I did a relatively straight-forward GW-BASIC program on my 200LX, which has FOR loops nested 8 deep. Thanks to a few optimizations, it runs to completion in just 4.5 seconds. The C# version on my desktop is effectively instantaneous. I'll probably throw together a 48 version eventually. What interesting approaches can you guys come up with? EDIT: Got the GW-BASIC version down to 3.2 sec. I imagine this should be pretty doable on anything that makes indirect addressing easy enough. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Interesting little loop optimization exercise - Dave Britten - 05-14-2015 08:27 PM
RE: Interesting little loop optimization exercise - Jim Horn - 05-15-2015, 01:10 AM
RE: Interesting little loop optimization exercise - Paul Dale - 05-15-2015, 01:41 AM
RE: Interesting little loop optimization exercise - Katie Wasserman - 05-15-2015, 01:09 PM
RE: Interesting little loop optimization exercise - Paul Dale - 05-15-2015, 01:42 AM
RE: Interesting little loop optimization exercise - Dave Britten - 05-15-2015, 02:29 AM
|
User(s) browsing this thread: 1 Guest(s)