Skip to content

Instantly share code, notes, and snippets.

View p1-dta's full-sized avatar
🐍
Coding Python

Dorian Turba p1-dta

🐍
Coding Python
View GitHub Profile
@p1-dta
p1-dta / count_living_per_year.py
Created April 16, 2023 17:00
Count how many people are alive per year, based on their birthyear and deathyear, aims for simplicity.
import collections
import random
import timeit
pop = [
(b := random.randint(1900, 2000), random.randint(b + 1, b + 100))
for _ in range(10000)
]
@p1-dta
p1-dta / count_living_per_year_perf.py
Last active August 8, 2024 12:09
Count how many people are alive per year, based on their birthyear and deathyear, aims for performances.
import collections
import random
import timeit
pop = [
(b := random.randint(1900, 2000), random.randint(b + 1, b + 100))
for _ in range(10000)
]