#OK to post homework #Natalya Ter-Saakov, April 10, Assignment 20 read "C20.txt": #Problem 1 #ConjLP(R): inputs a finite set of positive integers R, and outputs the pair [M,C] where M is a positive integer ≥ 2 and C is a subset of {0,1,...,M-1} such that PR(n,R)[1]=0 if and only if n mod M belongs to C ConjLP:=proc(R) local M,C,L: M:=1: L:=LP((nops(R))^3,R): do M+=1: C:=convert(L mod M,set): until nops(C)0 then return(1,{[a,0]}): fi: if a<>0 and b=0 then return(1,{[0,b]}): fi: for i from 1 to a do if Nim2V(a-i,b)[1]=0 then S:=S union {[i,0]}: fi: od: for i from 1 to b do if Nim2V(a,b-i)[1]=0 then S:=S union {[0,i]}: fi: od: for i from 1 to min(a,b) do if Nim2V(a-i,b-i)[1]=0 then S:=S union {[i,i]}: fi: od: if S={} then 0,S: else 1,S: fi: end: #Problem 7 #Nim2VL(N): inputs a positive integer N and outputs the LIST of pairs [a,b], 0 ≤ a ≤ b ≤ N, that are losing positions for the above game. with increasing order of the first component. Nim2VL:=proc(N) local a,b,S: option remember: S:=[]: for a from 0 to N do for b from a to N do if Nim2V(a,b)[1]=0 then S:=[op(S),[a,b]]: fi: od: od: S: end: #Problem 8 #Characterize such losing pairs.