#!/usr/local/bin/maple # -*- maplev -*- # Nathaniel Shar # HW 3 # Experimental Mathematics # It is okay to link to this assignment on the course webpage. # From c3.txt: Nim:=proc(Li) local i,j: option remember: #print(Li): 1-mul( mul( Nim([ op(1..j-1, Li), Li[j]-i, op(j+1..nops(Li),Li) ]), i=1..Li[j]), j=1..nops(Li)): end: ############# # Problem 2 # ############# F := proc(k, N) local i,j: select(L->Nim(L)=0, [seq(seq([k,i,j], j=i..N),i=0..N)]): end: # The answer to the second question ("Can you guess...") is yes. # However, I already know how Nim works, so I suppose it isn't really # "guessing". In general, [k,a,b] is a 0 position iff a xor b = k. ############# # Problem 3 # ############# kWyt := proc(L) local i,k,ind: k := nops(L): ind := [seq([i], i=1..k), seq(seq([i,j], i=j+1..k), j=1..k)]: return kWytHelper(L, ind): end: kWytHelper := proc(L,ind) local i,s: option remember: if L = [seq(0, i=1..nops(L))] then: return 0: else: return 1- mul( mul( kWytHelper( [seq(`if`(i in s, L[i]-j,L[i]), i=1..nops(L))], ind ), j=1..min(map(x->L[x], s)) ), s=ind ): fi: end: Wyt := proc(a,b): return kWyt([a,b]): end: ############# # Problem 4 # ############# seqAi := proc(i) local j: for j from 0 do: if Wyt(j,j+i)=0 then: return j: fi: od: end: seqA := proc(n) local i: return [seq(seqAi(i), i=0..n)]: end: # The sequence is in OEIS (A201) if you drop the initial 0. The # conjecture is that a(n)/n -> (1+sqrt(5))/2. ############# # Problem 5 # ############# #See problem 3. #kWyt([3,4,5,6]) = 1. One winning move is to 3,4,0,1. If opponent # eliminates a pile, then you will be at a winning position in # 2-Wythoff. If opponent goes to [2,4,1], change 4 to 0. If opponent # goes to [1,4,1], change 4 to 1. If opponent goes to [3,3,1], change # both 3s to 1. If opponent goes to [3,2,1], change 3 to 0. If # opponent goes to [3,1,1], change 3 to 1. If opponent goes to # [2,3,1], change 3 to 0. If opponent goes to [1,2,1], change 2 to 1.