<?xml version="1.0" encoding="UTF-8"?>
<Worksheet>
<Version major="2015" minor="0"/>
<Label-Scheme value="2" prefix=""/>
<View-Properties presentation="true" autoexpanding_sections="true" UserProfileName="Maple Default Profile" NumericFormat-ApplyInteger="true" NumericFormat-ApplyRational="true" NumericFormat-ApplyExponent="false">
</View-Properties>
<MapleNet-Properties elisiondigitsbefore="100" labelling="true" indentamount="4" elisiontermsthreshold="10000" ansi="false" errorbreak="1" useclientjvm="true" echo="1" imaginaryunit="I" labelwidth="20" unitattributes="&quot;fontweight&quot; = &quot;bold&quot;" contextmenusize="automatic" plotdriver="opengl" elisiondigitsafter="100" plotoutput="terminal" helpbrowser="standard" rtablesize="10" elisiontermsbefore="100" elisiondigitsthreshold="10000" typesetting="standard" plotdevice="inline" verboseproc="1" showassumed="1" quiet="false" errorcursor="false" longdelim="true" plotoptions="" elisiontermsafter="100" screenwidth="79" preplot="" prettyprint="3" displayprecision="-1" screenpixelheight="1080" warnlevel="3" screenheight="25" latexwidth="8.0" postplot="" prompt="&gt; " ShowLabels="true"/>
<Styles>
<Font name="Ordered List 1" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Annotation Text" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 2" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 3" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 4" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 5" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Author" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Annotation Title" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Warning" background="[255,255,255]" bold="false" executable="false" family="Courier New" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Caption Reference" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Input Placeholder" background="[255,255,255]" bold="true" executable="true" family="Courier New" foreground="[200,0,200]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="true"/>
<Font name="Maple Plot" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Code" background="[255,255,255]" bold="false" executable="false" family="Courier New" foreground="[255,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Line Printed Output" background="[255,255,255]" bold="false" executable="false" family="Courier New" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Text Output" background="[255,255,255]" bold="false" executable="false" family="Courier New" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Diagnostic" background="[255,255,255]" bold="false" executable="false" family="Courier New" foreground="[40,120,40]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Inert Output" background="[255,255,255]" bold="false" executable="true" family="Times New Roman" foreground="[144,144,144]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Normal" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Hyperlink" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,128,128]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="true" placeholder="false"/>
<Font name="Maple Output" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Dash Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Math" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Input" background="[255,255,255]" bold="true" executable="true" family="Courier New" foreground="[120,0,14]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Output" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Input" background="[255,255,255]" bold="false" executable="true" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="HyperlinkError" background="[255,255,255]" bold="false" executable="false" family="Courier New" foreground="[255,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="true" placeholder="false"/>
<Font name="Header and Footer" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="10" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Error" background="[255,255,255]" bold="false" executable="false" family="Courier New" foreground="[255,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Title" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 1" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Text" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Bullet Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 4" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="true" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Equation Label" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 3" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="true" opaque="false" readonly="false" size="14" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 2" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="16" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="HyperlinkWarning" background="[255,255,255]" bold="false" executable="false" family="Courier New" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="true" placeholder="false"/>
<Font name="Dictionary Hyperlink" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[147,0,15]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="true" placeholder="false"/>
<Font name="Atomic Variable" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[175,0,175]" italic="true" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Caption Text" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="List Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Layout name="Ordered List 1" alignment="left" bullet="numeric" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Ordered List 2" alignment="left" bullet="alphabetic" firstindent="0" leftmargin="36" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Ordered List 3" alignment="left" bullet="roman" firstindent="0" leftmargin="72" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Ordered List 4" alignment="left" bullet="ALPHABETIC" firstindent="0" leftmargin="108" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Ordered List 5" alignment="left" bullet="ROMAN" firstindent="0" leftmargin="144" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Author" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="8" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Warning" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Annotation Title" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="12" spacebelow="12" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Maple Plot" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Line Printed Output" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="any" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Text Output" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="newline" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Diagnostic" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="any" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Normal" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Maple Output" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.3" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Dash Item" alignment="left" bullet="dash" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="HyperlinkError" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Error" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Title" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="12" spacebelow="12" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 1" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="4" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Bullet Item" alignment="left" bullet="dot" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 4" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 3" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 2" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="2" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="HyperlinkWarning" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="List Item" alignment="left" bullet="indent" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Pencil-style name="Pencil 5" pen-color="[255,0,0]" pen-height="5.0" pen-width="5.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 4" pen-color="[0,0,255]" pen-height="3.0" pen-width="3.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 3" pen-color="[0,0,0]" pen-height="3.0" pen-width="3.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 2" pen-color="[0,0,255]" pen-height="1.0" pen-width="1.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 1" pen-color="[0,0,0]" pen-height="1.0" pen-width="1.0" pen-opacity="1.0"/>
<Highlighter-style name="Highlighter 2" pen-color="[255,204,0]" pen-height="14.0" pen-width="14.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 1" pen-color="[255,153,255]" pen-height="12.0" pen-width="8.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 4" pen-color="[0,255,255]" pen-height="32.0" pen-width="32.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 3" pen-color="[51,255,0]" pen-height="24.0" pen-width="24.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 5" pen-color="[255,255,0]" pen-height="48.0" pen-width="48.0" pen-opacity="0.8"/>
</Styles>
<Startup-Code startupcode=""/>
<Task-table>
    <Task-category name="&lt;default&gt;"/>
</Task-table>
<Task/><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L1" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Annotation Title" alignment="left"><Equation executable="true" style="2D Input" input-equation="Maplet*de*Sudoku:" display="LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzZELUkjbWlHRiQ2J1EnTWFwbGV0RicvJSVzaXplR1EjMThGJy8lJ2l0YWxpY0dRJXRydWVGJy8lKnVuZGVybGluZUdGNC8lLG1hdGh2YXJpYW50R1EnaXRhbGljRictSSNtb0dGJDYvUSJ+RidGL0Y1L0Y4USdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGQi8lKXN0cmV0Y2h5R0ZCLyUqc3ltbWV0cmljR0ZCLyUobGFyZ2VvcEdGQi8lLm1vdmFibGVsaW1pdHNHRkIvJSdhY2NlbnRHRkIvJSdsc3BhY2VHUSYwLjBlbUYnLyUncnNwYWNlR0ZRLUYsNidRI2RlRidGL0YyRjVGN0Y6LUYsNidRJ1N1ZG9rdUYnRi9GMkY1RjdGOi1GOzYuUSI6RidGL0Y+RkBGQ0ZFRkdGSUZLRk0vRlBRLDAuMjc3Nzc3OGVtRicvRlNGaG4tRjs2LkY9Ri9GPkZARkNGRUZHRklGS0ZNRk9GUi1GLDYmUShBcHB1eWVyRidGL0YyRjdGam4tRiw2JlEkc3VyRidGL0YyRjdGam4tRiw2JlEjbGVGJ0YvRjJGN0Zqbi1GLDYmUSdib3V0b25GJ0YvRjJGN0Zqbi1GLDYmUSNlbkYnRi9GMkY3RmpuLUYsNiZRKGRlc3NvdXNGJ0YvRjJGN0Zqbi1GLDYmUSVwb3VyRidGL0YyRjdGam4tRiw2JlEuZXgmIzIzMztjdXRlckYnRi9GMkY3RmpuLUYsNiZRI2xhRidGL0YyRjdGam4tRiw2JlEnbWFwbGV0RidGL0YyRjdGam5GWkZqbkZqbkZqbi8lK2V4ZWN1dGFibGVHRkJGPg==">QyYqKEknTWFwbGV0RzYiIiIiSSNkZUdGJUYmSSdTdWRva3VHRiVGJiEiIio2SShBcHB1eWVyR0YlRiZJJHN1ckdGJUYmSSNsZUdGJUYmSSdib3V0b25HRiVGJkkjZW5HRiVGJkkoZGVzc291c0dGJUYmSSVwb3VyR0YlRiZJKmV4fF53fGR1Y3V0ZXJHRiVGJkkjbGFHRiVGJkknbWFwbGV0R0YlRiZGKQ==</Equation></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L2" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
<Input>
<Text-field style="Text" layout="Normal"><Equation executable="false" style="2D Math" input-equation="" display="LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbWlHRiQ2I1EhRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYn">JSFH</Equation></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block><CodeEditor-ExecGroup view="presentation" hide-input="false" hide-output="true" inline-output="false" applyint="true" applyrational="true" display="code"><EC-CodeEditor id="CodeEditRegion0" visible="false" pixel-width="196902" pixel-height="517" code-language="text/maple" autoexpand="true" wrapping="false" show-border="true" code-line-numbers="true">with(StringTools):with(plots):fracs:=proc(n0);n:=n0;while(frac(n)&lt;&gt;0) do n:=n*10;od;return(floor(n));end;modx1:=proc(i,n);if (i=e or i=r) then m:=i;else x:=(i mod n);if x=0 then m:=n else m:=x;fi;fi;return(m);end;modx:=proc(i,n);x:=(i mod n);if x=0 then n else x;fi;end;zone:=proc(a,b,i0,j0);d := [seq(seq([[1+(i-1)*b, 1+(j-1)*a],[i,j]],j = 1 .. b),i = 1 .. a)];for k from 1 to nops(d) do if i0&lt;=d[k][1][1]+b-1 and i0&gt;=d[k][1][1] and j0&lt;=d[k][1][2]+a-1 and j0&gt;=d[k][1][2] then z:=d[k][2];break;fi;od;return(z);end;
sousta := proc (l, d) local A, i, r, j; A := []; for i to nops(l) do r := 0; for j to nops(d) do if l[i] = d[j] then r := 1 end if end do; if r = 0 then A := [op(A), l[i]] end if end do; return A end proc;
gen:=proc(a,b) local n,m,l,d,x,B,i,kk,e,r,i1,j1,k1,c,s,Z,A,dd,ss,AA,Zi,k; n:=b; m:=a; l:=[]; d:=[seq(seq([1+(i - 1)*b,1+(j - 1)*a],j=1..n),i=1..m)]; x:=[]; B:=[]; i:=1; kk:=0; while i&lt;=a*b*n*m do if i=1 then Z:=[] end if; Zi:=[]; for k to nops(Z) do if nops(Z) - k+2&lt;=nops(Z) then if Z[nops(Z) - k+1][1]=i and i&lt;Z[nops(Z) - k+2][1] then Zi:=Z[nops(Z) - k+1][2]; break end if end if end do; e:=0; r:=`mod`(i,m*b); if r=0 then i1:=(i - r)/(m*b); j1:=n*a else i1:=(i - r)/(m*b)+1; j1:=r end if; for k1 to nops(d) do if d[k1][1]&lt;=i1 and i1&lt;=d[k1][1]+b - 1 and d[k1][2]&lt;=j1 and j1&lt;=d[k1][2]+a - 1 then c:=d[k1]; break end if end do; s:=convert({seq(l[(io - 1)*m*b+j1],io=1..c[1] - 1),seq(l[(i1 - 1)*m*b+jo],jo=1..c[2] - 1),seq(l[(i1 - 1)*m*b+jo],jo=c[2]..j1 - 1),seq(seq(l[(io - 1)*m*b+jo],io=c[1]..i1 - 1),jo=c[2]..c[2]+a - 1)},list); while e=0 do s:=convert({op(x),op(s),op(Zi)},list); if {op(s)}={seq(j,j=1..a*b)} then x:=[]; Z:=[op(Z),[i,[]]]; l:=[seq(l[j],j=1..nops(l) - 1)]; i:=i - 1; e:=1 else A:=sousta([seq(kh,kh=1..a*b)],s); x:=[A[modu(rand(),nops(A))]]; dd:=[op(l),op(x)]; if i&lt;a*b*n*m then i:=i+1; r:=`mod`(i,m*b); if r=0 then i1:=(i - r)/(m*b); j1:=n*a else i1:=(i - r)/(m*b)+1; j1:=r end if; for k1 to nops(d) do if d[k1][1]&lt;=i1 and i1&lt;=d[k1][1]+b - 1 and d[k1][2]&lt;=j1 and j1&lt;=d[k1][2]+a - 1 then c:=d[k1]; break end if end do; ss:=convert({seq(dd[(io - 1)*m*b+j1],io=1..c[1] - 1),seq(dd[(i1 - 1)*m*b+jo],jo=1..c[2] - 1),seq(dd[(i1 - 1)*m*b+jo],jo=c[2]..j1 - 1),seq(seq(dd[(io - 1)*m*b+jo],io=c[1]..i1 - 1),jo=c[2]..c[2]+a - 1)},list); AA:=sousta([seq(j,j=1..a*b)],ss); if AA=[] then i:=i - 1 else e:=1; l:=[op(l),op(x)]; Z:=[op(Z),[i - 1,[op(x),op(Zi)]]]; x:=[] end if else e:=1; l:=[op(l),op(x)]; Z:=[op(Z),[i,[op(x),op(Zi)]]]; x:=[]; i:=i+1 end if end if end do end do; return l end proc;
presenta := proc (l, a, b) options operator, arrow; Vector[row](2, {(1) = seq, (2) = [seq(l[j], j = 1+(i-1)*b*a .. i*b*a)], i = 1 .. nops(l)/(b*a)}) end proc;
multi_gen := proc (n, a, b) local A, i, l; A := []; i := 1; while i &lt;= n do l := gen(a, b); if not member(l, A) then A := [op(A), l]; i := i+1 end if end do; return A end proc;
al:=(i,l,c)-&gt;if i=l then c else 1 end if;
f1 := proc (l0, n) local l, i, A, j, d, ki; l := l0; for i to nops(l) do A := []; for j to nops(l[i]) do if l[i][j][1] &lt;&gt; `` then A := [op(A), l[i][j][1]] end if end do; d := sousta([seq(i,i = 1 .. n)],A); for ki to nops(d) do for j to nops(l[i]) do if l[i][j][1] = `` and not member(d[ki],[seq(l[i][j][1],i = 1 .. nops(l))]) then l := [seq(l[x],x = 1 .. i-1), [seq(l[i][t],t = 1 .. j-1), [l[i][j][1], [op(l[i][j][2]), d[ki]]], seq(l[i][t],t = j+1 .. nops(l[i]))], seq(l[x],x = i+1 .. nops(l))] end if end do end do end do; return l end proc;
f2 := proc (l0, a, b) local l, d, ki, A, i, j, ti, xi, yi; l := l0; d := [seq(seq([1+(i-1)*b, 1+(j-1)*a],j = 1 .. b),i = 1 .. a)]; for ki to nops(d) do A := []; for i from d[ki][1] to d[ki][1]+b-1 do for j from d[ki][2] to d[ki][2]+a-1 do if l[i][j][1] &lt;&gt; `` then A := [op(A), l[i][j][1]] end if end do end do; for ti to nops(A) do for xi from d[ki][1] to d[ki][1]+b-1 do for yi from d[ki][2] to d[ki][2]+a-1 do l := [seq(l[x],x = 1 .. xi-1), [seq(l[xi][t],t = 1 .. yi-1), [l[xi][yi][1], sousta(l[xi][yi][2],[A[ti]])], seq(l[xi][t],t = yi+1 .. nops(l[xi]))], seq(l[x],x = xi+1 .. nops(l))] end do end do end do end do; return l end proc;
f3 := proc (l0, a, b) local l, d, te, i, j, r, ki, xi, yi, dd; l := l0; d := [seq(seq([1+(i-1)*b, 1+(j-1)*a], j = 1 .. b), i = 1 .. a)]; for i to a*b do for j to nops(l[1]) do if nops(l[i][j][2]) = 1 then l := [seq(l[x], x = 1 .. i-1), [seq(l[i][t], t = 1 .. j-1), [op(l[i][j][2]), []], seq(l[i][t], t = j+1 .. nops(l[i]))], seq(l[x], x = i+1 .. nops(l))]; r := 0; for ki to nops(d) do if d[ki][1] &lt;= i and i &lt;= d[ki][1]+b-1 and d[ki][2] &lt;= j and j &lt;= d[ki][2]+a-1 then r := ki; break end if end do; for xi from d[r][1] to d[r][1]+b-1 do for yi from d[r][2] to d[r][2]+a-1 do l := [seq(l[x], x = 1 .. xi-1), [seq(l[xi][t], t = 1 .. yi-1), [l[xi][yi][1], sousta(l[xi][yi][2], [l[i][j][1]])], seq(l[xi][t], t = yi+1 .. nops(l[xi]))], seq(l[x], x = xi+1 .. nops(l))] end do end do; l := [seq(l[x], x = 1 .. i-1), [seq([l[i][kj][1], sousta(l[i][kj][2], [l[i][j][1]])], kj = 1 .. j-1), l[i][j], seq([l[i][kj][1], sousta(l[i][kj][2], [l[i][j][1]])], kj = j+1 .. nops(l[i]))], seq(l[x], x = i+1 .. nops(l))]; l := [seq([seq(l[x][kj], kj = 1 .. j-1), [l[x][j][1], sousta(l[x][j][2], [l[i][j][1]])], seq(l[x][kj], kj = j+1 .. nops(l[i]))], x = 1 .. i-1), l[i], seq([seq(l[x][kj], kj = 1 .. j-1), [l[x][j][1], sousta(l[x][j][2], [l[i][j][1]])], seq(l[x][kj], kj = j+1 .. nops(l[i]))], x = i+1 .. nops(l))]; break end if end do end do; te := 0; while te = 0 do dd := l; l := f4(l, a, b); for i to a*b do for j to nops(l[1]) do if nops(l[i][j][2]) = 1 then l := [seq(l[x], x = 1 .. i-1), [seq(l[i][t], t = 1 .. j-1), [op(l[i][j][2]), []], seq(l[i][t], t = j+1 .. nops(l[i]))], seq(l[x], x = i+1 .. nops(l))]; r := 0; for ki to nops(d) do if d[ki][1] &lt;= i and i &lt;= d[ki][1]+b-1 and d[ki][2] &lt;= j and j &lt;= d[ki][2]+a-1 then r := ki; break end if end do; for xi from d[r][1] to d[r][1]+b-1 do for yi from d[r][2] to d[r][2]+a-1 do l := [seq(l[x], x = 1 .. xi-1), [seq(l[xi][t], t = 1 .. yi-1), [l[xi][yi][1], sousta(l[xi][yi][2], [l[i][j][1]])], seq(l[xi][t], t = yi+1 .. nops(l[xi]))], seq(l[x], x = xi+1 .. nops(l))] end do end do; l := [seq(l[x], x = 1 .. i-1), [seq([l[i][kj][1], sousta(l[i][kj][2], [l[i][j][1]])], kj = 1 .. j-1), l[i][j], seq([l[i][kj][1], sousta(l[i][kj][2], [l[i][j][1]])], kj = j+1 .. nops(l[i]))], seq(l[x], x = i+1 .. nops(l))]; l := [seq([seq(l[x][kj], kj = 1 .. j-1), [l[x][j][1], sousta(l[x][j][2], [l[i][j][1]])], seq(l[x][kj], kj = j+1 .. nops(l[i]))], x = 1 .. i-1), l[i], seq([seq(l[x][kj], kj = 1 .. j-1), [l[x][j][1], sousta(l[x][j][2], [l[i][j][1]])], seq(l[x][kj], kj = j+1 .. nops(l[i]))], x = i+1 .. nops(l))]; break end if end do end do; l := f5(l, a, b); for i to a*b do for j to nops(l[1]) do if nops(l[i][j][2]) = 1 then l := [seq(l[x], x = 1 .. i-1), [seq(l[i][t], t = 1 .. j-1), [op(l[i][j][2]), []], seq(l[i][t], t = j+1 .. nops(l[i]))], seq(l[x], x = i+1 .. nops(l))]; r := 0; for ki to nops(d) do if d[ki][1] &lt;= i and i &lt;= d[ki][1]+b-1 and d[ki][2] &lt;= j and j &lt;= d[ki][2]+a-1 then r := ki; break end if end do; for xi from d[r][1] to d[r][1]+b-1 do for yi from d[r][2] to d[r][2]+a-1 do l := [seq(l[x], x = 1 .. xi-1), [seq(l[xi][t], t = 1 .. yi-1), [l[xi][yi][1], sousta(l[xi][yi][2], [l[i][j][1]])], seq(l[xi][t], t = yi+1 .. nops(l[xi]))], seq(l[x], x = xi+1 .. nops(l))] end do end do; l := [seq(l[x], x = 1 .. i-1), [seq([l[i][kj][1], sousta(l[i][kj][2], [l[i][j][1]])], kj = 1 .. j-1), l[i][j], seq([l[i][kj][1], sousta(l[i][kj][2], [l[i][j][1]])], kj = j+1 .. nops(l[i]))], seq(l[x], x = i+1 .. nops(l))]; l := [seq([seq(l[x][kj], kj = 1 .. j-1), [l[x][j][1], sousta(l[x][j][2], [l[i][j][1]])], seq(l[x][kj], kj = j+1 .. nops(l[i]))], x = 1 .. i-1), l[i], seq([seq(l[x][kj], kj = 1 .. j-1), [l[x][j][1], sousta(l[x][j][2], [l[i][j][1]])], seq(l[x][kj], kj = j+1 .. nops(l[i]))], x = i+1 .. nops(l))]; break end if end do end do; if l = dd then te := 1 end if end do; return l end proc;
suivant:=(c,a,b)-&gt;if c[2]=a*b then [c[1]+1,1] else [c[1],c[2]+1] end if;
sudoku := proc (l0, a, b) local d, l, z, rz1, ki, kj, Co, e, CC, t, C, i, j, Ca, err, k, rz, ti, za, B, A, x, s; d := [seq([seq([1+(i-1)*b, 1+(j-1)*a],j = 1 .. b)],i = 1 .. a)]; l := [seq([seq([l0[i][j], []],j = 1 .. nops(l0[1]))],i = 1 .. nops(l0))]; z := f3(f2(f1(l,b*a),a,b),a,b); rz1 := 0; for ki to nops(z) do for kj to nops(z[1]) do if z[ki][kj][1] = `` then rz1 := 1; break end if end do end do; if rz1 = 1 then Co := [[z, [1, 1]]]; e := 0; CC := [];  while e = 0 do for t to nops(Co) do if e = 0 then C := Co[t]; for i from C[2][1] to C[2][1] do if e = 0 then for j from C[2][2] to C[2][2] do if e = 0 then if 2 &lt;= nops(C[1][i][j][2]) then Ca := [seq([f3([seq(C[1][x],x = 1 .. i-1), [seq(C[1][i][y],y = 1 .. j-1), [``, [C[1][i][j][2][k]]], seq(C[1][i][y],y = j+1 .. nops(C[1][i]))], seq(C[1][x],x = i+1 .. nops(C[1]))],a,b), suivant([i, j],a,b)],k = 1 .. nops(C[1][i][j][2]))]; err := [seq(1,k = 1 .. nops(Ca))]; for k to nops(Ca) do rz := 0; for ki to nops(Ca[k][1]) do for kj to nops(Ca[k][1][1]) do if Ca[k][1][ki][kj][1] = `` then rz := 1; break end if end do end do; err := [seq(err[ui],ui = 1 .. k-1), rz, seq(err[ui],ui = k+1 .. nops(err))] end do; for ti to nops(err) do if err[ti] = 0 then z := Ca[ti][1]; e := 1; break else CC := [op(CC), Ca[ti]] end if end do elif C[1][i][j][1] &lt;&gt; `` then CC := [op(CC), [C[1], suivant([C[2][1], C[2][2]],a,b)]] end if else break end if end do else break end if end do else break end if end do; Co := CC; CC := [] end do end if; za := [seq([seq(z[i][j][1],j = 1 .. nops(z[1]))],i = 1 .. nops(z))]; B := []; for ki to nops(d) do A := []; for x to nops(d[ki]) do s := [seq([seq(za[i][j],j = d[ki][x][2] .. d[ki][x][2]+a-1)],i = d[ki][x][1] .. d[ki][x][1]+b-1)]; A := [op(A), matrix(s)] end do; B := [op(B), A] end do; return matrix(B) end proc;
f4 := proc (l0, a, b) local l, d, i, j, r, ki, xi, yi, zi, ti, kj, ko; l := l0; d := [seq(seq([1+(i-1)*b, 1+(j-1)*a], j = 1 .. b), i = 1 .. a)]; for i to nops(l) do for j to nops(l[1]) do if nops(l[i][j][2]) = 2 then r := 0; for ki to nops(d) do if d[ki][1] &lt;= i and i &lt;= d[ki][1]+b-1 and d[ki][2] &lt;= j and j &lt;= d[ki][2]+a-1 then r := ki; break end if end do; for xi from d[r][1] to d[r][1]+b-1 do for yi from d[r][2] to d[r][2]+a-1 do if l[xi][yi][2] = l[i][j][2] and [xi, yi] &lt;&gt; [i, j] then for zi from d[r][1] to d[r][1]+b-1 do for ti from d[r][2] to d[r][2]+a-1 do if not member([zi, ti], [[i, j], [xi, yi]]) then l := [seq(l[x], x = 1 .. zi-1), [seq(l[zi][y], y = 1 .. ti-1), [l[zi][ti][1], sousta(l[zi][ti][2], l[i][j][2])], seq(l[zi][y], y = ti+1 .. nops(l[zi]))], seq(l[x], x = zi+1 .. nops(l))] end if end do end do end if end do end do; for kj to nops(l[i]) do if l[i][kj][2] = l[i][j][2] and [i, kj] &lt;&gt; [i, j] then for ko to nops(l[i]) do if not member([i, ko], [[i, kj], [i, j]]) then l := [seq(l[x], x = 1 .. i-1), [seq(l[i][t], t = 1 .. ko-1), [l[i][ko][1], sousta(l[i][ko][2], l[i][j][2])], seq(l[i][t], t = ko+1 .. nops(l[i]))], seq(l[x], x = i+1 .. nops(l))] end if end do end if end do; for ki to nops(l) do if l[ki][j][2] = l[i][j][2] and [ki, j] &lt;&gt; [i, j] then for ko to nops(l) do if not member([ko, j], [[ki, j], [i, j]]) then l := [seq(l[x], x = 1 .. ko-1), [seq(l[ko][y], y = 1 .. j-1), [l[ko][j][1], sousta(l[ko][j][2], l[i][j][2])], seq(l[ko][y], y = j+1 .. nops(l[ko]))], seq(l[x], x = ko+1 .. nops(l))] end if end do end if end do end if end do end do; return l end proc;
f5 := proc (l0, a, b) local l, d, ki, n, A, i, j; l := l0; d := [seq(seq([1+(i-1)*b, 1+(j-1)*a], j = 1 .. b), i = 1 .. a)]; for ki to nops(d) do for n to a*b do A := []; for i from d[ki][1] to d[ki][1]+b-1 do for j from d[ki][2] to d[ki][2]+a-1 do if member(n, l[i][j][2]) then A := [op(A), [i, j]] end if end do end do; if nops(A) = 1 then l := [seq(l[x], x = 1 .. A[1][1]-1), [seq(l[A[1][1]][y], y = 1 .. A[1][2]-1), [l[A[1][1]][A[1][2]][1], [n]], seq(l[A[1][1]][y], y = A[1][2]+1 .. nops(l[1]))], seq(l[x], x = A[1][1]+1 .. nops(l))] end if end do end do; for n to a*b do for i to nops(l) do A := []; for j to nops(l[1]) do if member(n, l[i][j][2]) then A := [op(A), [i, j]] end if end do; if nops(A) = 1 then l := [seq(l[x], x = 1 .. A[1][1]-1), [seq(l[A[1][1]][y], y = 1 .. A[1][2]-1), [l[A[1][1]][A[1][2]][1], [n]], seq(l[A[1][1]][y], y = A[1][2]+1 .. nops(l[1]))], seq(l[x], x = A[1][1]+1 .. nops(l))] end if end do end do; for n to a*b do for j to nops(l[1]) do A := []; for i to nops(l) do if member(n, l[i][j][2]) then A := [op(A), [i, j]] end if end do; if nops(A) = 1 then l := [seq(l[x], x = 1 .. A[1][1]-1), [seq(l[A[1][1]][y], y = 1 .. A[1][2]-1), [l[A[1][1]][A[1][2]][1], [n]], seq(l[A[1][1]][y], y = A[1][2]+1 .. nops(l[1]))], seq(l[x], x = A[1][1]+1 .. nops(l))] end if end do end do; return l end proc;
trouage := proc (N, a, b) local l, ch, i, v, k, d, L, LL, S, e, ki, kj, su, sud, ti, dd, za, B, A, x, s, j, A1; with(plots); dd := [seq([seq([1+(i-1)*b, 1+(j-1)*a],j = 1 .. b)],i = 1 .. a)]; l := gen(a,b); ch := []; i := 1;  while i &lt;= N do v := `mod`(rand(),a^2*b^2)+1; if not member(v,ch) then ch := [op(ch), v]; i := i+1 end if end do; for k to nops(ch) do d := l; l := [seq(l[t],t = 1 .. ch[k]-1), ``, seq(l[t],t = ch[k]+1 .. nops(l))]; L := presenta2(l,a,b); S := nombre_de_solutions(L,a,b); if 2 &lt;= S then l := d end if end do; za := presenta2(l,a,b); A1 := []; for ki to nops(za) do for kj to nops(za[ki]) do if za[ki][kj] &lt;&gt; `` then A1 := [op(A1), [kj, nops(za)-ki+1, za[ki][kj]]] end if end do end do; B := plots:-display({plots:-polygonplot([seq([[.5+k, .5], [.5+k, b*a+.5]],k = 0 .. b*a), seq(op([[[.4+a*t, .5], [.4+a*t, b*a+.5]], [[.6+a*t, .5], [.6+a*t, b*a+.5]]]),t = 1 .. b-1), seq([[.5, .5+k], [b*a+.5, .5+k]],k = 0 .. b*a), seq(op([[[.5, .4+b*t], [b*a+.5, .4+b*t]], [[.5, .6+b*t], [b*a+.5, .6+b*t]]]),t = 1 .. a-1)]), plots:-textplot(A1,color = red)},axes = none,scaling = constrained); return [[seq([seq(l[i],i = 1+(k-1)*a*b .. k*a*b)],k = 1 .. b*a)], B] end proc;
nombre_de_solutions := proc (l0, a, b) local d, l, z, rz1, ki, kj, Co, e, CC, t, C, i, j, Ca, err, k, rz, ti, za, B, A, x, s, zz, ca, kl1, kl2; d := [seq([seq([1+(i-1)*b, 1+(j-1)*a],j = 1 .. b)],i = 1 .. a)]; l := [seq([seq([l0[i][j], []],j = 1 .. nops(l0[1]))],i = 1 .. nops(l0))]; z := []; zz := f3(f2(f1(l,b*a),a,b),a,b); rz1 := 0; for ki to nops(zz) do for kj to nops(zz[1]) do if zz[ki][kj][1] = `` then rz1 := 1; break end if end do end do; if rz1 = 0 then z := [zz] else Co := [[zz, [1, 1]]]; e := 0; CC := [];  while e &lt; 2 and Co &lt;&gt; [] do for t to nops(Co) do if e &lt; 2 and Co &lt;&gt; [] then C := Co[t]; for i from C[2][1] to C[2][1] do if e &lt; 2 and Co &lt;&gt; [] then for j from C[2][2] to C[2][2] do if e &lt; 2 and Co &lt;&gt; [] then if 2 &lt;= nops(C[1][i][j][2]) then Ca := [seq([f3([seq(C[1][x],x = 1 .. i-1), [seq(C[1][i][y],y = 1 .. j-1), [``, [C[1][i][j][2][k]]], seq(C[1][i][y],y = j+1 .. nops(C[1][i]))], seq(C[1][x],x = i+1 .. nops(C[1]))],a,b), suivant([i, j],a,b)],k = 1 .. nops(C[1][i][j][2]))]; err := [seq(1,k = 1 .. nops(Ca))]; for k to nops(Ca) do rz := 0; for ki to nops(Ca[k][1]) do for kj to nops(Ca[k][1][1]) do if Ca[k][1][ki][kj][1] = `` then rz := 1; break end if end do end do; err := [seq(err[ui],ui = 1 .. k-1), rz, seq(err[ui],ui = k+1 .. nops(err))] end do; for ti to nops(err) do if err[ti] = 0 then z := convert({Ca[ti][1], op(z)},list); e := nops(z) else ca := 0; for kl1 to nops(Ca[ti][1]) do if ca = 1 then break else for kl2 to nops(Ca[ti][1][kl1]) do if Ca[ti][1][kl1][kl2] = [``, []] then ca := 1; break end if end do end if end do; if ca = 0 then CC := [op(CC), Ca[ti]] end if end if end do elif C[1][i][j][1] &lt;&gt; `` then CC := [op(CC), [C[1], suivant([C[2][1], C[2][2]],a,b)]] end if else break end if end do else break end if end do else break end if end do; Co := CC; CC := [] end do end if; return nops(convert({op(z)},list)) end proc;
presenta2 := proc (l, a, b) options operator, arrow; [seq([seq(l[j], j = 1+(i-1)*b*a .. i*b*a)], i = 1 .. nops(l)/(b*a))] end proc;
generateur := proc () local N, nb, i, A, B, m, k, w, a, b; printf(&quot;inserer la largeur d'une zone:\134n&quot;); a := op(scanf(&quot;%d&quot;,a)); printf(&quot;inserer la hauteur d'une zone:\134n&quot;); b := op(scanf(&quot;%d&quot;,b)); printf(&quot;inserer le nombre de trous maximum dans chaque sudoku (nombre inferieur \303\240 %d):\134n&quot;,a^2*b^2); N := op(scanf(&quot;%d&quot;,N)); printf(&quot;inserer le nombre de grilles \303\240 g\303\251n\303\251rer:\134n&quot;); nb := op(scanf(&quot;%d&quot;,nb)); printf(&quot;inserer un entier\134n&quot;); w := op(scanf(&quot;%d&quot;,w));randomize(w); i := 1; A := []; B := [];  while i &lt;= nb do m := trouage(N,a,b); if not member(m[1],A) then A := [op(A), m[1]]; B := [op(B), m[2]]; i := i+1 end if end do; for k to nops(B) do print(A[k]); print(); print(B[k]); print() end do end proc;
modu := (a, n) -&gt; if `mod`(a,n) = 0 then n else `mod`(a,n) end if;
sudoku := proc (l0, a, b) local d, l, z, rz1, ki, kj, Co, e, CC, t, C, i, j, Ca, err, k, rz, ti, za, B, A, x, s; d := [seq([seq([1+(i-1)*b, 1+(j-1)*a],j = 1 .. b)],i = 1 .. a)]; l := [seq([seq([l0[i][j], []],j = 1 .. nops(l0[1]))],i = 1 .. nops(l0))]; z := f3(f2(f1(l,b*a),a,b),a,b); rz1 := 0; for ki to nops(z) do for kj to nops(z[1]) do if z[ki][kj][1] = `` then rz1 := 1; break end if end do end do; if rz1 = 1 then Co := [[z, [1, 1]]]; e := 0; CC := [];  while e = 0 do for t to nops(Co) do if e = 0 then C := Co[t]; for i from C[2][1] to C[2][1] do if e = 0 then for j from C[2][2] to C[2][2] do if e = 0 then if 2 &lt;= nops(C[1][i][j][2]) then Ca := [seq([f3([seq(C[1][x],x = 1 .. i-1), [seq(C[1][i][y],y = 1 .. j-1), [``, [C[1][i][j][2][k]]], seq(C[1][i][y],y = j+1 .. nops(C[1][i]))], seq(C[1][x],x = i+1 .. nops(C[1]))],a,b), suivant([i, j],a,b)],k = 1 .. nops(C[1][i][j][2]))]; err := [seq(1,k = 1 .. nops(Ca))]; for k to nops(Ca) do rz := 0; for ki to nops(Ca[k][1]) do for kj to nops(Ca[k][1][1]) do if Ca[k][1][ki][kj][1] = `` then rz := 1; break end if end do end do; err := [seq(err[ui],ui = 1 .. k-1), rz, seq(err[ui],ui = k+1 .. nops(err))] end do; for ti to nops(err) do if err[ti] = 0 then z := Ca[ti][1]; e := 1; break else CC := [op(CC), Ca[ti]] end if end do elif C[1][i][j][1] &lt;&gt; `` then CC := [op(CC), [C[1], suivant([C[2][1], C[2][2]],a,b)]] end if else break end if end do else break end if end do else break end if end do; Co := CC; CC := [] end do end if; za := [seq([seq(z[i][j][1],j = 1 .. nops(z[1]))],i = 1 .. nops(z))]; return za end proc;
trouage := proc (N, a, b) local l, ch, i, v, k, d, L, LL, S, e, ki, kj, su, sud, ti, dd, za, B, A, x, s, j, A1; with(plots); dd := [seq([seq([1+(i-1)*b, 1+(j-1)*a],j = 1 .. b)],i = 1 .. a)]; l := gen(a,b); ch := []; i := 1;  while i &lt;= N do v := `mod`(rand(),a^2*b^2)+1; if not member(v,ch) then ch := [op(ch), v]; i := i+1 end if end do; for k to nops(ch) do d := l; l := [seq(l[t],t = 1 .. ch[k]-1), ``, seq(l[t],t = ch[k]+1 .. nops(l))]; L := presenta2(l,a,b); S := nombre_de_solutions(L,a,b); if 2 &lt;= S then l := d end if end do; return [seq(seq(l[i],i = 1+(k-1)*a*b .. k*a*b),k = 1 .. b*a)] end proc;
generateur := proc (N, nb, w,a,b) local i, A, m; randomize(w); i := 1; A := [];  while i &lt;= nb do m := trouage(N,a,b); if not member(m,A) then A := [op(A), op(m), `*`]; i := i+1 end if end do; return [op(A),N,w,nb] end proc;
par:=x-&gt;if x=&quot;&quot; then `` else parse(x);fi;with(Maplets[Elements]);sudo := proc (l, a, b) local s; s := sudoku(l,a,b); return [seq(op(s[i]),i = 1 .. nops(s))] end proc;
sudok:=(l,a,b)-&gt;if l&lt;&gt;[seq([seq(&quot;dra&quot;,i=1..a*b)],j=1..a*b)] then sudo(l,a,b);else [seq(``,i=1..a*b*b*a)];fi;cont:=proc(x);re:=convert([seq(parse(substring(x,i..i))*10^(length(x)-i),i=1..length(x))],`+`);if re=0 then R:=``;else R:=re;fi;return(R);end;
sudoku_maplet4:=proc(a,b,colo2,police1,sp,pog,col,cor1,cor2,colx,esp);randomize1:=proc() uses Maplets:-Tools;w0:=parse(Get('w'));return(randomize(w0+fracs(time())));end;MEX:=[seq(convert(cat(seq(C,k=1..i)),name),i=1..(a*b))];ME:=[seq(convert(cat(seq(W,k=1..i)),name),i=1..(a*b)^3)];betc:=proc();x:=Maplets:-Tools:-Get('cptkz');return(parse(x));end;chgc:=proc() uses Maplets:-Tools;io:=parse(Get('cptkz'));if Get('MEX'[io]) then Set('MEX'[io]('value')=false); else Set('MEX'[io]('value')=true);fi;end;effmex:=proc(a,b) uses Maplets:-Tools;i:=parse(Get('cpto'));for ki from 1 to a*b do Set('ME'[(i-1)*a*b+ki]=true);Set('MEX'[ki]=true);od;end;recmex:=proc(a,b) uses Maplets:-Tools;cpto1:=parse(Get('cpto'));for ki from 1 to a*b do x:=Get('ME'[(cpto1-1)*a*b+ki]);Set('MEX'[ki]=x);od;end;yyelo:=proc(i,a,b) uses Maplets:-Tools;g:=parse(Get('GC'));if not(member(g[i],[seq(ki,ki=1..a*b*b*a)])) then Set(l[i]('background')=LightYellow);fi;end;bet0:=proc(a,b);x:=Maplets:-Tools:-Get('cptk');if not(member(x,map(i-&gt;convert(i,string),[seq(ki,ki=1..a*b),e,r]))) then a*b else parse(x);fi;end;bet1:=proc(a,b);x:=Maplets:-Tools:-Get('cptk');if not(member(x,map(i-&gt;convert(i,string),[seq(ki,ki=1..a*b)]))) then a*b else parse(x);fi;end;colr:=`if`(esp=0,col,black);PNN:=[seq(convert(cat(seq(Y,k=1..i)),name),i=1..(a*b)^2)];PN:=[seq(convert(cat(seq(L,k=1..i)),name),i=1..(a*b)^2)];depl2:=proc(j) uses Maplets:-Tools;Set(cptk('value')=&quot;&quot;);seq(seq(Set(lll[a*b*(i1-1)+j1]('background')=alter(a,b,(zone(a,b,i1,j1)))),i1=1..a*b),j1=1..a*b);Set(cpto('value')=j);Set(lll[parse(Get(cpto))]('background')=pink);end;depl:=proc(j) uses Maplets:-Tools;d:=[-a*b,a*b,-1,1];Set(cptk('value')=&quot;&quot;);if member(parse(Get(cpto))+d[j],[seq(i,i=1..a*b*b*a)]) then seq(seq(Set(lll[a*b*(i1-1)+j1]('background')=alter(a,b,(zone(a,b,i1,j1)))),i1=1..a*b),j1=1..a*b);seq(seq(Set(l[a*b*(i1-1)+j1]('background')=LightYellow),i1=1..a*b),j1=1..a*b);Set(cpto('value')=parse(Get(cpto))+d[j]);Set(lll[parse(Get(cpto))]('background')=pink);Set(l[parse(Get(cpto))]('background')=LightBlue);fi;end;soso:=proc(ito,sre) uses Maplets:-Tools;if member(ito,sre) then Set('oso'('value')=&quot;deja resolu&quot;);else Set('oso'('value')=&quot;non resolu&quot;);fi;end;soso2:=proc(ito,sre) uses Maplets:-Tools;if member(ito,sre) then Set('oso2'('value')=&quot;deja resolu&quot;);else Set('oso2'('value')=&quot;non resolu&quot;);fi;end;retaZ:=proc();surxl:=proc(i) uses Maplets:-Tools;if ((((i-(i mod b))/b)+mkd(i mod b)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(seq(`if`((Get(lll[(i-1)*a*b+k]('value')))=&quot;&quot;,Action(Set(RA[(i-1)*a*b+k]('foreground')=colp[(io mod 2)+1]),Set(RA[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]),Set(lll[(i-1)*a*b+k]('foreground')=colp[(io mod 2)+1]),Set(lll[(i-1)*a*b+k]('background')=colp[(io mod 2)+1])),Action(Set(lll[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]),Set(RA[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]))),k=1+(io-1)*a..io*a),io=1..b);end;for k from 1 to a*b*b*a do surxl(((k-modx(k,a*b))/(a*b))+1);od;end;mkd:=x-&gt;if x=0 then 0 else 1;fi;retalZ:=proc() uses Maplets:-Tools;e:=1;i:=parse(Get('cpto'));i:=((i-modx(i,a*b))/(a*b))+1;if e=1 then if ((((i-(i mod b))/b)+mkd(i mod b)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(seq(`if`((Get(lll[(i-1)*a*b+k]('value')))=&quot;&quot;,Action(Set(lll[(i-1)*a*b+k]('foreground')=colp[(io mod 2)+1]),Set(lll[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]),Set(RA[(i-1)*a*b+k]('foreground')=colp[(io mod 2)+1]),Set(RA[(i-1)*a*b+k]('background')=colp[(io mod 2)+1])),Action(Set(RA[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]),Set(lll[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]))),k=1+(io-1)*a..io*a),io=1..b);fi;end;retacZ:=proc() uses Maplets:-Tools;e:=1;j:=parse(Get('cpto'));j:=modx(j,a*b);if e=1 then if ((((j-(j mod a))/a)+mkd(j mod a)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(seq(`if`((Get(lll[(k-1)*a*b+j]('value')))=&quot;&quot;,Action(Set(RA[(k-1)*a*b+j]('foreground')=colp[(io mod 2)+1]),Set(RA[(k-1)*a*b+j]('background')=colp[(io mod 2)+1]),Set(lll[(k-1)*a*b+j]('foreground')=colp[(io mod 2)+1]),Set(lll[(k-1)*a*b+j]('background')=colp[(io mod 2)+1])),Action(Set(RA[(k-1)*a*b+j]('background')=colp[(io mod 2)+1]),Set(lll[(k-1)*a*b+j]('background')=colp[(io mod 2)+1]))),k=1+(io-1)*b..io*b),io=1..a);fi;end;surllZ:=proc() uses Maplets:-Tools;e:=1;i:=parse(Get('cpto'));i:=((i-modx(i,a*b))/(a*b))+1;if e=1 then if ((((i-(i mod b))/b)+mkd(i mod b)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(`if`((Get(lll[(i-1)*a*b+j]('value')))=&quot;&quot;,Action(Set(RA[(i-1)*a*b+j]('foreground')=Yellow),Set(RA[(i-1)*a*b+j]('background')=Yellow),Set(lll[(i-1)*a*b+j]('foreground')=Yellow),Set(lll[(i-1)*a*b+j]('background')=Yellow)),Action(Set(RA[(i-1)*a*b+j]('background')=Yellow),Set(lll[(i-1)*a*b+j]('background')=Yellow))),j=1..a*b);fi;end;surlcZ:=proc() uses Maplets:-Tools;e:=1;j:=parse(Get('cpto'));j:=modx(j,a*b);if e=1 then if ((((j-(j mod a))/a)+mkd(j mod a)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(`if`((Get(lll[(i-1)*a*b+j]('value')))=&quot;&quot;,Action(Set(RA[(i-1)*a*b+j]('foreground')=Yellow),Set(RA[(i-1)*a*b+j]('background')=Yellow),Set(lll[(i-1)*a*b+j]('foreground')=Yellow),Set(lll[(i-1)*a*b+j]('background')=Yellow)),Action(Set(RA[(i-1)*a*b+j]('background')=Yellow),Set(lll[(i-1)*a*b+j]('background')=Yellow))),i=1..a*b);fi;end;reta:=proc();surxl:=proc(i) uses Maplets:-Tools;if ((((i-(i mod b))/b)+mkd(i mod b)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(seq(`if`(parse(Get(RA[(i-1)*a*b+k]('caption')))=parse(rpx(a,b,0)),Action(Set(RA[(i-1)*a*b+k]('foreground')=colp[(io mod 2)+1]),Set(RA[(i-1)*a*b+k]('background')=colp[(io mod 2)+1])),Set(RA[(i-1)*a*b+k]('background')=colp[(io mod 2)+1])),k=1+(io-1)*a..io*a),io=1..b);end;for k from 1 to a*b*b*a do surxl(((k-modx(k,a*b))/(a*b))+1);od;end;mkd:=x-&gt;if x=0 then 0 else 1;fi;retal:=proc(i0) uses Maplets:-Tools;e:=1;i:=((i0-modx(i0,a*b))/(a*b))+1;if e=1 then if ((((i-(i mod b))/b)+mkd(i mod b)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(seq(`if`(parse(Get(RA[(i-1)*a*b+k]('caption')))=parse(rpx(a,b,0)),Action(Set(RA[(i-1)*a*b+k]('foreground')=colp[(io mod 2)+1]),Set(lll[(i-1)*a*b+k]('foreground')=colp[(io mod 2)+1]),Set(lll[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]),Set(RA[(i-1)*a*b+k]('background')=colp[(io mod 2)+1])),Action(Set(lll[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]),Set(RA[(i-1)*a*b+k]('background')=colp[(io mod 2)+1]))),k=1+(io-1)*a..io*a),io=1..b);fi;end;retac:=proc(j0) uses Maplets:-Tools;e:=1;j:=modx(j0,a*b);if e=1 then if ((((j-(j mod a))/a)+mkd(j mod a)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(seq(`if`(parse(Get(RA[(k-1)*a*b+j]('caption')))=parse(rpx(a,b,0)),Action(Set(RA[(k-1)*a*b+j]('foreground')=colp[(io mod 2)+1]),Set(lll[(k-1)*a*b+j]('foreground')=colp[(io mod 2)+1]),Set(RA[(k-1)*a*b+j]('background')=colp[(io mod 2)+1]),Set(lll[(k-1)*a*b+j]('background')=colp[(io mod 2)+1])),Action(Set(lll[(k-1)*a*b+j]('background')=colp[(io mod 2)+1]),Set(RA[(k-1)*a*b+j]('background')=colp[(io mod 2)+1]))),k=1+(io-1)*b..io*b),io=1..a);fi;end;surll:=proc(i0) uses Maplets:-Tools;e:=1;i:=((i0-modx(i0,a*b))/(a*b))+1;if e=1 then if ((((i-(i mod b))/b)+mkd(i mod b)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(`if`(parse(Get(RA[(i-1)*a*b+j]('caption')))=parse(rpx(a,b,0)),Action(Set(RA[(i-1)*a*b+j]('foreground')=Yellow),Set(lll[(i-1)*a*b+j]('foreground')=Yellow),Set(RA[(i-1)*a*b+j]('background')=Yellow),Set(lll[(i-1)*a*b+j]('background')=Yellow)),Action(Set(RA[(i-1)*a*b+j]('background')=Yellow),Set(lll[(i-1)*a*b+j]('background')=Yellow))),j=1..a*b);fi;end;surlc:=proc(j0) uses Maplets:-Tools;e:=1;j:=modx(j0,a*b);if e=1 then if ((((j-(j mod a))/a)+mkd(j mod a)) mod 2)=1 then colp:=[cor1,cor2];else colp:=[cor2,cor1];fi;seq(`if`(parse(Get(RA[(i-1)*a*b+j]('caption')))=parse(rpx(a,b,0)),Action(Set(RA[(i-1)*a*b+j]('foreground')=Yellow),Set(lll[(i-1)*a*b+j]('foreground')=Yellow),Set(RA[(i-1)*a*b+j]('background')=Yellow),Set(lll[(i-1)*a*b+j]('background')=Yellow)),Action(Set(RA[(i-1)*a*b+j]('background')=Yellow),Set(lll[(i-1)*a*b+j]('background')=Yellow))),i=1..a*b);fi;end;testj2 := proc (a,b) local d, e, i, j, ki, aa, incl, soe, ex; incl := proc (l, d) local em, i; em := 0; for i to nops(l) do if not member(l[i],d) then em := 1; break end if end do; return em end proc; soe := (d,a,b) -&gt; if incl(convert(`minus`({op(d)},{&quot;&quot;}),list),map(io -&gt; convert(io,string),[seq(ki,ki = 1 .. a*b)])) = 1 or nops(map(x -&gt; `if`(x =&quot;&quot;,NULL,x),d)) &lt;&gt; nops(`minus`({op(d)},{&quot;&quot;})) then 1 else 0 end if;d := [seq(seq([1+(i-1)*b, 1+(j-1)*a], j = 1 .. b), i = 1 .. a)];e := 0; for i to a*b do if soe([seq(Maplets:-Tools:-Get(llll[a*b*i-a*b+j]('value')),j = 1 .. a*b)],a,b) = 1 then e := 1; break end if end do; if e = 0 then for j to a*b do if soe([seq(Maplets:-Tools:-Get(llll[a*b*i-a*b+j]('value')),i = 1 .. a*b)],a,b) = 1 then e := 1; break end if end do end if; if e = 0 then for ki to nops(d) do if soe([seq(seq(Maplets:-Tools:-Get(llll[a*b*i-a*b+j]('value')),j = d[ki][2] .. d[ki][2]+a-1),i = d[ki][1] .. d[ki][1]+b-1)],a,b) = 1 then e := 1; break end if end do end if; ex := 0; for i to a*b do if member(&quot;&quot;,[seq(Maplets:-Tools:-Get(llll[a*b*i-a*b+j]('value')),j = 1 .. a*b)]) then ex := 1; break end if end do; if ex = 0 then for j to a*b do if member(&quot;&quot;,[seq(Maplets:-Tools:-Get(llll[a*b*i-a*b+j]('value')),i = 1 .. a*b)]) then ex := 1; break end if end do end if; if ex = 0 then for ki to nops(d) do if member(&quot;&quot;,[seq(seq(Maplets:-Tools:-Get(llll[a*b*i-a*b+j]('value')),j = d[ki][2] .. d[ki][2]+a-1),i = d[ki][1] .. d[ki][1]+b-1)]) then ex := 1; break end if end do end if;if e = 0 then if ex = 0 then Maplets:-Tools:-Set(J2('value') = &quot;juste&quot;);Maplets:-Tools:-Set(oso('value') = &quot;&quot;);Maplets:-Tools:-Set(oso2('value') = &quot;&quot;);Maplets:-Tools:-Set(sre('value')=convert({op(parse(Maplets:-Tools:-Get('sre'))),parse(Maplets:-Tools:-Get('ito2'))},list));elif ex = 1 then Maplets:-Tools:-Set(J2('value') = &quot;pas_totalement_rempli&quot;) end if elif e = 1 then Maplets:-Tools:-Set(J2('value') = &quot;faux&quot;) end if end proc;rpx := (a, b, i) -&gt; (cat(seq(&quot;0&quot;,k = 1 .. nops(convert(a*b,base,10))-nops(convert(i,base,10))),convert(i,string)));yel:=proc(i) uses Maplets:-Tools;px:=parse(Get('p'));if px=0 then for ki from 1 to nops(l) do if ki=i then Set(l[ki]('background')=LightBlue);else Set(l[ki]('background')=LightYellow);fi;od;elif px=1 then for ki from 1 to nops(l) do if ki=i then Set(l[ki]('background')=LightBlue);else Set(l[ki]('background')=LightYellow);fi;od;fi;end;inscand:=proc(a,b) uses Maplets:-Tools;g:=proc(x);R:=op([]);if x&lt;&gt;&quot;error&quot; then if member(x,[seq(io,io=1..9)]) then R:=cat(x) elif x&gt;=10 then R:=cat(&quot; &quot;,x);fi;fi;return(R);end;f:=(x,j)-&gt;if x=true then j;else &quot;error&quot;;fi;i:=parse(Get('cpto'));sc:=convert(cat(op(map(g,[seq(f((Get('MEX'[j])),j),j=1..a*b)]))),string);cpto1:=parse(Get('cpto'));gt:=parse(Get('GC'));if not(member(gt[i],[seq(ki,ki=1..a*b*b*a)])) then Set(lll[i]('foreground')=Black);Set(lll[i]('value')=sc);for ki from 1 to a*b do x:=Get('MEX'[ki]);Set('ME'[(cpto1-1)*a*b+ki]=x);od;fi;end;testj := proc (a,b) local d, e, i, j, ki, aa, incl, soe, ex; incl := proc (l, d) local em, i; em := 0; for i to nops(l) do if not member(l[i],d) then em := 1; break end if end do; return em end proc; soe := (d,a,b) -&gt; if incl(convert(`minus`({op(d)},{rpx(a,b,0)}),list),map(io -&gt; rpx(a,b,io),[seq(ki,ki = 1 .. a*b)])) = 1 or nops(map(x -&gt; `if`(x =rpx(a,b,0),NULL,x),d)) &lt;&gt; nops(`minus`({op(d)},{rpx(a,b,0)})) then 1 else 0 end if;d := [seq(seq([1+(i-1)*b, 1+(j-1)*a], j = 1 .. b), i = 1 .. a)];e := 0; for i to a*b do if soe([seq(Maplets:-Tools:-Get(RA[a*b*i-a*b+j]('caption')),j = 1 .. a*b)],a,b) = 1 then e := 1; break end if end do; if e = 0 then for j to a*b do if soe([seq(Maplets:-Tools:-Get(RA[a*b*i-a*b+j]('caption')),i = 1 .. a*b)],a,b) = 1 then e := 1; break end if end do end if; if e = 0 then for ki to nops(d) do if soe([seq(seq(Maplets:-Tools:-Get(RA[a*b*i-a*b+j]('caption')),j = d[ki][2] .. d[ki][2]+a-1),i = d[ki][1] .. d[ki][1]+b-1)],a,b) = 1 then e := 1; break end if end do end if; ex := 0; for i to a*b do if member(rpx(a,b,0),[seq(Maplets:-Tools:-Get(RA[a*b*i-a*b+j]('caption')),j = 1 .. a*b)]) then ex := 1; break end if end do; if ex = 0 then for j to a*b do if member(rpx(a,b,0),[seq(Maplets:-Tools:-Get(RA[a*b*i-a*b+j]('caption')),i = 1 .. a*b)]) then ex := 1; break end if end do end if; if ex = 0 then for ki to nops(d) do if member(rpx(a,b,0),[seq(seq(Maplets:-Tools:-Get(RA[a*b*i-a*b+j]('caption')),j = d[ki][2] .. d[ki][2]+a-1),i = d[ki][1] .. d[ki][1]+b-1)]) then ex := 1; break end if end do end if; aa := parse(Maplets:-Tools:-Get('p')); if aa = 0 then Maplets:-Tools:-Set(J('value') = &quot;&quot;) elif aa = 1 then if e = 0 then if ex = 0 then Maplets:-Tools:-Set(J('value') = &quot;juste&quot;);Maplets:-Tools:-Set(oso('value') = &quot;&quot;);Maplets:-Tools:-Set(oso2('value') = &quot;&quot;);Maplets:-Tools:-Set(sre('value')=convert({op(parse(Maplets:-Tools:-Get('sre'))),parse(Maplets:-Tools:-Get('Num'))},list));elif ex = 1 then Maplets:-Tools:-Set(J('value') = &quot;pas_totalement_rempli&quot;) end if elif e = 1 then Maplets:-Tools:-Set(J('value') = &quot;faux&quot;) end if end if end proc;coo:=(i,a,b)-&gt;if i mod (a*b)=0 then [i/(a*b),a*b];else [((i-(i mod a*b))/(a*b))+1,(i mod (a*b))] fi;PM:=[seq(convert(cat(seq(H,k=1..i)),name),i=1..(a*b)^2)];llll:=[seq(convert(cat(seq(U,k=1..i)),name),i=1..(a*b)^2)];;RA:=[seq(convert(cat(seq(T,k=1..i)),name),i=1..(a*b)^2)];police:=cat(seq(op([police1[ki],&quot; &quot;]),ki=1..nops(police1)-1),police1[nops(police1)]);colo:=colo2-&gt;if colo2=blue then DarkRed else blue fi;ex:=0;maplet3:=Maplet(Window('title'=&quot;Warning&quot;,[[Label(&quot;les nombres ins\303\251r\303\251s doivent etre des entiers positifs non nuls&quot;)]]));if (frac(a)&lt;&gt;0 or frac(b)&lt;&gt;0 or a&lt;=0 or b&lt;=0) then ex:=1;Maplets[Display](maplet3);fi;if ex=0 then colo3:=x-&gt;if x=black then red else black fi;rp := (a, b, i) -&gt; convert(i,string);recop:=proc() uses Maplets:-Tools;pg:=parse(Get('p'));if pg=0 then for i from 1 to nops(RA) do x:=Get(RA[i]('caption'));if not(member(x,[seq(rpx(a,b,k),k=1..a*b)])) then Set(lll[i]('value')=&quot;&quot;);Set(lll[i]('foreground')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b)))));Set(lll[i]('background')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b)))));elif member(x,[seq(rpx(a,b,k),k=1..a*b)]) then Set(lll[i]('value')=x);Set(lll[i]('foreground')=blue);fi;od;else for i from 1 to nops(l) do x:=Get(RA[i]('caption'));if not(member(x,[seq(rpx(a,b,k),k=1..a*b)])) then Set(lll[i]('value')=&quot;&quot;);Set(lll[i]('foreground')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b)))));Set(lll[i]('background')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b)))));elif member(x,[seq(rpx(a,b,k),k=1..a*b)]) then Set(lll[i]('value')=x);gc:=parse(Get('GC'));if gc[i]=`` then Set(lll[i]('foreground')=blue);else Set(lll[i]('foreground')=DarkRed);Set(lll[i]('editable')=false);fi;fi;od;fi;end;ini:=proc(a,b) uses Maplets:-Tools;pg:=parse(Get('p'));if pg=1 then i:=parse(Get('cpto'));gc:=parse(Get('GC'));if gc[i]=`` then Set(l[i]('value')=&quot;&quot;);Set(RA[i]('value')=false);Set(RA[i]('caption')=rpx(a,b,0));Set(RA[i]('foreground')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b)))));Set(RA[i]('background')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b)))));Set(lll[i]('value')=&quot;&quot;);fi;else i:=parse(Get('cpto'));Set(l[i]('value')=&quot;&quot;);Set(RA[i]('value')=false);Set(RA[i]('caption')=rpx(a,b,0));Set(RA[i]('foreground')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b)))));Set(RA[i]('background')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b)))));Set(lll[i]('value')=&quot;&quot;);fi;end;insxt:=proc(a,b) uses Maplets:-Tools;pg:=parse(Get('p'));if pg=1 then i:=parse(Get('cpto'));gc:=parse(Get('GC'));if gc[i]=`` then Set(RA[i]('value')=false);Set(RA[i]('foreground')=blue);Set(RA[i]('caption')=rpx(a,b,parse(Get(ll[i]))));Set(l[i]('value')=rp(a,b,parse(Get(ll[i]))));Set(lll[i]('value')=rpx(a,b,parse(Get(ll[i]))));Set(lll[i]('foreground')=blue);fi;fi;end;insx:=proc(a,b,k) uses Maplets:-Tools;pg:=parse(Get('p'));if member(k,[seq(io,io=1..a*b),e,r]) then if pg=1 then i:=parse(Get('cpto'));gc:=parse(Get('GC'));if gc[i]=`` then if (k&lt;&gt;e and k&lt;&gt;r) then Set(RA[i]('value')=false);Set(RA[i]('foreground')=blue);Set(RA[i]('caption')=rpx(a,b,k));Set(l[i]('value')=rp(a,b,k));Set(lll[i]('value')=rpx(a,b,k));Set(lll[i]('foreground')=blue);elif k=e then effmex(a,b);ini(a,b);elif k=r then insxt(a,b);fi;fi;else i:=parse(Get('cpto'));if (k&lt;&gt;e and k&lt;&gt;r) then Set(RA[i]('value')=false);Set(RA[i]('foreground')=blue);Set(RA[i]('caption')=rpx(a,b,k));Set(l[i]('value')=rp(a,b,k));Set(lll[i]('value')=rpx(a,b,k));Set(lll[i]('foreground')=blue);elif k=e then effmex(a,b);ini(a,b);elif k=r then insxt(a,b);fi;fi;else Maplets:-Tools:-Set(cptk('value')=a*b);fi;end;alter:=proc(a,b,l);i:=l[1];j:=l[2];d := [seq(seq([1+(io-1)*b, 1+(jo-1)*a], jo = 1 .. b), io = 1 .. a)];zt:=[(i mod 2),(j mod 2)];if member(zt,[[1,0],[0,1]]) then c:=cor1; else c:=cor2;fi;return(c);end;inat := proc (a,b) local gx; gx := parse(Maplets:-Tools:-Get('G')); Action(Maplets:-Tools:-Set(ito('editable') = true),Maplets:-Tools:-Set(ito2('editable') = true),Maplets:-Tools:-Set(ito('value') = &quot;&quot;),Maplets:-Tools:-Set(ito2('value') = &quot;&quot;),Maplets:-Tools:-Set(ito('itemlist') = map(x -&gt; convert(x,string),[seq(i,i = 1 .. gx[nops(gx)])])),Maplets:-Tools:-Set(ito2('itemlist') = map(x -&gt; convert(x,string),[seq(i,i = 1 .. gx[nops(gx)])])),Maplets:-Tools:-Set(ito('editable') = false),Maplets:-Tools:-Set(ito2('editable') = false)) end proc;ins := proc (i, x);if x&lt;&gt;0 then g:=parse(Maplets:-Tools:-Get('GC'));ax:=parse(Maplets:-Tools:-Get('p'));if ax=0 then Maplets:-Tools:-Set(l[i]('value') =x);Maplets:-Tools:-Set(RA[i]('caption') = rpx(a,b,x));Maplets:-Tools:-Set(lll[i]('value') = rpx(a,b,x));elif g[i]=`` then Maplets:-Tools:-Set(l[i]('value') = x);Maplets:-Tools:-Set(RA[i]('caption') = rpx(a,b,x));Maplets:-Tools:-Set(lll[i]('value') = rpx(a,b,x));fi;else g:=parse(Maplets:-Tools:-Get('GC'));ax:=parse(Maplets:-Tools:-Get('p'));if ax=0 then Maplets:-Tools:-Set(l[i]('value') = &quot;&quot;);Maplets:-Tools:-Set(RA[i]('caption') = rpx(a,b,0));Maplets:-Tools:-Set(lll[i]('value') = &quot;&quot;);elif g[i]=`` then Maplets:-Tools:-Set(l[i]('value') = &quot;&quot;);Maplets:-Tools:-Set(RA[i]('caption') = rpx(a,b,0));Maplets:-Tools:-Set(lll[i]('value') = &quot;&quot;);fi;fi; end proc;l:=[seq(convert(i,name),i=1..a*b*b*a)];ll:=[seq(convert(cat(seq(A,k=1..i)),name),i=1..a*b*b*a)];lll:=[seq(convert(cat(seq(B,k=1..i)),name),i=1..a*b*b*a)];enregistrer:=proc() uses Maplets:-Tools;trx:= i-&gt;if i=`` then cat(seq(&quot;~&quot;,k = 1 .. nops(convert(a*b,base,10))));else cat(seq(&quot;0&quot;,k = 1 .. nops(convert(a*b,base,10))-nops(convert(i,base,10))),convert(i,string));fi;g:=parse(Get('G'));nbo:=cat(convert(g[nops(g)],name),`_`,convert(g[nops(g)-1],name),`_`,convert(g[nops(g)-2],name));sudx:=cat(currentdir(),&quot;\134sudoku&quot;,nbo,&quot;.txt&quot;);g:=parse(Get('G'));cf:=fopen(sudx,WRITE,TEXT);for ik from 1 to g[nops(g)] do lx:=[seq(g[(a*b*b*a+1)*(ik-1)+kx],kx=1..a*b*b*a)];for io from 1 to a do for i from 1+b*(io-1) to b*io do for jo from 1 to b do for j from 1+a*(jo-1) to a*jo do fprintf(cf,&quot;%s&quot;,trx(lx[a*b*(i-1)+j]));fprintf(cf,&quot; &quot;);od;fprintf(cf,&quot;%s&quot;,&quot;  &quot;);od;fprintf(cf,&quot;\134n&quot;);od;fprintf(cf,&quot;\134n&quot;);od;fprintf(cf,&quot;-----------------\134n&quot;);od;fclose(cf);Set('info'(value)=sudx);end;XK:=[seq(convert(cat(seq(P,k=1..i)),name),i=1..a*b*b*a)];ffo := proc (a0,a,b) local s; s := op([]); if a0 = 0 then s := sudo([seq([seq(cont(Maplets:-Tools:-Get(RA[k]('caption'))),k = 1+a*b*(i-1) .. a*b*i)],i = 1 .. a*b)],a,b);seq(Maplets:-Tools:-Set(ll[i] = s[i]),i = 1 .. nops(ll)) elif a0 = 1 then seq(Maplets:-Tools:-Set(ll[i] = &quot;&quot;),i = 1 .. nops(ll)), Maplets:-Tools:-Set(('S') = &quot;&quot;) end if; return s end proc;trap:=l-&gt;cat(op(map(x-&gt;`if`(x=``,0,x),l)));presenta2 := (l, a, b) -&gt; [seq([seq(l[j],j = 1+(i-1)*b*a .. i*b*a)],i = 1 .. nops(l)/b/a)];plotage := proc (l,a,b,n,color1,color2,plsp,colnb) local za, A1, ki, kj, B; za := presenta2(l,a,b); A1 := []; for ki to nops(za) do for kj to nops(za[ki]) do if za[ki][kj] &lt;&gt; `` then A1 := [op(A1), [kj, nops(za)-ki+1, za[ki][kj],'font'=[op(plsp),BOLD,26]]] end if end do end do; B := plots:-display({plots:-polygonplot([seq(seq(`if`(member([(i mod 2),(j mod 2)],[[1,1],[0,0]]),[[0.5+a*(i-1),0.5+b*(j-1)],[0.5+a*i,0.5+b*(j-1)],[0.5+a*i,0.5+b*j],[0.5+a*(i-1),0.5+b*j],[0.5+a*(i-1),0.5+b*(j-1)]],NULL),i=1..b),j=1..a)],color=convert(color1,string),style=polygon),plots:-polygonplot([seq(seq(`if`(member([(i mod 2),(j mod 2)],[[1,0],[0,1]]),[[0.5+a*(i-1),0.5+b*(j-1)],[0.5+a*i,0.5+b*(j-1)],[0.5+a*i,0.5+b*j],[0.5+a*(i-1),0.5+b*j],[0.5+a*(i-1),0.5+b*(j-1)]],NULL),i=1..b),j=1..a)],color=convert(color2,string),style=polygon),plots:-polygonplot([[[.5, .5], [.5, b*a+.5]]],thickness=10),plots:-polygonplot([[[.5+a*b, .5], [.5+a*b, b*a+.5]]],thickness=10),plots:-polygonplot([seq([[.5+a*t, .5], [.5+a*t, b*a+.5]],t = 1 .. b-1)],thickness=5),plots:-polygonplot([[[.5, .5], [b*a+.5, .5]]],thickness=10),plots:-polygonplot([[[.5, .5+b*a], [b*a+.5, .5+b*a]]],thickness=10),plots:-polygonplot([seq([[.5, .5+b*t], [b*a+.5, .5+b*t]],t = 1 .. a-1)],thickness=5),plots:-polygonplot([seq(`if`(not(member(k,[seq(a*t,t=0..b)])),[[.5+k, .5], [.5+k, b*a+.5]],NULL),k = 0 .. b*a),seq(`if`(not(member(k,[seq(b*t,t=0..a)])),[[.5, .5+k], [b*a+.5, .5+k]],NULL),k = 0 .. b*a)]), plots:-textplot(A1,color = colnb)},axes = none,scaling = constrained);sfile:=FileTools:-JoinPath([convert(cat(`sudoku`,`-`,n,`.gif`),string)],base=homedir);Maplets:-Tools:-Set(loc('value')=sfile);Export(sfile,B);end proc;plotagec := proc (l,a,b,n,color1,color2) local za, A1, ki, kj, B;couleur:=x-&gt;if x=1 then &quot;Blue&quot; elif x=2 then &quot;pink&quot; elif x=3 then &quot;Chocolate&quot; elif x=4 then &quot;Green&quot; elif x=5 then &quot;Grey&quot; elif x=6 then &quot;Violet&quot; elif x=7 then &quot;Yellow&quot; elif x=8 then &quot;LightBlue&quot; elif x=9 then &quot;LightGreen&quot; elif x=10 then &quot;Magenta&quot; elif x=11 then &quot;YellowGreen&quot; elif x=12 then &quot;Cyan&quot; fi;za := presenta2(l,a,b); A1 := []; for ki to nops(za) do for kj to nops(za[ki]) do if za[ki][kj] &lt;&gt; `` then A1 := [op(A1), plots:-polygonplot([[kj-0.5, nops(za)-ki+1-0.5],[kj-0.5, nops(za)-ki+1+0.5],[kj+0.5, nops(za)-ki+1+0.5],[kj+0.5, nops(za)-ki+1-0.5],[kj-0.5, nops(za)-ki+1-0.5]],color=couleur(za[ki][kj]))] end if end do end do;Pic:=seq(plots:-polygonplot([[kk-0.5,a*b+2-0.25],[kk-0.5,a*b+2+0.25],[kk+0.5,a*b+2+0.25],[kk+0.5,a*b+2-0.25],[kk-0.5,a*b+2-0.25]],color=couleur(kk),style=polygon),kk=1..a*b);B := plots:-display({plots:-polygonplot([seq(seq(`if`(member([(i mod 2),(j mod 2)],[[1,1],[0,0]]),[[0.5+a*(i-1),0.5+b*(j-1)],[0.5+a*i,0.5+b*(j-1)],[0.5+a*i,0.5+b*j],[0.5+a*(i-1),0.5+b*j],[0.5+a*(i-1),0.5+b*(j-1)]],NULL),i=1..b),j=1..a)],color=convert(color1,string),style=polygon),plots:-polygonplot([seq(seq(`if`(member([(i mod 2),(j mod 2)],[[1,0],[0,1]]),[[0.5+a*(i-1),0.5+b*(j-1)],[0.5+a*i,0.5+b*(j-1)],[0.5+a*i,0.5+b*j],[0.5+a*(i-1),0.5+b*j],[0.5+a*(i-1),0.5+b*(j-1)]],NULL),i=1..b),j=1..a)],color=convert(color2,string),style=polygon),plots:-polygonplot([[[.5, .5], [.5, b*a+.5]]],thickness=10),plots:-polygonplot([[[.5+a*b, .5], [.5+a*b, b*a+.5]]],thickness=10),plots:-polygonplot([seq([[.5+a*t, .5], [.5+a*t, b*a+.5]],t = 1 .. b-1)],thickness=5),plots:-polygonplot([[[.5, .5], [b*a+.5, .5]]],thickness=10),plots:-polygonplot([[[.5, .5+b*a], [b*a+.5, .5+b*a]]],thickness=10),plots:-polygonplot([seq([[.5, .5+b*t], [b*a+.5, .5+b*t]],t = 1 .. a-1)],thickness=5),plots:-polygonplot([seq(`if`(not(member(k,[seq(a*t,t=0..b)])),[[.5+k, .5], [.5+k, b*a+.5]],NULL),k = 0 .. b*a),seq(`if`(not(member(k,[seq(b*t,t=0..a)])),[[.5, .5+k], [b*a+.5, .5+k]],NULL),k = 0 .. b*a)]),op(A1),Pic},axes = none,scaling = constrained);sfile:=FileTools:-JoinPath([convert(cat(`sudoku`,`-`,n,`.gif`),string)],base=homedir);Maplets:-Tools:-Set(loc('value')=sfile);Export(sfile,B);end proc;plotagemulti:=proc(a,b,color1,color2,x,plsp,colnb);nbo:=nops((Maplets:-Tools:-Get(ito2('itemlist'))));Gb:=parse(Maplets:-Tools:-Get('G'));if x=non then for k from 1 to nbo do plotage([seq(Gb[(k-1)+a*b*b*a*(k-1)+j],j=1..a*b*b*a)],a,b,k,color1,color2,plsp,colnb);od;elif (x=oui and a*b &lt;=12) then for k from 1 to nbo do plotagec([seq(Gb[(k-1)+a*b*b*a*(k-1)+j],j=1..a*b*b*a)],a,b,k,white,white);od;fi;end;inat := proc () local gx; gx := parse(Maplets:-Tools:-Get('G')); Action(Maplets:-Tools:-Set(ito('editable') = true),Maplets:-Tools:-Set(ito2('editable') = true),Maplets:-Tools:-Set(ito('value') = &quot;&quot;),Maplets:-Tools:-Set(ito2('value') = &quot;&quot;),Maplets:-Tools:-Set(ito('itemlist') = map(x -&gt; convert(x,string),[seq(i,i = 1 .. gx[nops(gx)])])),Maplets:-Tools:-Set(ito2('itemlist') = map(x -&gt; convert(x,string),[seq(i,i = 1 .. gx[nops(gx)])])),Maplets:-Tools:-Set(ito('editable') = false),Maplets:-Tools:-Set(ito2('editable') = false)) end proc;
ino := proc () Action(Maplets:-Tools:-Set(ito('editable') = true),Maplets:-Tools:-Set(ito2('editable') = true),Maplets:-Tools:-Set(ito('itemlist') = [&quot;&quot;]),Maplets:-Tools:-Set(ito2('itemlist') = [&quot;&quot;]),Maplets:-Tools:-Set(ito('value') = &quot;&quot;),Maplets:-Tools:-Set(ito2('value') = &quot;&quot;),Maplets:-Tools:-Set(ito('editable') = false),Maplets:-Tools:-Set(ito2('editable') = false)) end proc;fff:=proc() uses Maplets:-Tools;Action(seq(Set(l[i]('value')=&quot;&quot;),i=1..nops(l)),seq(Set(llll[i]('value')=&quot;&quot;),i=1..nops(llll)),seq(Set(l[i]('editable')=false),i=1..nops(l)),seq(Set(RA[i]('caption')=rpx(a,b,0)),i=1..nops(l)),seq(seq(Set(RA[a*b*(i-1)+j]('foreground')=alter(a,b,(zone(a,b,i,j)))),i=1..a*b),j=1..a*b),seq(seq(Set(RA[a*b*(i-1)+j]('background')=alter(a,b,(zone(a,b,i,j)))),i=1..a*b),j=1..a*b),seq(seq(Set(lll[a*b*(i-1)+j]('background')=alter(a,b,(zone(a,b,i,j)))),i=1..a*b),j=1..a*b),seq(Set(RA[i]('enabled')=true),i=1..nops(l)),seq(Set(RA[i]('value')=false),i=1..nops(l)),seq(Set(l[i]('background')=LightYellow),i=1..nops(l)),seq(Set(ll[i]('value')=&quot;&quot;),i=1..nops(ll)));Set(lll[parse(Get('cpto'))]('background')=pink);end;fffsel:=proc() uses Maplets:-Tools;Action(seq(seq(Set(lll[a*b*(i-1)+j]('background')=alter(a,b,(zone(a,b,i,j)))),i=1..a*b),j=1..a*b));end;ff:=proc() uses Maplets:-Tools;g:=parse(Get('GC'));for i from 1 to nops(l) do if g[i]=`` then Action(Set(RA[i]('enabled')=true),Set(lll[i]('editable')=false),Set(RA[i]('caption')=rpx(a,b,0)),SetOption(RA[i]('foreground')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b))))),SetOption(RA[i]('background')=alter(a,b,(zone(a,b,((i-modx(i,a*b))/(a*b))+1,modx(i,a*b))))),Set(RA[i]('value')=false),Set(l[i]('editable')=true),Set(l[i]('editable')=false),Set(l[i]('background')=LightYellow),Set(l[i]('foreground')=blue),Set(l[i]('value')=&quot;&quot;),Set(llll[i]('value')=&quot;&quot;),Set(llll[i]('editable')=false));else Action(Set(RA[i]('enabled')=false),Set(lll[i]('editable')=false),Set(RA[i]('value')=false),Set(RA[i]('foreground')=DarkRed),Set(RA[i]('caption')=rpx(a,b,g[i])),Set(llll[i]('value')=g[i]),Set(llll[i]('editable')=false),Set(l[i]('foreground')=DarkRed),Set(l[i]('editable')=false),Set(l[i]('editable')=false),Set(l[i]('value')=rp(a,b,g[i])));fi;od;end;ffp:=proc() uses Maplets:-Tools;g:=parse(Get('GCp'));for i from 1 to nops(l) do if g[i]=`` then Action(Set(llll[i]('value')=&quot;&quot;),Set(llll[i]('editable')=true),Set(llll[i]('foreground')=DarkRed));else Action(Set(llll[i]('value')=g[i]),Set(llll[i]('editable')=false),Set(llll[i]('foreground')=black));fi;od;end;maplet:= Maplet( 'onstartup'=RunWindow('TK'),Window['W1']( 'title'=convert(cat(a,&quot;x&quot;,b,&quot;-sudoku&quot;),string),layout=BorderLayout(GridCell2(BorderLayout(background=LightYellow,GridCell2(GridLayout(GridRow(GridCell(BorderLayout(GridCell2(GridLayout(GridRow(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(CheckBox[RA[a*b*(kj-1)+ki]]('caption'=rpx(a,b,0),font=Font(&quot;Null&quot;,pog),background=alter(a,b,[j,1]),foreground=alter(a,b,[j,1]),'onchange'=Action(Evaluate('function'='yel'(a*b*(kj-1)+ki)))))),background=alter(a,b,[j,1]),inset=2,border=true))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(j-1)..b*j),inset=1,background=colx))),inset=1,background=colr)),seq(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(CheckBox[RA[a*b*(kj-1)+ki]]('caption'=rpx(a,b,0),font=Font(&quot;Null&quot;,pog),background=alter(a,b,[j,i]),foreground=alter(a,b,[j,i]),'onchange'=Action(Evaluate('function'='yel'(a*b*(kj-1)+ki)))))),inset=2,border=true,background=alter(a,b,[j,i])))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(j-1)..b*j),inset=1,background=colx))),inset=1,background=colr)),i=2..b)])),j=1..a-1),GridRow(op([GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(CheckBox[RA[a*b*(kj-1)+ki]]('caption'=rpx(a,b,0),font=Font(&quot;Null&quot;,pog),background=alter(a,b,[a,1]),foreground=alter(a,b,[a,1]),'onchange'=Action(Evaluate('function'='yel'(a*b*(kj-1)+ki)))))),inset=2,border=true,background=alter(a,b,[a,1])))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(a-1)..b*a),inset=1,background=colx))),background=colr,inset=1)),seq(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(CheckBox[RA[a*b*(kj-1)+ki]]('caption'=rpx(a,b,0),font=Font(&quot;Null&quot;,pog),background=alter(a,b,[a,i]),foreground=alter(a,b,[a,i]),'onchange'=Action(Evaluate('function'='yel'(a*b*(kj-1)+ki)))))),inset=2,border=true,background=alter(a,b,[a,i])))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(a-1)..b*a),inset=1,background=colx))),background=colr,inset=1)),i=2..b)])),background=white,inset=esp)))))),background=col,border=false,inset=8),constraint=center),background=LightYellow))),background=LightYellow),constraint=center),background=LightYellow,inset=50),constraint=center),GridCell2(constraint=east),GridCell2(constraint=south),GridCell2(constraint=north),hgap=5,vgap=5,background=LightYellow),resizable=false),seq(Window['PM'[i]](title=&quot;&quot;,layout=BorderLayout(GridCell2(GridLayout(seq(GridRow(seq(GridCell(CheckBox['ME'[(i-1)*a*b+io]](rp(a,b,io),value=true,font=Font(police,20))),io=1+(ik-1)*a..ik*a)),ik=1..b),border=false),constraint=center),hgap=10,vgap=10,background=LightYellow),resizable=false),i=1..a*b*b*a),Window['compt']([[TextBox['cpto'](value=1,editable=false,width=2)]]),Window['help'](title=&quot;aide et \303\240 propos&quot;,[[Label(&quot;Le but du sudoku \303\240 r\303\251gions a*b est d'ins\303\251rer les chiffres de 1 \303\240 a*b dans chaque ligne,chaque colonne et chaque r\303\251gion.&quot;)],[TextBox['He'](value=&quot;pour ins\303\251rer,on peut s\303\251lectionner la ligne (boutons ronds verticaux) et la Colonne (boutons ronds horizontaux) puis le chiffre.Ou bien utiliser clique droit souris sur les cases Ou bien utiliser Tactile: s\303\251lection de la case puis choisir le chiffre ou effacer(bouton vide).Pour surligner ligne:choix ligne avec bouton rond puis '--' (annuler:le meme symbole mais ayant '/').Pour surligner colonne:choix colonne avec bouton rond puis '|' (annuler:le meme symbole mais ayant '/').On peut copier coller et sauvergarder sous le bloc note puis coller puis charger avec 'charger grilles'.On peut choisir la 'grille \303\240 pr\303\251senter' (pour capturer puis imprimer).&quot;,editable=false,3..5)],[Label(&quot;Cette Maplet a \303\251t\303\251 enti\303\250rement invent\303\251e par Xavier Cormier: Algorithme et Interface&quot;)],[Label(&quot;Auteur:Xavier Cormier (Cl\303\251ment Charles).email:x.cormier@wanadoo.fr&quot;)]]),MenuBar['MB'](Menu(caption=&quot;aide&quot;,MenuItem(&quot;Aide&quot;,RunWindow('helpx'))),Menu(caption=&quot;Jeu&quot;,MenuItem(&quot;G\303\251n\303\251rer les grilles&quot;,RunWindow('generer')),MenuItem(&quot;Resoudre la grille en jeu&quot;,Action(Evaluate('S'='sudok'([seq([seq('GC'[k],k=1+a*b*(i-1)..a*b*i)],i=1..a*b)],a,b)),seq(Evaluate(ll[i]='S'[i]),i=1..nops(ll)),RunWindow('W3'))),MenuItem(&quot;Effacer&quot;,Action(seq(Evaluate('MEX'[ki]=true),ki=1..a*b),seq(Evaluate('ME'[ki]=true),ki=1..(a*b)^3),Evaluate('oso'=&quot;&quot;),seq(seq(SetOption(l[a*b*(i-1)+j]('foreground')=LightYellow),i=1..a*b),j=1..a*b),Evaluate('cpto'=1),Evaluate('oso2'=&quot;&quot;),Evaluate('sre'=&quot;[]&quot;),Evaluate('function'='retaZ'()),seq(SetOption(lll[i]('editable')=false),i=1..a*b*b*a),seq(SetOption(RA[i]('value')=false),i=1..a*b*b*a),Evaluate('Num'=&quot;&quot;),Evaluate('GC'=[seq(seq(&quot;dra&quot;,i=1..a*b),j=1..a*b)]),Evaluate('function'='fff'),Evaluate('J'=&quot;&quot;),Evaluate('function'='ino'),SetOption(G('editable')=true),Evaluate('G'=&quot;&quot;),seq(SetOption(l[i]('foreground')=blue),i=1..nops(l)),seq(SetOption(l[i]('editable')=true),i=1..nops(l)),Evaluate('p'=0),Evaluate('S'=&quot;&quot;),seq(Evaluate(ll[i]=&quot;&quot;),i=1..nops(ll)),Evaluate('function'='fff'),Evaluate('function'='recop'))),MenuItem(&quot;grilles resolues&quot;,RunWindow('GRE')),MenuItem(&quot;juste ?&quot;,Action(Evaluate('function'='testj'('a','b')),RunWindow('W4')))),Menu(caption=&quot;Externe&quot;,MenuItem(&quot;R\303\251soudre la grille ins\303\251r\303\251e&quot;,Action(Evaluate('S'='ffo('p',a,b)'),RunWindow('W3'))),MenuItem(&quot;charger grilles&quot;,Action(Evaluate('oso'=&quot;&quot;),Evaluate('oso2'=&quot;&quot;),Evaluate('sre'=&quot;[]&quot;),RunWindow('charger')))),Menu(caption=&quot;Sauvegarder&quot;,MenuItem(&quot;sauvegarder les grilles&quot;,RunWindow('sauvegarder'))),Menu(caption=&quot;Choix grille&quot;,MenuItem(&quot;choix grille \303\240 jouer&quot;,Action(RunWindow('jouer'))),MenuItem(&quot;choix grille \303\240 pr\303\251senter&quot;,Action(RunWindow('presenter'))))),Window['helpx']('title'=&quot;aide&quot;,layout=GridLayout(GridRow(GridCell(TextBox(10..20,editable=false,value=&quot;le but du sudoku \303\240 r\303\251gion a*b est de remplir totalement chaque ligne, chaque colonne et chaque r\303\251gion seulement avec tous les nombres de 1 \303\240 a*b sans r\303\251p\303\251titions.
Auteur: Xavier Cormier
adresse mail: x.cormier@wanadoo.fr.&quot;))),border=true),resizable=false),Window['TTK'](resizable=false,layout=BorderLayout(GridCell2(BorderLayout(GridCell2(BorderLayout(GridCell2(GridLayout(GridRow(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(TextBox[l[a*b*(kj-1)+ki]](value=&quot;&quot;,editable=false,background=LightYellow,foreground=blue,height=hwb1(a,b)[1],width=hwb1(a,b)[2],focus=true,font=Font(police,sp)))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(j-1)..b*j))),seq(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(TextBox[l[a*b*(kj-1)+ki]](value=&quot;&quot;,editable=false,background=LightYellow,foreground=blue,height=hwb1(a,b)[1],width=hwb1(a,b)[2],focus=true,font=Font(police,sp)))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(j-1)..b*j))),i=2..b)])),j=1..a-1),GridRow(op([GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(TextBox[l[a*b*(kj-1)+ki]](value=&quot;&quot;,editable=false,background=LightYellow,foreground=blue,height=hwb1(a,b)[1],width=hwb1(a,b)[2],focus=true,font=Font(police,sp)))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(a-1)..b*a))),seq(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(TextBox[l[a*b*(kj-1)+ki]](value=&quot;&quot;,editable=false,background=LightYellow,foreground=blue,height=hwb1(a,b)[1],width=hwb1(a,b)[2],focus=true,font=Font(police,sp)))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(a-1)..b*a))),i=2..b)])),inset=2,background=black))),background=black,inset=6))),background=LightYellow),constraint=center),GridCell2(constraint=north),GridCell2(constraint=west),GridCell2(constraint=east),GridCell2(constraint=south),background=LightYellow),constraint=center),GridCell2(constraint=west),GridCell2(constraint=east),GridCell2(constraint=south),background=LightYellow),constraint=center))),Window['MENU'](title=&quot;Menu&quot;,layout=BorderLayout(GridCell2(constraint=center,GridLayout(caption=&quot;Menu&quot;,border=true,GridRow(GridCell(GridLayout(caption=&quot;aide&quot;,border=true,GridRow(GridCell(Button(&quot;Aide&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=RunWindow('helpx'))))))),GridRow(GridCell(GridLayout(caption=&quot;Jeu&quot;,border=true,GridRow(GridCell(Button(&quot;G\303\251n\303\251rer les grilles&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(RunWindow('generer'))))),GridRow(GridCell(Button(&quot;Resoudre la grille en jeu&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(Evaluate('S'='sudok'([seq([seq('GC'[k],k=1+a*b*(i-1)..a*b*i)],i=1..a*b)],a,b)),seq(Evaluate(ll[i]='S'[i]),i=1..nops(ll)),RunWindow('W3'))))),GridRow(GridCell(Button(&quot;Effacer&quot;,font=Font(&quot;Arial&quot;,bold,16),Action(seq(Evaluate('MEX'[ki]=true),ki=1..a*b),seq(Evaluate('ME'[ki]=true),ki=1..(a*b)^3),Evaluate('oso'=&quot;&quot;),seq(seq(SetOption(l[a*b*(i-1)+j]('foreground')=LightYellow),i=1..a*b),j=1..a*b),Evaluate('cpto'=1),Evaluate('oso2'=&quot;&quot;),Evaluate('sre'=&quot;[]&quot;),Evaluate('function'='retaZ'()),seq(SetOption(lll[i]('editable')=false),i=1..a*b*b*a),seq(SetOption(RA[i]('value')=false),i=1..a*b*b*a),Evaluate('Num'=&quot;&quot;),Evaluate('GC'=[seq(seq(&quot;dra&quot;,i=1..a*b),j=1..a*b)]),Evaluate('function'='fff'),Evaluate('J'=&quot;&quot;),Evaluate('function'='ino'),SetOption(G('editable')=true),Evaluate('G'=&quot;&quot;),seq(SetOption(l[i]('foreground')=blue),i=1..nops(l)),seq(SetOption(l[i]('editable')=true),i=1..nops(l)),Evaluate('p'=0),Evaluate('S'=&quot;&quot;),seq(Evaluate(ll[i]=&quot;&quot;),i=1..nops(ll)),Evaluate('function'='fff'),Evaluate('function'='recop'))))),GridRow(GridCell(Button(&quot;grilles resolues&quot;,font=Font(Arial,bold,16),onclick=RunWindow('GRE')))),GridRow(GridCell(Button(&quot;juste ?&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(Evaluate('function'='testj'('a','b')),RunWindow('W4')))))))),GridRow(GridCell(GridLayout(caption=&quot;Externe&quot;,border=true,GridRow(GridCell(Button(&quot;R\303\251soudre la grille ins\303\251r\303\251e&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(Evaluate('S'='ffo('p',a,b)'),RunWindow('W3'))))),GridRow(GridCell(Button(&quot;charger grilles&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(Evaluate('oso'=&quot;&quot;),Evaluate('oso2'=&quot;&quot;),Evaluate('sre'=&quot;[]&quot;),RunWindow('charger')))))))),GridRow(GridCell(GridLayout(caption=&quot;Sauvegarder&quot;,border=true,GridRow(GridCell(Button(&quot;sauvegarder les grilles&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=RunWindow('sauvegarder'))))))),GridRow(GridCell(GridLayout(caption=&quot;Choix grille&quot;,border=true,GridRow(GridCell(Button(&quot;choix grille \303\240 jouer&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(RunWindow('jouer'))))),GridRow(GridCell(Button(&quot;choix grille \303\240 pr\303\251senter&quot;,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(RunWindow('presenter'))))))))))),resizable=false),Window['TKK']('title'=convert(cat(a,&quot;x&quot;,b,&quot;-sudoku&quot;),string),'layout'=BorderLayout(GridCell2(constraint=north),GridCell2(GridLayout(border=true,GridRow(GridCell(Button(&quot;Juste ?&quot;,font=Font(&quot;Arial&quot;,16,bold),'onclick'=Evaluate('function'='testj2'(a,b)))),GridCell(TextField['J2'](width=15,'editable'=false,foreground=red,background=pink)))),constraint=south),GridCell2(constraint=east),GridCell2(constraint=west),GridCell2(BorderLayout(background=LightYellow,GridCell2(GridLayout(GridRow(GridCell(BorderLayout(GridCell2(GridLayout(GridRow(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(TextField[llll[a*b*(kj-1)+ki]](background=LightYellow,foreground=black,value=&quot;&quot;,halign=center,width=taillex(a,b),font=Font(&quot;Arial&quot;,bold,35)))),background=LightYellow,inset=0))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(j-1)..b*j),inset=1,background=black))),inset=1,background=black)),seq(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(TextField[llll[a*b*(kj-1)+ki]](background=LightYellow,foreground=black,value=&quot;&quot;,halign=center,width=taillex(a,b),font=Font(&quot;Arial&quot;,bold,35)))),inset=0,background=LightYellow))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(j-1)..b*j),inset=1,background=black))),inset=1,background=black)),i=2..b)])),j=1..a-1),GridRow(op([GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(TextField[llll[a*b*(kj-1)+ki]](background=LightYellow,foreground=black,value=&quot;&quot;,halign=center,width=taillex(a,b),font=Font(&quot;Arial&quot;,bold,35)))),inset=0,background=LightYellow))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(a-1)..b*a),inset=1,background=black))),background=black,inset=1)),seq(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(TextField[llll[a*b*(kj-1)+ki]](background=LightYellow,foreground=black,value=&quot;&quot;,width=taillex(a,b),halign=center,font=Font(&quot;Arial&quot;,bold,35)))),inset=0,background=LightYellow))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(a-1)..b*a),inset=1,background=black))),background=black,inset=1)),i=2..b)])),background=Khaki,inset=0)))))),background=black,inset=4),constraint=center),background=LightYellow))),background=LightYellow),constraint=center),background=LightYellow,inset=10),constraint=center),hgap=50,vgap=50,background=LightYellow),resizable=true),Window['TK']('title'=convert(cat(a,&quot;x&quot;,b,&quot;-sudoku&quot;),string),menubar='MB',defaultbutton='EG','layout'=BorderLayout(GridCell2(GridLayout(GridRow(GridCell(BorderLayout(GridCell2(GridLayout(GridRow(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(TextBox[lll[a*b*(kj-1)+ki]](editable=false,popupmenu=PNN[a*b*(kj-1)+ki],foreground=alter(a,b,[j,1]),background=alter(a,b,[j,1]),value=&quot;&quot;,height=hwb1(a,b)[1],width=hwb1(a,b)[2],font=Font(police,sp)))),background=alter(a,b,[j,1]),inset=0))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(j-1)..b*j),inset=1,background=colx))),inset=1,background=colr)),seq(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(TextBox[lll[a*b*(kj-1)+ki]](editable=false,popupmenu=PNN[a*b*(kj-1)+ki],foreground=alter(a,b,[j,i]),background=alter(a,b,[j,i]),value=&quot;&quot;,height=hwb1(a,b)[1],width=hwb1(a,b)[2],font=Font(police,sp)))),inset=0,background=alter(a,b,[j,i])))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(j-1)..b*j),inset=1,background=colx))),inset=1,background=colr)),i=2..b)])),j=1..a-1),GridRow(op([GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(TextBox[lll[a*b*(kj-1)+ki]](editable=false,popupmenu=PNN[a*b*(kj-1)+ki],foreground=alter(a,b,[a,1]),background=alter(a,b,[a,1]),value=&quot;&quot;,height=hwb1(a,b)[1],width=hwb1(a,b)[2],font=Font(police,sp)))),inset=0,background=alter(a,b,[a,1])))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(a-1)..b*a),inset=1,background=colx))),background=colr,inset=1)),seq(GridCell(GridLayout(GridRow(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(GridLayout(GridRow(GridCell(TextBox[lll[a*b*(kj-1)+ki]](editable=false,popupmenu=PNN[a*b*(kj-1)+ki],foreground=alter(a,b,[a,i]),background=alter(a,b,[a,i]),value=&quot;&quot;,height=hwb1(a,b)[1],width=hwb1(a,b)[2],font=Font(police,sp)))),inset=0,background=alter(a,b,[a,i])))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(a-1)..b*a),inset=1,background=colx))),background=colr,inset=1)),i=2..b)])),background=white,inset=esp)))))),background=col,border=false,inset=5),constraint=center),background=white,inset=0))),GridRow(GridCell(Label(&quot;Alt+key&quot;,background=Black,foreground=white))),background=Black,border=false,inset=10),constraint=west),GridCell2(BorderLayout(background=Black,GridCell2(GridLayout(GridRow(GridCell(GridLayout(GridRow(GridCell(Button(&quot;MENU&quot;,background=Grey,onclick=RunWindow('MENU'))),GridCell(TextField['Num'](editable=false,width=5,background=grey,foreground=DarkRed,font=Font(&quot;Arial&quot;,bold,12))),GridCell(TextField['inc'](value=1,width=1,visible=false,editable=false))),background=Grey,border=false))),GridRow(GridCell(BorderLayout(hgap=3,vgap=3,background=Chocolate,border=false,GridCell2(GridLayout(GridRow(GridCell(RadioButton['mh'](&quot;*&quot;,background=grey,foreground=grey,group='CHS',font=Font(Arial,bold,30),onclick=Action(Evaluate('function'='depl'(1)),Evaluate('function'='recmex'(a,b)))))),GridRow(GridCell(Label(&quot;XC&quot;,foreground=Chocolate,background=Chocolate,font=Font(&quot;Arial&quot;,38)))),GridRow(GridCell(RadioButton['mb'](&quot;*&quot;,background=grey,foreground=grey,group='CHS',font=Font(Arial,bold,30),onclick=Action(Evaluate('function'='depl'(2)),Evaluate('function'='recmex'(a,b)))))),background=Chocolate),constraint=center),GridCell2(constraint=west,GridLayout(background=Chocolate,GridRow(GridCell(Label(&quot;XC&quot;,foreground=Chocolate,background=Chocolate))),GridRow(GridCell(RadioButton['mg'](&quot;*&quot;,background=grey,foreground=grey,group='CHS',font=Font(Arial,bold,30),onclick=Action(Evaluate('function'='depl'(3)),Evaluate('function'='recmex'(a,b)))))),GridRow(GridCell(Label(&quot;XC&quot;,foreground=Chocolate,background=Chocolate))))),GridCell2(constraint=east,GridLayout(background=Chocolate,GridRow(GridCell(Label(&quot;XC&quot;,foreground=Chocolate,background=Chocolate))),GridRow(GridCell(RadioButton['md'](&quot;*&quot;,background=grey,foreground=grey,group='CHS',font=Font(Arial,bold,30),onclick=Action(Evaluate('function'='depl'(4)),Evaluate('function'='recmex'(a,b)))))),GridRow(GridCell(Label(&quot;XC&quot;,foreground=Chocolate,background=Chocolate)))))))),GridRow(GridCell(GridLayout(background=grey,GridRow(GridCell(RadioButton(caption=&quot;&amp;k&quot;,foreground=black,background=grey,group='DH',onclick=Action(Evaluate('mg'=true),Evaluate('function'='depl(3)'),Evaluate('function'='recmex'(a,b))))),GridCell(RadioButton(caption=&quot;&amp;o&quot;,foreground=black,background=grey,group='DH',onclick=Action(Evaluate('mh'=true),Evaluate('function'='depl(1)'),Evaluate('function'='recmex'(a,b))))),GridCell(RadioButton(caption=&quot;&amp;l&quot;,foreground=black,background=grey,group='DH',onclick=Action(Evaluate('mb'=true),Evaluate('function'='depl(2)'),Evaluate('function'='recmex'(a,b))))),GridCell(RadioButton(caption=&quot;&amp;m&quot;,foreground=black,background=grey,group='DH',onclick=Action(Evaluate('md'=true),Evaluate('function'='depl(4)'),Evaluate('function'='recmex'(a,b))))))))),GridRow(GridCell(GridLayout(background=LightBlue,border=false,inset=1,seq(GridRow(seq(GridCell(Button(caption=rpx(a,b,k),background=LightBlue,font=Font(Arial,bold,sp),onclick=Evaluate('function'='insx'(a,b,k)))),k=1+(io-1)*a..io*a)),io=1..b)))),GridRow(GridCell(GridLayout(GridRow(GridCell(GridLayout(background=DarkRed,GridRow(GridCell(Button(&quot;&amp;i+&quot;,background=LightBlue,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(Evaluate('inc'=1),Evaluate('cptk'='modx'('bet1'(a,b)+parse('inc'),(a*b))),Evaluate('function'='insx'(a,b,'cptk'))))),GridCell(Button['EG'](&quot;=&quot;,background=LightBlue,font=Font(&quot;Arial&quot;,bold,16),onclick=Action(Evaluate('inc'=0),Evaluate('cptk'='modx1'('bet0'(a,b)+parse('inc'),(a*b))),Evaluate('function'='insx'(a,b,'cptk')))))))),GridCell(TextField['cptk'](value=a*b,width=2,background=LightBlue,foreground=Blue,popupmenu='cptkp',visible=true,halign=center,foreground=Blue,font=Font(Arial,bold,20),editable=true))),GridRow(GridCell(Button(&quot;&amp;eff&quot;,background=DarkRed,font=Font(&quot;Arial&quot;,bold,20),onclick=Action(Evaluate('function'='effmex'(a,b)),Evaluate('function'='ini'(a,b))))),GridCell(Button(&quot;&amp;r?&quot;,background=DarkRed,font=Font(&quot;Arial&quot;,bold,20),onclick=Evaluate('function'='insxt'(a,b))))),background=DarkRed,border=false,inset=2))),GridRow(GridCell(BorderLayout(background=pink,GridCell2(GridLayout(background=pink,seq(GridRow(seq(GridCell(CheckBox['MEX'[io]](rp(a,b,io),background=pink,value=true,font=Font(police,sp))),io=1+(ik-1)*a..ik*a)),ik=1..b),border=false),constraint=center),GridCell2(constraint=south,GridLayout(background=pink,GridRow(GridCell(Button(&quot;&amp;w+&quot;,background=pink,font=Font(&quot;Arial&quot;,bold,12),onclick=Action(Evaluate('cptkz'='modx'('betc'()+1,(a*b)))))),GridCell(Button(&quot;&amp;x&quot;,background=pink,font=Font(&quot;Arial&quot;,bold,12),onclick=Action(Evaluate('function'='chgc')))),GridCell(TextField['cptkz'](value=a*b,width=2,background=pink,foreground=Black,visible=true,halign=center,font=Font(Arial,bold,sp),editable=false))))),GridCell2(GridLayout(background=pink,GridRow(GridCell(Button(&quot;&amp;c&quot;,background=pink,font=Font(&quot;Arial&quot;,bold,20),onclick=Action(Evaluate('function'='ini'(a,b)),Evaluate('function'='inscand'(a,b))))))),constraint=east),hgap=5,vgap=5))),background=Grey,border=false,inset=3),constraint=east),background=Black,vgap=10,hgap=10,border=false),constraint=center),GridCell2(constraint=east),GridCell2(constraint=south),GridCell2(constraint=north),hgap=10,vgap=10,background=Black),resizable=false),PopupMenu['cptkp'](Menu(&quot;inserer&quot;,seq(MenuItem(caption=convert(ki,string),Action(Evaluate('cptk'=ki),Evaluate('function'='insx'(a,b,'cptk')))),ki=1..a*b))),seq(PopupMenu[PNN[k]](Menu(caption=&quot;||||&quot;,MenuItem(caption=&quot;selection&quot;,Action(Evaluate('cpto'=k),Evaluate('function'='recmex'(a,b)),Evaluate('function'='depl2'(k)))))),k=1..a*b*b*a),seq(PopupMenu[PN[k]](Menu(caption=&quot;||||&quot;,MenuItem(caption=&quot;||||&quot;,Action(Evaluate('function'='depl2'(k)))))),k=1..a*b*b*a),Window['GRE'](title=&quot;grilles resolues&quot;,layout=BorderLayout(background=LightYellow,GridCell2(constraint=center,GridLayout(background=LightYellow,caption=&quot;Grilles resolues&quot;,border=true,GridRow(GridCell(TextBox['sre']('value'=&quot;[]&quot;,editable=false,7..26)))))),resizable=false),Window['W3']('title'=&quot;Solution&quot;,[[[[BorderLayout(GridCell2(GridLayout(seq(GridRow(op([GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(TextField[ll[a*b*(kj-1)+ki]](width=nops(convert(a*b,base,10)),editable=false,halign=center,background=pink,foreground=black,font=Font(police,22)))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(j-1)..b*j))),seq(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(TextField[ll[a*b*(kj-1)+ki]](width=nops(convert(a*b,base,10)),editable=false,halign=center,background=pink,foreground=black,font=Font(police,22)))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(j-1)..b*j))),i=2..b)])),j=1..a-1),GridRow(op([GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(TextField[ll[a*b*(kj-1)+ki]](width=nops(convert(a*b,base,10)),editable=false,halign=center,background=pink,foreground=black,font=Font(police,22)))]),ki=1+a*(1-1)..a*1)])),kj=1+b*(a-1)..b*a))),seq(GridCell(GridLayout(seq(GridRow(op([seq(op([GridCell(TextField[ll[a*b*(kj-1)+ki]](width=nops(convert(a*b,base,10)),editable=false,halign=center,background=pink,foreground=black,font=Font(police,22)))]),ki=1+a*(i-1)..a*i)])),kj=1+b*(a-1)..b*a))),i=2..b)])),border=false,inset=2,background=black),constraint=center),GridCell2(constraint=south),GridCell2(constraint=north),GridCell2(constraint=west),GridCell2(constraint=east),vgap=4,hgap=4,background=black)],[TextField['S'](width=2,editable=false)]]]],resizable=false),Window['W4']('title'=&quot;correction&quot;,resizable=false,[[TextBox['J'](background=pink,foreground=red,editable=false,font=Font(Arial,bold,30),width=20)]]),Window['generer']('title'=&quot;generation&quot;,[[Label(&quot;nombre de cases vides maximum&quot;,font=Font(&quot;Arial&quot;,bold,25)),DropDownBox['N']([seq(convert(ki,string),ki=0..a*b*b*a)],width=75,font=Font(Null,bold,30))],[Label(&quot;nombre aleatoire&quot;,font=Font(&quot;Arial&quot;,bold,25)),TextBox['w'](value=randomize(fracs(time())),background=blue,foreground=white,width=2,font=Font(Null,bold,25)),Button(&quot;&amp;hasard&quot;,Evaluate('w'='randomize1'()))],[Button(&quot;&amp;nombre de grille&quot;,Evaluate('nb'=1))],[Label(&quot;nombre de grilles&quot;,font=Font(&quot;Arial&quot;,bold,25)),TextBox['nb'](background=pink,foreground=red,width=2,font=Font(Null,bold,25))],Button(&quot;&amp;g\303\251n\303\251rer&quot;,Action(Evaluate('sre'=&quot;[]&quot;),Evaluate('oso'=&quot;&quot;),Evaluate('oso2'=&quot;&quot;),Evaluate('J'=&quot;&quot;),Evaluate('G'='generateur('N','nb',trunc(abs('w')),a,b)'),SetOption(G('editable')=false),Evaluate('function'='inat'('a','b')),Evaluate('S'=&quot;&quot;),seq(Evaluate(ll[i]=&quot;&quot;),i=1..nops(ll))),font=Font(Arial,bold,25))],resizable=false),Window['charger']('title'=&quot;charger grilles&quot;,resizable=false,[[Label(&quot;grilles&quot;,font=Font(Arial,bold,25)),TextField['G'](width=7,font=Font(Null,bold,8))],Button(&quot;charger&quot;,Action(seq(SetOption(RA[i]('value')=false),i=a*b*b*a),Evaluate('function'='inat'('a','b')),SetOption(G('editable')=false)),font=Font(Arial,bold,25))]),Window['jouer']('title'=&quot;choix grille&quot;,resizable=false,[[ComboBox['ito'](width=80,editable=false,onchange=Evaluate('oso'=&quot;&quot;),font=Font(Null,bold,30))],[TextField['oso'](width=7,editable=false,background=pink,foreground=red)],[Button(&quot;&amp;jouer avec grille ci-dessus&quot;,Action(seq(Evaluate('MEX'[ki]=true),ki=1..a*b),seq(Evaluate('ME'[ki]=true),ki=1..(a*b)^3),Evaluate('function'='soso'('ito','sre')),Evaluate('cpto'=1),Evaluate('function'='retaZ'()),seq(SetOption(RA[i]('value')=false),i=a*b*b*a),seq(seq(SetOption(l[a*b*(i-1)+j]('foreground')=LightYellow),i=1..a*b),j=1..a*b),seq(seq(SetOption(RA[a*b*(i-1)+j]('foreground')=alter(a,b,(zone(a,b,i,j)))),i=1..a*b),j=1..a*b),Evaluate('Num'=ito),Evaluate('S'=&quot;&quot;),Evaluate('GC'=[seq('G'[(ito-1)+a*b*b*a*(ito-1)+j],j=1..a*b*b*a)]),Evaluate('function'='ff'),Evaluate('p'=1),seq(Evaluate(ll[i]=&quot;&quot;),i=1..nops(ll)),Evaluate('function'='recop'),Evaluate('S'='sudok'([seq([seq('GC'[k],k=1+a*b*(i-1)..a*b*i)],i=1..a*b)],a,b)),seq(Evaluate(ll[i]='S'[i]),i=1..nops(ll))),font=Font(Null,bold,25))]]),Window['sauvegarder']('title'=&quot;sauvegarder&quot;,resizable=false,[[&quot;lieu de sauvegarde&quot;,TextField['info'](editable=false)],[Button(&quot;&amp;sauvegarder&quot;,Evaluate('function'='enregistrer'()))]]),Window['presenter']('title'=&quot;pr\303\251senter grille&quot;,resizable=false,[[ComboBox['ito2'](width=80,editable=false,onchange=Evaluate('oso2'=&quot;&quot;),font=Font(Null,bold,30))],[TextField['oso2'](width=10,editable=false,foreground=red,background=pink)],[&quot;couleur 1&quot;,ComboBox['color1']([&quot;white&quot;,&quot;grey&quot;,&quot;Khaki&quot;,&quot;LightGreen&quot;,&quot;LightBlue&quot;],editable=false)],[&quot;couleur 2&quot;,ComboBox['color2']([&quot;white&quot;,&quot;grey&quot;,&quot;Khaki&quot;,&quot;LightGreen&quot;,&quot;LightBlue&quot;],editable=false)],[&quot;couleur des nombres&quot;,ComboBox['colnb']([&quot;red&quot;,&quot;black&quot;],editable=false)],[&quot;police&quot;,ComboBox['plsp']([[COURIER],[&quot;Arial&quot;]],editable=false)],[Button(&quot;&amp;a-sauvegarder toutes les grilles en gif&quot;,Action(Evaluate('oso2'=&quot;&quot;),Evaluate('function'='plotagemulti'(a,b,'color1','color2',non,'plsp','colnb')),Evaluate('J2'=&quot;&quot;)),font=Font(Null,bold,25))],[Button(&quot;&amp;b-Pr\303\251senter grille ci-dessus&quot;,Action(Evaluate('function'='soso2'('ito2','sre')),Evaluate('GCp'=[seq('G'[(ito2-1)+a*b*b*a*(ito2-1)+j],j=1..a*b*b*a)]),Evaluate('function'='ffp'),Evaluate('J2'=&quot;&quot;),RunWindow('TKK')),font=Font(Null,bold,25))],[&quot;lieu d'enregistrement&quot;,TextField['loc']('editable'=false,'width'=20)]]),Window['en']('title'=&quot;grille en jeu&quot;,[TextField['GC'](value=[seq(seq(&quot;dra&quot;,i=1..a*b),j=1..a*b)],editable=false,width=1),TextField['GCp'](value=[seq(seq(&quot;&quot;,i=1..a*b),j=1..a*b)],editable=false,width=1),TextField['p'](value=0,editable=false,width=1)]),ButtonGroup['DH'](),ButtonGroup['BG1'](),ButtonGroup['MV'](),ButtonGroup['CHS'](),ButtonGroup['CHC'](),ButtonGroup['Z1'](),ButtonGroup['BD'](),ButtonGroup['Z2']());Maplets[Display](maplet);fi;end;taillex:=(a,b)-&gt;nops(convert(a*b,base,10));taillep:=(a,b,tapol)-&gt;if (a=1 and b&lt;=2) or (b=1 and a&lt;=2) then 35 elif (a=1 and b&lt;=3) or (b=1 and a&lt;=3) then 35 elif (a=1 and b&lt;=6) or (b=1 and a&lt;=6) or (a=2 and b&lt;=4) or (b=2 and a&lt;=4) then 22 elif a=3 and b=3 then tapol else 12;fi;tailleq:=(a,b)-&gt;if (a=1 and b&lt;=2) or (b=1 and a&lt;=2) then 25 elif (a=1 and b&lt;=3) or (b=1 and a&lt;=3) then 25 elif (a=1 and b&lt;=6) or (b=1 and a&lt;=6) or (a=2 and b&lt;=4) or (b=2 and a&lt;=4) then 8 elif a=3 and b=3 then 8 else 8;fi;taillep1:=proc(a,b,ab,tapol) uses Maplets:-Tools;if ab=1 then tailleq(a,b);elif ab=2 then taillep(a,b,tapol);fi;end;hwb:=(a,b)-&gt;if (a=1 and b&lt;=2) or (b=1 and a&lt;=2) then [1,4] elif (a=1 and b&lt;=3) or (b=1 and a&lt;=3) then [1,4] elif (a=1 and b&lt;=6) or (b=1 and a&lt;=6) or (a=2 and b&lt;=4) or (b=2 and a&lt;=4) then [2,4] elif a=3 and b=3 then [2,4] else [4,5];fi;hwc:=(a,b)-&gt;if (a=1 and b&lt;=2) or (b=1 and a&lt;=2) then [2,2] elif (a=1 and b&lt;=3) or (b=1 and a&lt;=3) then [2,2] elif (a=1 and b&lt;=6) or (b=1 and a&lt;=6) or (a=2 and b&lt;=4) or (b=2 and a&lt;=4) then [2,4] elif a=3 and b=3 then [2,4] else [5,5];fi;hwb1:=proc(a,b) uses Maplets:-Tools;ab:=2;if ab=1 then hwc(a,b) elif ab=2 then hwb(a,b);fi;end;vga:=(a,b)-&gt;if (a=1 and b&lt;=2) or (b=1 and a&lt;=2) then 0 elif (a=1 and b&lt;=3) or (b=1 and a&lt;=3) then 0 elif (a=1 and b&lt;=6) or (b=1 and a&lt;=6) or (a=2 and b&lt;=4) or (b=2 and a&lt;=4) then 35 elif a=3 and b=3 then 65 else 145;fi;maplet1:=Maplet(Window('title'=&quot;sudoku (version finale)&quot;,layout=BorderLayout(GridCell2(GridLayout(GridRow(GridCell(Label(&quot;largeur d'une r\303\251gion :&quot;)),GridCell(TextField['a'](width=2))),GridRow(GridCell(Label(&quot;hauteur d'une r\303\251gion :&quot;)),GridCell(TextField['b'](width=2))),GridRow(GridCell(ComboBox['tpo'](visible=false,[convert(20,string)],editable=false))),GridRow(GridCell(Label(&quot;couleur 1&quot;)),GridCell(ComboBox['fond1']([&quot;grey&quot;,&quot;ForestGreen&quot;,&quot;LightBlue&quot;,&quot;LightYellow&quot;,&quot;Chocolate&quot;],editable=false))),GridRow(GridCell(Label(&quot;couleur 2&quot;)),GridCell(ComboBox['fond2']([&quot;grey&quot;,&quot;ForestGreen&quot;,&quot;LightBlue&quot;,&quot;LightYellow&quot;,&quot;Chocolate&quot;],editable=false))),GridRow(GridCell(Label(&quot;taille police&quot;)),GridCell(ComboBox['tapol']([seq(convert(io,string),io=12..100)],editable=false))),GridRow(GridCell(Label(&quot;Interface&quot;)),GridCell(GridLayout(background=pink,GridRow(GridCell(RadioButton['type1'](caption=&quot;1&quot;,background=pink,value=true,group='GINT',onclick=Action(Evaluate('colx'=white),Evaluate('esp'=0)))),GridCell(RadioButton['type2'](caption=&quot;2&quot;,background=pink,value=false,group='GINT',onclick=Action(Evaluate('colx'=white),Evaluate('esp'=8))))))),GridCell(TextField['colx'](value=&quot;white&quot;,editable=false,visible=false)),GridCell(TextField['esp'](value=0,editable=false,visible=false,width=1))),GridRow(GridCell(Label(&quot;                                 &quot;)),GridCell(Button(&quot;go&quot;,Evaluate('function'='sudoku_maplet4('a','b',black,[Null],'tapol','tpo',white,'fond1','fond2','colx','esp')')))),GridRow(GridCell(Label(&quot;Xavier Cormier&quot;)))),constraint=south),vgap=5,hgap=0,background=grey),resizable=true),ButtonGroup['GINT'](),ButtonGroup['Q1']());Maplets[Display](maplet1)</EC-CodeEditor></CodeEditor-ExecGroup></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L5" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
<Input>
<Text-field style="Text" layout="Normal"><Equation executable="false" style="2D Math" input-equation="" display="LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbWlHRiQ2I1EhRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYn">JSFH</Equation></Text-field>
</Input>
</Group></Presentation-Block>
</Worksheet>