#Please do not post homework #Caroline Cote, Feb 28th, 2026, Assignment 11 HelpHW11:=proc(): print(``): end: #problem 1 #CountNuCompsClever(a,b,A,B,N): inputs the positive integers a and b # and a subset A of {1,..., a} and a subset B of {0,...,b-1} and outputs #the first N terms of the sequence enumerating compositions all whose # parts have the property that i mod a belongs to A # and the number of parts mod b belongs to B CountNuCompsClever:= proc(a,b,A,B,N) local x, f, i: f:= GenCompsGF(a,b,A,B,x): [seq(coeff( taylor(f,x=0,N+3),x,i),i=0..N)]: end: #problem 2 with(combinat): read "C11.txt": read "C10.txt": #CountNuCompsStupid(a,b,A,B,N): same thing but longer CountNuCompsStupid1:= proc(a,b,A,B,n) local co, good, L,i, x, k : co:= 0: for L in Comps(n) do if member(nops(L) mod b, B) then good := true: for i from 1 to nops(L) do k := L[i]: x := k mod a: if x = 0 then x:= a: fi: if not member(x,A) then good:= false: fi: od: if good then co := co + 1: fi: fi: od: co: end: CountNuCompsStupid:= proc(a,b,A,B,N) local n: [seq(CountNuCompsStupid1(a,b,A,B,n), n = 0..N)]: end: a := 3; b := 4; A := {1, 2}; B := {0, 3}; evalb(CountNuCompsClever(a, b, A, B, 15) = CountNuCompsStupid(a, b, A, B, 15)); # true a := 2; b := 3; A := {1}; B := {2}; evalb(CountNuCompsClever(a, b, A, B, 15) = CountNuCompsStupid(a, b, A, B, 15)); # true