Skip to content

Instantly share code, notes, and snippets.

@QuinnStephens
Last active February 25, 2016 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QuinnStephens/80ac3e45958a020b21c8 to your computer and use it in GitHub Desktop.
Save QuinnStephens/80ac3e45958a020b21c8 to your computer and use it in GitHub Desktop.
weights = []
weights.append 215
weights.append 275
weights.append 335
weights.append 355
weights.append 420
weights.append 580
limit = 1505
copyArray ^source = {
new = []
source.each ^element ^(new.append element)
return new
}
iterate ^total ^order = {
weights.each ^weight ^(
if (total + weight == limit) ^(
order.append weight
order.each print
println ""
)
if (total + weight < limit) ^(
newOrder = copyArray order
newOrder.append(weight)
iterate (total + weight) newOrder
)
)
}
iterate 0 []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment