On 7/16/07, Tom Pledger [EMAIL PROTECTED] wrote:
I'll be a nuisance and bring up this case:
solve 150005 [2, 4, 150001]
Argh, that makes my solution hang! :-/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
We've seen some nice concise solutions that can deal with the original
problem:
solve 1505 [215, 275, 335, 355, 420, 580]
I'll be a nuisance and bring up this case:
solve 150005 [2, 4, 150001]
A more scalable solution is to use an explicit heap that brings
together all the ways to
Hugh Perkins wrote:
There's a good tutorial on pruning at:
http://www.cs.nott.ac.uk/~gmh/book.html
http://www.cs.nott.ac.uk/%7Egmh/book.html (Section Slides, number 11)
Aaa... Interesting. Check each subexpression for validity at every
stage of the process. I hadn't thought of that. (I
On Tue, 10 Jul 2007, Hugh Perkins wrote:
By the way, if you enjoy these problems, there are tons of these at
topcoder.com I cant help thinking it'd be neat to have topcoder-like
competitions for Haskell, either by pursuading topcoder to integrate support
for Haskell, or hosting our own.
Is
Am Dienstag, 10. Juli 2007 00:25 schrieb Albert Y. C. Lai:
http://xkcd.com/c287.html
It disappoints me that there is no solution if each item is used at most
once. However, do change the code to allow multiple uses, then there are
many solutions.
i see only two solutions.
let menu = [215,
On Tue, 10 Jul 2007, Donald Bruce Stewart wrote:
These smaller NP problems really love the list monad. here's roconnor's
solution from #haskell:
import Control.Monad
menu = [(Mixed Fruit,215),(French Fries,275)
,(Side Salad,335),(Hot Wings,355)
,(Mozzarella
lemming:
On Tue, 10 Jul 2007, Donald Bruce Stewart wrote:
These smaller NP problems really love the list monad. here's roconnor's
solution from #haskell:
import Control.Monad
menu = [(Mixed Fruit,215),(French Fries,275)
,(Side Salad,335),(Hot Wings,355)
This is a compact solution, but it produces multiple permutations of the
same solution, which increases runtime. I let it run for 10 seconds, then
ctrl-c'd.
Here's a solution that produces all 2 (or three, if you include Barbecue
Sandwich) solutions instantly:
Output:
=
*Xkcd287 go
Menu 1
By the way, if you enjoy these problems, there are tons of these at
topcoder.com I cant help thinking it'd be neat to have topcoder-like
competitions for Haskell, either by pursuading topcoder to integrate support
for Haskell, or hosting our own.
___
Albert Y. C. Lai wrote:
You are right, I saw many solutions but they were all equivalent to
just those two. I did not avoid permutation-induced redundancy.
I was unsure how to eliminate that redundancy. After reading your
algorithm, I see it. Here is my algorithm modified.
In general, I
Hugh Perkins wrote:
There's a good tutorial on pruning at:
http://www.cs.nott.ac.uk/~gmh/book.html
http://www.cs.nott.ac.uk/%7Egmh/book.html (Section Slides, number 11)
In general, I find this kind of stuff really hard to avoid... :-S
...and indeed, countdown was what I was
http://xkcd.com/c287.html
import Data.Array
import Control.Monad
-- exactly n v
-- items in v that sum to exactly n
-- returns list of solutions, each solution list of items
exactly :: (Real a) = a - Array Int a - [[a]]
exactly 0 v = return []
exactly n v = do
i - indices v
guard (v!i = n)
12 matches
Mail list logo