Skip to content

Instantly share code, notes, and snippets.

@aasmpro
Last active March 24, 2022 22:03
Show Gist options
  • Save aasmpro/02655603a1616d65024a75f69bf01019 to your computer and use it in GitHub Desktop.
Save aasmpro/02655603a1616d65024a75f69bf01019 to your computer and use it in GitHub Desktop.
Script to find the year with most population from two arrays of birth and death years
b = [1386, 1345, 1367]
d = [1398, 1390, 1387]
l = len(b)
result = 0
count = 0
for year in range(min(b), max(d) + 1):
_c = 0
for i in range(l):
if b[i] <= year <= d[i]:
_c += 1
if _c > count:
result = year
count = _c
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment