Skip to content

Instantly share code, notes, and snippets.

@hntrmrrs
Forked from bradwright/gist:595081
Created September 24, 2010 09:06
Show Gist options
  • Save hntrmrrs/595089 to your computer and use it in GitHub Desktop.
Save hntrmrrs/595089 to your computer and use it in GitHub Desktop.
# a heavy int is one where the average of the digits is greater than 7
# eg: 8678 is heavy because (8 + 6 + 7 + 8) / 4 = 7.25
# 8677 is not heavy because ( 8 + 6 + 7 + 7) / 4 = 7
def is_heavy(my_number, heaviness=7):
# map each digit to a float and divide by the length
digits = str(my_number)
return sum(map(float, digits)) / len(digits) > heaviness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment