Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created December 7, 2023 09:35
Show Gist options
  • Save stephengruppetta/c550a8600d4e40c84476e6a5c7a2b2a3 to your computer and use it in GitHub Desktop.
Save stephengruppetta/c550a8600d4e40c84476e6a5c7a2b2a3 to your computer and use it in GitHub Desktop.
import random
numbers = [random.randint(1, 50) for _ in range(20)]
# 'max()' with a different rule.
# Can you figure out the rule?
print(
max(
numbers,
key=lambda x: sum(int(y) for y in str(x)),
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment