Skip to content

Instantly share code, notes, and snippets.

@Urpagin
Last active September 19, 2025 18:50
Show Gist options
  • Select an option

  • Save Urpagin/904c39b0a4cc914f92592e338e3381a0 to your computer and use it in GitHub Desktop.

Select an option

Save Urpagin/904c39b0a4cc914f92592e338e3381a0 to your computer and use it in GitHub Desktop.
Funny One-liner
#!/usr/bin/env python3
# Author: Urpagin
# Date: 2025-09-19
# Description: Counts and prints the number of draws needed to obtain an even number.
# Numbers randomly selected between 1 and 6 (inclusive).
# License: MIT
print(f"{(rnd := __import__('random')) and ''}{((END := [0]), '')[1]}{(nums := len([n for n in iter(lambda: (lambda r: r if r % 2 != 0 else (END.__setitem__(0, r)) or END)(rnd.randint(1, 6)), END)]) + 1) and ''}There {'have' if nums > 1 else 'has'} been {nums} draw{'s' if nums > 1 else ''} before getting an even number: {END[0]}.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment