addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Geeknight Dallas Message Board › From our 'Farmer' problem...

From our 'Farmer' problem...

R. J.
Fort Worth, TX
Post #: 17
In Ruby.
Calculating the different combinations of four values that add up to 40:

I don't think Greg's Haskell version did this exactly though it is much more succinct.
I sort the elements of the array that adds up to 40 and then put it in the set.
That means the duplicates [1, 1, 1, 37]...[37, 1, 1, 1] all get put in the same bucket.

478 different unique combinations.
R. J.
Fort Worth, TX
Post #: 18
Here is another ruby try with a BIG assumption.
No two stones weigh the same.

Reduces the number of combinations to 297
A former member
Post #: 1
In Scala:


Not a brute force solution. Allows for solving for any positive int weight.
More explanation on­
A former member
Post #: 1
Here is my solution in Clojure https://gist.github.c...­
Greg H.
Plano, TX
Post #: 3
Here is my solution from last night cleaned up a bit:
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy