Skip to content

Instantly share code, notes, and snippets.

@EntranceJew
Created April 10, 2019 10:15
Show Gist options
  • Save EntranceJew/f1ed904ec0fa614ec57c18f3cc3d79ac to your computer and use it in GitHub Desktop.
Save EntranceJew/f1ed904ec0fa614ec57c18f3cc3d79ac to your computer and use it in GitHub Desktop.
fuck amazon order summaries, business support can't do math any better than me
def permute_sum_contributors(elements, target):
from random import sample
while True:
working = []
workset = sample(elements, k=len(elements))
while True:
working.append(workset.pop())
if round(sum(working),2) == target:
return working
elif round(sum(working),2) > target:
break
else:
continue
return working
def deduce_shipment_tax(elements, target):
from random import sample, getrandbits
goal = round(target - sum(elements), 2)
while True:
working = []
taxworked = []
workset = sample(elements, k=len(elements))
while True:
element = workset.pop()
taxworked.append(element)
working.append(round(element*0.07,2))
if round(sum(working),2) == goal:
return taxworked
elif round(sum(working),2) > goal:
break
else:
continue
return taxworked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment