#Ok to post homework #Tifany Tong, November 1st, 2020, HW #15 # Question 1 RoG := proc(k, n) local V, E, i, j, T1, v, N, M, m, pt: V := [seq(seq(seq([i, j], j = 1 .. n), i = 1 .. k))]: for i to nops(V) do T1[V[i]] := i: od: E := []: M := {}: for i to k - 1 do M := M union {[-i, 0], [i, 0]}: od: for i to n - 1 do M := M union {[0, -i], [0, i]}: od: for i to nops(V) do pt := V[i]: N := {seq(pt + m, m in M)}: N := N intersect convert(V, set): E := [op(E), {seq(T1[v], v in N)}]: od: E, V: end: # 2,6,96,3132,252240 --> This sequence is not in the OEIS. # Question 2 nopsn #Number of ways: # SeqW({[0, 1], [1, 0], [1, 1], [2, 2]}, 40) = 2382564832244243056285491057263 #Number of good ways: # SeqGW({[0, 1], [1, 0], [1, 1], [2, 2]}, 40) = 89322096703094945357683861273 #First 20 terms: #SeqW({[0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]}, 20) = #[7, 115, 2371, 54091, 1307377, 32803219, 844910395, 22188235867, 591446519797, 15953338537885, 434479441772845, 11927609772412075, 329653844941016785, 9163407745486783435, 255982736410338609931, 7181987671728091545787, 202271071826031620236525, 5715984422606794841997001, 162016571360163769411597081, 4604748196249289767697705221] #First 20 good terms: #SeqGW({[0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]}, 20); #[2, 10, 88, 1043, 14778, 236001, 4107925, 76314975, 1491934038, # 30389576308, 640286048416, 13877540824735, 308102204007536, # 6983346070924707, 161156356282624227, 3778249609096250059, # 89826197363219012470, 2162338803354415120414, # 52637415804379149938876, 1294313658632145337351381]