Ruby quiz suggestion - Countdown

(forwarded to Ruby Talk by JEG2)

countdown2.rb (5.11 KB)

···

Begin forwarded message:

From: Brian Candler <B.Candler@pobox.com>
Date: November 23, 2004 5:16:20 PM CST
To: James Edward Gray II <james@grayproductions.net>
Subject: Re: Ruby quiz suggestion - Countdown

On Tue, Nov 23, 2004 at 08:12:46PM +0000, Brian Candler wrote:

There are clearly other optimisations possible. One is to reject any
solution for value N using source numbers (a,b,c,d) if we have already seen
a solution for N using only a strict subset of (a,b,c,d). But there's a bit
of work involved there.

I've not finished yet, but already got it down to 3 seconds :slight_smile:

$ time ruby countdown2.rb 926 75 2 8 5 10 10
Solution: 926=(((75+(8-5))*(10+2))-10)

real 0m3.117s
user 0m3.025s
sys 0m0.008s