¿
take the first #.
subtract that from the goal.
now ask if the remaining #s can sum to the now-lesser goal.
lather rinse repeat.
don't forget a base case.
watch your cpu heat very quickly up on even slightly longer lists.
?

On Tue, Aug 14, 2012 at 4:13 PM, John Holland <jbholl...@gmail.com> wrote:
> I've been doing some programming exercises in Clojure, I've run into one I
> don't know how to approach. If anyone can just give me the strategy to use
> on this that'd be great. Here is the problem statement:
>
> Given an array of ints, is it possible to choose a group of some of the
> ints, such that the group sums to the given target?
>
>
> sample calls would be like:
>
> (groupSum [2, 4, 8] 10) → true
> (groupSum [2, 4, 8] 14) → true
> (groupSum [2, 4, 8]  9) → false
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to