Created
December 8, 2021 11:12
-
-
Save lovasoa/e860ee969cb9527b0f21ae3e7c72dc6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import sys | |
from numpy import * | |
from collections import Counter | |
n = int(sys.argv[1]) | |
def mat_fun(i,j): return (j == (i+1)%9) | ((i==6) & (j==0)) | |
M = matrix(fromfunction(mat_fun, (9, 9)), dtype=int)**n | |
ages=Counter(map(int,input().split(','))) | |
sizes=array([ages[i] for i in range(9)]) | |
print(M.dot(sizes).sum()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment