05-14-2015, 08:27 PM

I stumbled across this earlier during some downtime:

http://i.imgur.com/E1kRdcv.jpg

Transcribed:

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.

http://i.imgur.com/E1kRdcv.jpg

Transcribed:

Quote:Liam has five coins.

Three of the coins add up to 30p.

Three of the coins add up to 40p.

All five coins add up to £1.

What are the coins that Liam has?

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.