%% This file is generated by preprocessor!
%% Do not edit it by hand.
%% Edit the source file cpp/blocks.cpp.

\language{es}
\author{XIAO, Gang}
\email{xiao@unice.fr}
\computeanswer{no}
\format{html}
\precision{10000}

\text{colorlist=red,green,blue,gray,orange,cyan,violet,black}
\text{colornamem=rojo,verde,azul,gris,naranja,cián,violeta,negro}
\text{colornamef=roja,verde,azul,gris,naranja,cián,violeta,negra}
 \title{9: Cuadrado + diagonales}
 \integer{tot=5}
 \text{posx=-1,0,1,-1,0,1,-1,0,1}
 \text{posy=1,1,1,0,0,0,-1,-1,-1}
 \text{first=1,3,5,7,9}
 \text{conds=2,1,3,5;4,1,5,7;6,3,5,9;8,7,5,9}
 \text{centers=0,0.5;-0.5,0;0.5,0;0,-0.5}
 \integer{xstep=120}
 \integer{ystep=100}
 \integer{xrange=1}
 \integer{yrange=1}
 \text{border=0.3}
 \text{borderline=1,3,9,7,1,9,7,3}
 \text{circle=}
 \integer{coeff=3}
\integer{Tot=\tot+4}


\integer{confparm1=\confparm1 issametext ?1}
\integer{confparm2=\confparm2 issametext ?0}
\text{vars=shuffle(a,b,c,d,r,s,t,x,y,z)}
\text{rt=sqrt(random(2,3,5))}
\text{list=wims(record \confparm1 of src/data)}
\text{nature=\list[1;]}
\text{parms=\list[2;]}
\text{smin=\list[3;1]}
\text{smax=\list[3;2]}
\integer{smean=(\smin+\smax)/2}
\text{obj=\parms[1]}
\text{sizex=\parms[2]}
\text{sizey=\parms[3]}
\text{sizex=\sizex =? 60}
\text{sizey=\sizey=? 35}
\text{size=\sizex \sizey}
\text{list=wims(rows2lines row(4..-1,\list))}
\integer{n=items(\list)}
\if{\n<=3}{
 \text{a=\list[1]}
 \text{b=\list[2]}
 \text{c=\list[3]}
 \text{randtype=computed}
 \if{\c<0}{
  \text{sh1=wims(values \c*x,-(\c)*x for x=\a to \b)}
 }{
  \text{sh1=wims(values \c*x for x=\a to \b)}
 }
 \text{list=\sh1}
}{
 \text{randtype=listed}
}
\text{list=wims(mathsubst f=\vars[1] in \list)}
\text{list=wims(mathsubst g=\vars[2] in \list)}
\text{list=wims(mathsubst rt=\rt in \list)}
\text{sh=item(1..\tot,shuffle(\list))}

\text{bb=wims(values 0 for x=1 to \Tot)}
\for{t=1 to \tot}
{\text{bb=wims(replace item number \first[\t] by \sh[\t] in \bb)}}
\real{sum=\smin<0?randint(\coeff*\smin..\coeff*\smax):
     (\coeff-1)*\smean+randint(2*\smean..2*\smax)}


\integer{condcnt=rows(\conds)}
\for{c=1 to \condcnt}{
 \text{cond=\conds[\c;]}
 \integer{cc=items(\cond)}
 \text{tt=(\sum)}
 \for{i=2 to \cc}{
  \text{tt=\tt-(\bb[\cond[\i]])}
 }
 \if{\randtype issametext computed}{
  \real{tt=\tt}
 }{
  \text{tt=maxima(expand(\tt))}
 }
 \text{bb=wims(replace item number \cond[1] by \tt in \bb)}
}



\text{redund=}
\text{red=wims(listcomplement \bb in \list)}
\integer{rcnt=min(\confparm2,items(\red))}
\for{t=1 to \rcnt}{
 \text{rrr=item(1..\confparm2,\red)}
 \text{tt=/ isin \rrr[\t]?wims(replace / by /( in \(\rrr[\t]))):\(\rrr[\t])}
 \text{redund=\redund,\tt}
}
\text{obj=}
\for{t=1 to \Tot}{
 \if{/ isin \bb[\t]}{
  \text{tt=wims(replace / by /( in \(\bb[\t])))}
 }{\text{tt=\(\bb[\t])}}
 \text{obj=wims(append item \tt to \obj)}
}
\text{lines=lines black}
\for{i in \borderline}{
 \text{lines=\lines,\posx[\i],\posy[\i]}
}
\text{fill=}
\for{i=1 to 4}{
 \text{fill=\fill
fill \centers[\i;],\colorlist[\i]}
}
\integer{Sizex=2*(\xrange+\border)*\xstep}
\integer{Sizey=2*(\yrange+\border)*\ystep}
\text{bigimg=draw(\Sizex,\Sizey
 xrange -\border-\xrange,\xrange+\border
 yrange -\border-\yrange,\yrange+\border
 fill 0,0,white
 linewidth 3
 \lines
 \circle
 \fill
)}
\text{posx=wims(values x*\xstep+\Sizex/2-\sizex/2 for x in \posx)}
\text{posy=wims(values -y*\ystep+\Sizey/2-\sizey/2 for y in \posy)}
\text{caselist=}
\for{i=1 to \Tot}{
 \text{caselist=\caselist
r\i,\posx[\i]x\posy[\i]}
}
\text{steps=item(1..\Tot,r1,r2,r3,r4,r5,r6,r7,r8,r9)}
\steps{\steps}
\statement{Rellenar la imagen con los objetos dados,
de manera que la suma de los elementos que limitan cada región coloreada
sea igual a \sum.
<p><center>
 \special{imagefill \bigimg,\Sizex \Sizey,\size
\caselist
}
</center>
}
\answer{Caja 1}{\r1;\obj[1]\redund}{type=dragfill}
\answer{Caja 2}{\r2;\obj[2]}{type=dragfill}
\answer{Caja 3}{\r3;\obj[3]}{type=dragfill}
\answer{Caja 4}{\r4;\obj[4]}{type=dragfill}
\answer{Caja 5}{\r5;\obj[5]}{type=dragfill}
\answer{Caja 6}{\r6;\obj[6]}{type=dragfill}
\answer{Caja 7}{\r7;\obj[7]}{type=dragfill}
\answer{Caja 8}{\r8;\obj[8]}{type=dragfill}
\answer{Caja 9}{\r9;\obj[9]}{type=dragfill}
\text{r=item(1..\Tot,\r1,\r2,\r3,\r4,\r5,\r6,\r7,\r8,\r9,\r10,\r11,\r12,\r13,\r14,\r15)}
\text{R=wims(replace internal \ by in \r)}
\text{t1=\sum}
\text{t2=\sum}
\text{t3=\sum}
\text{t4=\sum}
\text{t5=\sum}
\text{t6=\sum}
\for{t=1 to 8}{
 \text{t1=\conds[1;\t] notsametext?\t1-(\R[\conds[1;\t]])}
 \text{t2=\conds[2;\t] notsametext?\t2-(\R[\conds[2;\t]])}
 \text{t3=\conds[3;\t] notsametext?\t3-(\R[\conds[3;\t]])}
 \text{t4=\conds[4;\t] notsametext?\t4-(\R[\conds[4;\t]])}
 \text{t5=\conds[5;\t] notsametext?\t5-(\R[\conds[5;\t]])}
 \text{t6=\conds[6;\t] notsametext?\t6-(\R[\conds[6;\t]])}
}
\text{t1=simplify(\t1)}
\condition{Suma para la <font color=\colorlist[1]>región \colornamef[1]</font>
 = \sum}
 {\t1 notsametext and \t1=0}
\text{t2=simplify(\t2)}
\condition{Suma para la <font color=\colorlist[2]>región \colornamef[2]</font>
 = \sum}
 {\t2 notsametext and \t2=0}

\text{t3=simplify(\t3)}
\condition{Suma para la <font color=\colorlist[3]>región \colornamef[3]</font>
 = \sum}
 {\t3 notsametext and \t3=0}


\text{t4=simplify(\t4)}
\condition{Suma para la <font color=\colorlist[4]>región \colornamef[4]</font>
 = \sum}
 {\t4 notsametext and \t4=0}
