Advertisement
jukaukor

birthday.py

Jun 10th, 2023 (edited)
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. # Etsii henkilöjoukosta yhteisiä syntymäpäiviä
  2. # tulostaa yhteisten syntympäivien maksimin
  3. # Juhani Kaukoranta 10.6.2023
  4. import numpy as np
  5. import collections
  6. def birthday(n):
  7. # n henkilöiden lukumäärä
  8. a = np.random.randint(1,100,n)
  9. a.sort()
  10. samebirthday = 0
  11. max = 0
  12. maxi = 0
  13. b = collections.Counter(a)
  14. for i in range(1,366):
  15. if b[i] > 1:
  16. samebirthday += 1
  17. if b[i] > max:
  18. max = b[i]
  19. maxi = i # maxpäivä muistiin
  20. if max > 0:
  21. print(max,"henkilöllä yhteinen syntymäpäivä päivänro ",maxi)
  22. else:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement