Skip to content

Instantly share code, notes, and snippets.

@lernisto
Last active April 30, 2019 04:30
Show Gist options
  • Save lernisto/8ab4e4b78cc4b2a9e0c0643b86b0a1a4 to your computer and use it in GitHub Desktop.
Save lernisto/8ab4e4b78cc4b2a9e0c0643b86b0a1a4 to your computer and use it in GitHub Desktop.
data = [43, 542, 34, 15, 23, 24, 125, 503]
labels = ("even", "odd")
buckets = [list() for x in labels]
n = len(buckets)
for d in data:
buckets[d % n].append(d)
for label, bucket in zip(labels, buckets):
print(f"{label} numbers: {bucket}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment