Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Created December 8, 2021 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lovasoa/e860ee969cb9527b0f21ae3e7c72dc6b to your computer and use it in GitHub Desktop.
Save lovasoa/e860ee969cb9527b0f21ae3e7c72dc6b to your computer and use it in GitHub Desktop.
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