Last active
March 24, 2022 22:03
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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