Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Etsii henkilöjoukosta yhteisiä syntymäpäiviä
- # tulostaa yhteisten syntympäivien maksimin
- # Juhani Kaukoranta 10.6.2023
- import numpy as np
- import collections
- def birthday(n):
- # n henkilöiden lukumäärä
- a = np.random.randint(1,100,n)
- a.sort()
- samebirthday = 0
- max = 0
- maxi = 0
- b = collections.Counter(a)
- for i in range(1,366):
- if b[i] > 1:
- samebirthday += 1
- if b[i] > max:
- max = b[i]
- maxi = i # maxpäivä muistiin
- if max > 0:
- print(max,"henkilöllä yhteinen syntymäpäivä päivänro ",maxi)
- else:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement