Created
October 21, 2015 13:53
Revisions
-
lwander created this gist
Oct 21, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ easy_partition(keys, T) B = [] A = [] B_s = 0 A_s = 0 keys = sort(keys) while len(keys) > 0 k = pop_biggest(keys) if B_s + k > T: if A_s + k > T: return ([], []) else: A.push(k) A_s += k else: B.push(k) B_s += k return (A, B)