{VERSION 4 0 "IBM INTEL LINUX22" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 1 12 0 0 255 1 0 2 0 0 1 0 0 0 0 1 }{CSTYLE "" 0 21 "" 0 1 0 0 0 1 0 0 0 0 2 0 0 0 0 1 } {CSTYLE "" -1 256 "" 1 24 0 0 0 0 0 0 2 0 0 0 0 0 0 0 }{PSTYLE "Normal " -1 0 1 {CSTYLE "" -1 -1 "Times" 1 16 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 6 6 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 2" -1 4 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 2 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 18 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }{PSTYLE "R3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 12 128 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Norma l" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 16 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 259 1 {CSTYLE "" -1 -1 "Times" 1 24 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 12 12 3 0 3 0 2 2 19 1 }{PSTYLE "Maple Output" -1 260 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 3 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 18 "" 0 "" {TEXT 256 6 "new 06" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 15 "Initialisati ons" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "with(pldx):" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "interface(labelling=false); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "with(LinearAlgebra):" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "with(linalg, matrix, subma trix, rowdim,row); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 142 "if \+ kernelopts(platform)=\"unix\" \n then racine:= \"/home/douillet/\"\n e lse racine:= \"F:/\" \nfi: repert:= cat(racine, \"docs/Cherche/sudoku/ games/\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "description" }} {PARA 0 "" 0 "" {TEXT -1 80 "1..N : indices\nN+1..2*N : lettres\ndeb.. fin= 2*N+1..2*N+NN : indices des cellules" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 27 "Implementation (0 or not 0)" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 8 "ancienne" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 286 "let2empty:= proc() option inline ; \{op(letters),0\} ; end;\nlet2tab:= proc(z) option inline; \{z\} end;\ntab2let:= proc(z) option inline; op(z) end;\nunk2known:= proc (z) option inline ; z ; e nd;\nknown:= proc(z) option inline; nops(z)=1; end;\nunknown:= proc( z) option inline; has(z, 0) end;\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 8 "nouvelle" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 302 "let2empty:= proc () option inline ; convert(letters, set); end;\nlet2tab:= proc(z) opti on inline; z end;\ntab2let:= proc(z) option inline; z end;\nunk2known: = proc (z) option inline ; op(z); end;\nknown:= proc(z) option inlin e; not type(z,set); end;\nunknown:= proc(z) option inline; type(z, set); end;\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 8 "Routines" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 16 "init\nre\347oit m, n" }}{PARA 0 "" 0 "" {TEXT -1 98 "cr \351e m,n,N, deb,fin\ncr\351e letters et user_letters (d\351faut)\ncr \351e les groupes et la table des voisins" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 1171 "init:= proc(m_,n_) \nglobal m,n, N,letters, user_ letters, empty, voisins, grrow,grblo,grcol, grall, deb, debfin, ii,jj, kk, rerow, recol, message;\nlocal model, tetes, i,k,tmp,fin;\nm,n:= m_ ,n_; N:= m*n; ii:=ii;jj:=jj;kk:=kk;\nif not assigned(user_letters) or \+ nops(user_letters) <> N then \n user_letters:= [$1..N];\nfi;\nletters: = [$N+1..2*N]; \nempty:= let2empty(); \ndeb:= 2*N+1; fin:=deb-1+N^2;\n grrow:= [ seq([seq(deb+ii*N+kk, kk=0..N-1)], ii=0..N-1) ];\ngrcol:= [ seq([seq(deb+ii*N+kk, ii=0..N-1)], kk=0..N-1) ];\nmodel:= [seq($(kk* N)..(kk*N+n-1), kk=0..m-1)];\ntetes:= [seq(seq(deb+kk*n+ii*m*N, kk=0.. m-1), ii=0..n-1)];\ngrblo:= [seq([seq(model[jj]+tetes[kk], jj=1..N)], \+ kk=1..N)];\nvoisins:= table();\nfor i in grrow do tmp:= op(i); for k i n tmp do voisins[k]:= tmp od; od;\nfor i in grcol do tmp:= op(i); for \+ k in tmp do voisins[k]:= voisins[k],tmp od; od;\nfor i in grblo do tmp := op(i); for k in tmp do voisins[k]:= \{voisins[k],tmp\} minus\{k\} o d; od;\ngrall:= [op(grblo), op(grrow), op(grcol)];\nmessage:= subs ('' NA''=nops(grblo), ''NB''= nops(grblo)+nops(grrow), eval(message0));\nd ebfin:= [$deb..fin];\nrerow:=recol; recol:= table([seq(kk=kk, kk=1..N) ]);\n'm'=m, 'n'=n,'N'=N;\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "game\nre\347oit m,n puis une s\351quence de 0 et de lettres\ncr\351e la table correspondante" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 268 "game:= proc(m,n, descr_) global N, letters, user_letters, empty, deb, tab;\n local descr;\ninit(m,n);\ndescr:= subs(seq(user_letters[jj]=letters[jj ],jj=1..N), descr_);\ntab:= table([seq(k+deb-1=`if`(descr[k]=0, empty, let2tab(descr[k]) ), k=1..nops(descr) )]);\nview();\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 28 "view\naffiche le tab en cours" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 221 "view:= proc() global m,n,N,empty,letters,u ser_letters, grblo, tab, ``;\nmatrix(n,m, [seq(matrix(m,n, [seq(tab[kk ], kk=grblo[jj])] ), jj=1..N)]);\nsubs(empty=``, seq( let2tab(letters[ kk])=user_letters[kk], kk=1..N), %);\nend:" }}}{SECT 1 {PARA 4 "" 0 " " {TEXT -1 20 "Gestion des messages" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 4 "lico" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 172 "lico:= proc(i) globa l grrow, grcol,rerow,recol; local rrr, ccc;\nmember(true,map2(has, i, \+ grrow),'rrr'); member(true,map2(has, i, grcol),'ccc'); \nrerow[rrr],re col[ccc];\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 8 "message " }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 234 "message0:= proc(o_,i) global user_ letters, tab, N; local o;\nif member(o_, \{'O','P','Q','PP'\}) then o: = o_\nelif o_<= 'NA' then o:='MB'\nelif o_<= 'NB' then o:='MR'\nelse o :='MC'\nfi;\n`=`( o[lico(i)], user_letters[tab2let(tab[i])-N]);\nend: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 767 "saylevel:= proc(level) global say, line, N, xres_run, xres_ini, message;\nlocal stopx;\nif n args=0 or level= 'none' then say:= proc () end;\nelif level=print then say:= proc(o,i); print(message(o,i)); end;\nelif level='res' then xre s_ini(10*N*N, ['` #`', '` R`', '` C`', '` why`', '` ?`']); \n line:=0; \n say:= proc(o,i) global line; local tmp; tmp:= message(o,i); line : = line+1;\n xres_run([line, op(lhs(tmp)), op(0,lhs(tmp)), rhs(tmp)]); end;\nelif level='res_try' then xres_ini(10*N*N, ['` #`', '` R`', '` \+ C`', '` why`', '` ?`']); \n line:=0; stopx:= args[2]; \n say:= proc(o ,i) global line; local tmp; tmp:= message(o,i); line := line+1;\n xre s_run([line, op(lhs(tmp)), op(0,lhs(tmp)), rhs(tmp)]); \n if line=sto px then error fi;\n end;\nelse error \"bad level\"\nfi; end: " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 250 "print_joli:= proc() local t itre, ck, cj;\ntitre:= row(res, 1): cj:= rowdim(res)-1; ck:= ceil(cj/ 4):\nseq(matrix([titre, seq( row(res,i*ck+j),j=2..ck+1)]), i=0..2), \n matrix([eval(titre), seq( row(res,j),j=3*ck+2..cj+1), vector([``$5])$( 4*ck-cj)]);\nend:" }}}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "taboo\nbala ie et applique taboo \340 la tab en cours" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 406 "taboo:= proc() global tab, unknown, debfin, voisins, say; \nlocal flag, i, tmp; \nflag:= false;\nfor i in debfin \ndo if k nown(tab[i]) then next; fi; \ntmp:= tab[i] minus remove(unknown, \{se q(tab[kk], kk=voisins[i])\});\nif nops(tmp)=1 then tab[i]:= unk2known( tmp); flag:= true; say(O, i);\nelif nops(tmp)=0 then error sprintf(\"t aboo error at %a\", i);\nelse tab[i]:= tmp; \nfi; od;\nif flag then p rocname() fi;\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "totem\nbal aie et applique totem \340 la tab en cours" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 635 "totem := proc() global tab, grall, say;\nlocal flag, i, ll, tmp, lets, kill, ici;\ntaboo(); flag:= false;\nfor i to nops(g rall) do tmp:= \{seq( `if`(unknown(tab[k]),k=tab[k],NULL), k=grall[i]) \};\nkill:= \{seq( `if`(known(tab[k]), tab2let(tab[k])=NULL, NULL), k= grall[i])\};\nif kill<> \{\} then tmp:= subs(kill, tmp); fi;\nlets:= ( `union`@op@map)(rhs,tmp);\nfor ll in lets do\n ici:= select(has, tmp, \+ ll); \n if nops(ici)=1 then \n flag:= true; ici:= lhs(op(ici)); tab[ ici]:= let2tab(ll); tmp:= remove(has,tmp,ici); say(i, ici);\n elif ici =\{\} then error sprintf(\"missing letter %a in block %a\", ll,i); \n \+ fi \nod; od;\nif flag then procname() fi;\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 15 "Algo rithme pick" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "pivot\nchoix du piv ot dans l'algorithme pick" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 332 "pivot :=proc() global Entries, tab, how, debfin, encore;\nlocal tmp, howw; \+ \n tmp := subs(1 = NULL, map(nops, [Entries(tab)]));\n encore := nops( tmp);\n if encore = 0 then return 0 end if;\n how := min(op(tmp));\n h oww := \{% + 1, %\};\n [seq(`if`(member(nops(tab[jj]), howw), jj, NULL ), jj = debfin)];\n %[1 + modp(rand(), nops(%))]\nend proc:" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 33 "pick\npour un pivot donn\351, essa ie " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 692 "tootem:= proc() option inli ne; totem(); end; \npick:= proc(piv) global ou, memoloc, memotab, tab, essai, say;\nlocal li, loc;\nli:= tab[piv]; if known(li) then return \+ fi;\nli:= li minus \{0\}; ou:= ou+1 ; memoloc[ou]:= piv; memotab[ou]:= copy(tab);\nwhile 0 < nops(li) do\nessai:= li[1+modp(rand(), nops(li) )]; tab[piv]:= let2tab(essai); say('P', piv);\ntry tootem() ; return; \+ \ncatch: \n if nops(li)=1 then\n while ou>1 do ou:= ou-1; tab:= copy( memotab[ou]); loc:= memoloc[ou];\n tab[loc]:= memotab[ou][loc] minus \{tab2let(memotab[ou+1][loc])\}; say('Q', loc);\n try tootem(); ou: = ou-1; return; \n catch: \n end try; \n od; \n fi;\nli:= li mi nus \{essai\}; tab:= copy(memotab[ou]); \nend try;\nod;\nend:" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Ex\351cute une solution compl\350t e" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 320 "vazy_pick:= proc() global ou, memoloc, memotab, encore;\nlocal qqq, piv;\nou:=0: memoloc, memotab:= table(), table():\ntootem();\nfor qqq do\npiv:= pivot():\nif encore = 0 then break fi;\npick(piv);\n# print(sprintf(\"etape= %a, ou= %a, en core= %a, how=%a, pivot= %a,val= %a\", qqq,ou,encore,how,piv,essai )); \nod:\nview();\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 46 "pick_proof\nd\351montre l'uni cit\351 d'une completion" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 630 "prove_ pick:= proc() global ou, tab, memotab, memoloc, this_pick, zou, zmemot ab, zmemoloc; \nlocal proven, tou, tpiv, tqui, xqui;\nthis_pick:= tabl e([seq(ii=[memoloc[ii], tab[memoloc[ii]]], ii=1..ou)]);\nzou:= ou; mem otab[zou+1]:= copy(tab): zmemotab:= copy(memotab): zmemoloc:= copy(mem oloc):\nproven := true;\nfor tou from zou by -1 to 1 while proven do \+ \ntpiv:= zmemoloc[tou]; \ntqui:= zmemotab[tou][%] minus \{tab2let(zmem otab[tou+1][%])\};\nfor xqui in tqui while proven do\ntab:= copy(zmemo tab[tou]): tab[tpiv]:= let2tab(xqui);\ntry vazy_pick(); proven:= false ; print('not_proven', tou, tpiv, xqui); \ncatch:\nend try;\nod; od; pr oven; end:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 23 "Liste une solution \+ pick" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 186 "list_pick:= proc() global \+ this_pick, zou, tab, say;\nlocal ou;\ntootem();\nfor ou to zou do \nta b[this_pick[ou][1]]:=this_pick[ou][2];\nsay('PP', this_pick[ou][1]);\n tootem();\nod:\nview();\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 24 " Nouvelle grille compl\350te" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "new _sud\nutilise pick, et un canton initialis\351" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 697 "new_sud:=proc(m_, n_, canton_, given_) \nglobal repe rt, m, n, N, tab, tac, grblo, mem_seed, empty, letters, debfin ;\nloca l canton, ouca, given, i;\n init(m_, n_);\n mem_seed := _seed;\n if na rgs = 2 or canton_ = 0 \n then canton, ouca, given := 0, 1, combinat[ 'randperm'](letters)\n else canton, ouca, given := canton_, canton_, \+ given_\n end if;\n tab := table([seq(k = empty, k = debfin)]);\n ouca \+ := [N, N + 1 - m, m, 1][ouca]; ouca := grblo[ouca];\n for i to N do ta b[ouca[i]] := given[i] end do;\n saylevel('none'); vazy_pick(); tac||c anton := copy(tab);\n cat(repert, \"sud_\", m, \"_\", n, \"_\", canton , \".m\");\n save m, n, N, debfin, user_letters, letters, empty, canto n, tac||canton, mem_seed, %\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 7 "new_sam" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 610 "new_sam:= proc(m_, n_) global rep ert, mem_seed, tab,tac,tac0, m,n,N, grblo, given, debfin;\nlocal mymem _seed;; \nnew_sud(m_,n_); mymem_seed:= mem_seed; \ngiven||1:=[seq(tac0 [k], k=grblo[1])]; given||2:=[seq(tac0[k], k=grblo[m])];\ngiven||3 :=[seq(tac0[k], k=grblo[N+1-m])]; given||4:=[seq(tac0[k], k=grblo[N])] ;\nseq(new_sud(m,n,k,given||k), k=1..4); mem_seed:= mymem_seed;\n## ju sque-l\340, tab, grblo et debfin sont \"petits\" \nbiggame(m,n,seq([se q(tac||i[k], k=debfin)], i=[$1..4,0]));\ntac:= copy(tab);\ncat(repert, \"sam_\", m, \"_\", n, \".m\");\nsave m, n, N, debfin, user_letters, \+ letters, empty, tac, mem_seed, %\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {SECT 1 {PARA 4 "" 0 "" {TEXT -1 21 "Cr\351ation de probl\350mes" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 769 "bigproblem:= proc(m_, n_, q uoi) global m,n, tab, tac, empty, letters, let2tab, debfin, repert;\nl ocal idents, tad, voir, quer, essai; \nbiginit(m_,n_); cat(repert, \"s am_\", m, \"_\", n, \".m\"): \nread %;\nidents:= convert(map((z->[z])@ let2tab, letters), set): \ntad:= copy(tac): voir:= debfin: quer:= NULL ;\nwhile voir <> \{\} do\n essai:= voir[1+ modp(rand(), nops(voir))]; \n quer:= quer, essai: # print(nops([quer]));\n voir:= voir minus \{es sai\}:\n tad[essai]:= empty: tab:= copy(tad): quoi(); \n if \{entries (tab)\} minus idents <> \{\} \n then tad[quer[-1]]:= let2tab(tac[que r[-1]]); quer:= quer[1..-2] \n fi;\nod:\ntab:= copy(tad): \ncat(reper t, \"sam_\", m, \"_\", n, \"_\", quoi, \".m\");\nsave m, n, N, letters , user_letters, empty, mem_seed, tab, tac, %;\nprint(nops([quer])); bi gview();\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 16 "Big is beautyful" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1584 "biginit:= proc(m_,n_) \nglobal m, n, N, voisins, grrow, grblo, grblo0, grcol, grall, \n ii, jj, kk, reduire, \+ deb, debfin, sdebfin, rerow, recol, message;\nlocal srow, scol, sblo,z ,i,k,tmp;\nii:=ii;jj:=jj;kk:=kk;z:='z';\ninit(m_,n_); sdebfin, srow, s col, sblo:= debfin, copy(grrow), copy(grcol), copy(grblo);\ngrcol:= [s eq(seq(map(unapply(z+N*N*ii,z), scol[kk]), kk=1..N), ii=0..4)];\ngrrow := [seq(seq(map(unapply(z+N*N*ii,z), srow[kk]), kk=1..N), ii=0..4)];\n grblo0:=[seq(seq(map(unapply(z+N*N*ii,z), sblo[kk]), kk=1..N), ii=0..4 )];\n \nreduire:= `union`(\nstudent['equate'](grblo0[1*N+N ],grblo0 [1]),\nstudent['equate'](grblo0[2*N+N+1-m],grblo0[m]),\nstudent['equat e'](grblo0[3*N+m ],grblo0[N+1-m]),\nstudent['equate'](grblo0[4*N+1 \+ ],grblo0[N]));\n\ngrblo:= subsop(1*N+N=NULL,2*N+N+1-m=NULL,3*N+m=NU LL,4*N+1=NULL, grblo0);\ngrrow:=subs(reduire,grrow); grcol:=subs(redui re,grcol); \ndebfin:= \{$deb..deb+5*N*N-1\} minus map(lhs,reduire); \ngrall:= [op(grblo),op(grrow),op(grcol)];\n\nvoisins:= table();\nfor \+ i in grrow do tmp:= op(i); for k in tmp do voisins[k]:= tmp od; od;\nf or i in grcol do tmp:= op(i); for k in tmp do voisins[k]:= voisins[k], tmp od; od;\nfor i in grblo do tmp:= op(i); for k in tmp do voisins[k] := \{voisins[k],tmp\} minus\{k\} od; od;\nrecol:= table([seq(op([kk=N- n+kk,N+kk=kk,3*N+kk=kk,2*N+kk=2*N-2*n+kk,4*N+kk=2*N-2*n+kk]),kk=1..N)] ):\nrerow:= table([seq(op([kk=N-m+kk,N+kk=kk,2*N+kk=kk,3*N+kk=2*N-2*m+ kk,4*N+kk=2*N-2*m+kk]),kk=1..N)]);\n\nmessage:= subs (''NA''=nops(grbl o), ''NB''= nops(grblo)+nops(grrow), eval(message0));\n\n'm' = m, 'n' \+ = n, 'N' = N, 'cells'=nops(debfin);\nend: " }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 531 "biggame:= proc(m,n, descr1,descr2,descr3,descr4, d escr0)\n global N, letters, user_letters, empty, deb, tab, reduire;\nl ocal descr, convers;\nbiginit(m,n); convers:= seq(user_letters[jj]=let ters[jj],jj=1..N); \ndescr:= subs(convers, [descr1,descr2,descr3,descr 4,descr0]);\ntab:= seq( seq(N^2*i+k+deb-1=`if`(descr[i][k]=0, empty, l et2tab(descr[i][k]) ), k=1..N^2),i=1..4);\ntab:= table([tab, seq(k+deb -1=`if`(descr[5][k]=0, empty, let2tab(descr[5][k]) ), k=1..N^2)]);\nma p(lhs,reduire); unassign( seq( evaln(tab[k]), k=%));\nbigview();\nend: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 837 "bigview:= proc() global m, n, N, letters, use r_letters, tab, ``, kk,jj, empty, reduire, grblo0;\nlocal mid1, mid2, \+ mid3, lesblo, tmp, blow0, fill;\n\nlesblo:= map(proc(li) [seq(tab[kk], kk=li)]; Matrix(matrix(m,n,%)) end, grblo0): \ntmp:= Matrix(matrix(n,m ,lesblo[1..N])); \nblow0:=Matrix(m,n,unapply(``,jj,kk)); fill:= unappl y(blow0,jj,kk);\n\nMatrix(n-1,m-2,fill), SubMatrix(tmp,1..1,2..m-1): m id1:= <%>:\nSubMatrix(tmp,n..n,2..m-1), Matrix(n-1,m-2,fill): mid3:= < %>:\n;\n mid2:=%;\n<,mid2,\n >:\nsubs(map(proc(eq) `=`(tab[lhs(eq) ],tab[rhs(eq)]) end, reduire), empty=``, \n seq( let2tab(letters[kk])= user_letters[kk], kk=1..N), %);\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 5 "xmint" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 238 "unassi gn('n','m','N','deb','debfin', 'letters','user_letters', 'empty', 'tab ', 'say', 'line', 'how', 'encore', 'ou', 'piv', 'essai', 'grrow', 'grc ol', 'zou',\n'proven', 'tou', 'tpiv', 'tqui', 'xqui', 'qqq', 'sdebfin' , 'mem_seed', 'quoi'): " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 186 "lesprocs:= [ saylevel, lico, init, biginit, game, biggame, view, bigv iew, taboo, totem, message0, pivot, pick, vazy_pick, prove_pick, list_ pick, new_sud, new_sam, problem, bigproblem]; \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 123 "map(protect, lesprocs): \nfor j in lesprocs \+ do try xmint(j); catch: print(lasterror); end try; od; map(unprotect, \+ lesprocs):" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 11 "Exemple 3,2" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "descr:= [4,0,0,0,0,5,0$6,0,6,0,0,3,2,6,0,5,2,0,4,0,0, 0,6,2,0,0$6]; # nops(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "game(3,2, descr);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "sayle vel(res): totem(); view();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "xres_cut(): print_joli();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 25 "Le m^eme, avec taboo/p ick" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "descr:= [4,0,0,0,0,5, 0$6,0,6,0,0,3,2,6,0,5,2,0,4,0,0,0,6,2,0,0$6]; # nops(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "# mem_seed:=_seed; " }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 22 "_seed := 662742185431;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "game(3,2, descr): saylevel(none): vazy_pick(); ou; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 129 "prove_pick(); \nif % the n game(m,n, descr): saylevel(res): list_pick(); fi:\n'this_pick'=eval( this_pick); xres_cut(): print_joli();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 16 "Un exemple taboo" }}{EXCHG {PARA 0 "" 0 "" {MPLTEXT 0 21 137 "\"/home/douillet/docs/Cherche/sudoku/sud_ 3_3_taboo.m\"; read %; \nconvert(eval(ma), listlist): descr:= map(op, \+ map(op, subs(tous=\{0\}, %)));;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 278 "descr := [0, 0, 0, 0, 17, 0, 16, 15, 0, 0, 0, 0, 0, 0, 0, 10, 14, 0, 0, 0, 16, 0, 0, 0, 0, 17, 0, 0, 16, 12, 0, 0, 0, 0, 0, 0, 14, \+ 0, 0, 0, 15, 0, 0, 10, 13, 18, 15, 0, 0, 13, 0, 0, 0, 0, 12, 0, 13, 0, 16, 0, 0, 11, 0, 0, 0, 0, 0, 0, 14, 17, 0, 0, 10, 11, 0, 0, 0, 12, 0, 0, 0]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "game(3,3,descr): saylevel(res): taboo(); view();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 16 "Un exemple totem" }}{EXCHG {PARA 0 "" 0 "" {MPLTEXT 0 21 137 "\"/home/douillet/docs/Cherche/sudoku/sud_ 3_3_totem.m\"; read %; \nconvert(eval(ma), listlist): descr:= map(op, \+ map(op, subs(tous=\{0\}, %)));;" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 276 "descr := [0, 0, 0, 0, 0, 13, 0, 0, 18, 0, 13, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 18, 0, 0, 0, 0, 0, 0, 0, 10, 0, 15, 0, 0, 14, 17, 11, 0, 0, 0, 12, 0, 0, 18, 0, 0, 0, 0, 0, 0, 16, 0, 12, 0, 0, 0, 0, 0, 0, 0, 15, 16, 0, 0, 13, 0, 0, 17, 0, 10, 10, 0, 0, 0, 18, 0, 14, 0, 0]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "ga me(3,3,descr): saylevel(res): vazy_pick();" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 25 "xres_cut(): print_joli();" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 21 "Constru cteur sud, 3,3" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "new_sud(3, 3); view();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 40 "Constructeur sam, 2,2 et probl\350me totem" }}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 25 "m__,n__,quoi:=2,2,totem; " }}}{EXCHG {PARA 0 "" 0 "" {MPLTEXT 0 21 28 "new_sam(m__,n__); bigview();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "# bigproblem(m__,n__, quoi);" } {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 8 "Solution" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 146 "biginit(m__,n__); \ncat(repert, \"sam_\" , m, \"_\", n, \"_\", quoi, \".m\"); read %; bigview();\nsaylevel(res) : quoi(); xres_cut(): print_joli(); bigview();" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 40 "Cons tructeur sam, 2, 3 et probl\350me totem" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "m__,n__,quoi:=2,3,totem; " }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 30 "# new_sam(m__,n__); bigview();" }{TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "# bigproblem(m__,n__, quoi); " }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 8 "Solution" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 146 "biginit(m__,n__); \ncat(repert, \" sam_\", m, \"_\", n, \"_\", quoi, \".m\"); read %; bigview();\nsayleve l(res): quoi(); xres_cut(): print_joli(); bigview();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 40 "Constructeur sam, 3, 3 et probl\350me totem" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "m__,n__,quoi:=3,3,totem; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "# new_sam(m__,n__); " }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 28 "# bigproblem(m__,n__, quoi);" }{TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "# op(eval(tab)): remove(hast ype, %, set): nops(%%), nops(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 8 "Solution" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 146 "biginit(m__,n__); \ncat(repert, \" sam_\", m, \"_\", n, \"_\", quoi, \".m\"); read %; bigview();\nsayleve l(res): quoi(); xres_cut(): print_joli(); bigview();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "3" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }