Skip to content

Instantly share code, notes, and snippets.

@ks--ks
Created August 9, 2020 04:02
Show Gist options
  • Save ks--ks/72e80c43f4fadae79409f1ce3cf0ad12 to your computer and use it in GitHub Desktop.
Save ks--ks/72e80c43f4fadae79409f1ce3cf0ad12 to your computer and use it in GitHub Desktop.
'''Given an int n, return the absolute difference between n and 21,
except return double the absolute difference if n is over 21.'''
def diff21(n):
if n <= 21:
return 21-n
else:
return (n - 21) * 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment