Skip to content

Instantly share code, notes, and snippets.

@Shaddyjr
Created June 1, 2021 01:50
Show Gist options
  • Save Shaddyjr/556d803486359530cab7190d4b562d2f to your computer and use it in GitHub Desktop.
Save Shaddyjr/556d803486359530cab7190d4b562d2f to your computer and use it in GitHub Desktop.
# source: https://www.hackerrank.com/challenges/taum-and-bday/problem
# video: https://youtu.be/9vajRE0bJ5w
def taumBday(b, w, bc, wc, z):
# if black gifts > white gifts + z conversion cost
if bc > wc + z:
return (w * wc) + (b * (wc + z))
# if white gifts > black gifts + z conversion cost
if wc > bc + z:
return (b * bc) + (w * (bc + z))
# else, just buy as is
return b * bc + w * wc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment