%% This file is generated by preprocessor!
%% Do not edit it by hand.
%% Edit the source file cpp/sides.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{5: V}
 \integer{tot=3}
 \integer{Tot=5}
 \text{posx=-2,-1,0,1,2}
 \text{posy=1,0,-1,0,1}
 \text{first=2,3,4}
 \text{conds=1,2,3;5,4,3}
 \integer{xstep=65}
 \integer{ystep=80}
 \integer{xrange=2}
 \integer{yrange=1}
 \text{colorname=\colornamef}
 \text{lname=línea}
 \text{de=de la}
\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(2*\smin..2*\smax):\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{py=}
\for{t=1 to \condcnt}{
 \text{cond=\conds[\t;]}
 \text{py=\py
lines \colorlist[\t],\posx[\cond[1]],\posy[\cond[1]],\posx[\cond[2]],\posy[\cond[2]],\posx[\cond[3]],\posy[\cond[3]]
}
}
\text{border=0.3}
\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
 \py
)}
\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,r10,r11,r12,r13,r14,r15)}
\steps{\steps}
\statement{Rellenar la imagen con los objetos dados,
de manera que la suma de cada \lname 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}
\answer{Caja 10}{\r10;\obj[10]}{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=simplify(\sum-(\R[\conds[1;1]])-(\R[\conds[1;2]])-(\R[\conds[1;3]]))}
\condition{Suma \de <font color=\colorlist[1]>\lname \colorname[1]</font>
 = \sum}
 {\t1 notsametext and \t1=0}
\text{t2=simplify(\sum-(\R[\conds[2;1]])-(\R[\conds[2;2]])-(\R[\conds[2;3]]))}
\condition{Suma \de <font color=\colorlist[2]>\lname \colorname[2]</font>
 = \sum}
 {\t2 notsametext and \t2=0}
