!set title=Tres enteros II

!goto $wims_read_parm

:present
 Sean a,b,c tres enteros. El objetivo es calcular el valor de
 $goalname.
!exit

:form
 $goalname = <input size=3 name=ans1>
!exit

:ans
 La respuesta dada es que $goalname = $ans1.
 !ifval $ans1=$good1
  <font color=green>Es correct</font>.
 !else
  <font color=red>Está equivocado</font>: $goalname = $good1.
 !endif
!exit

:init
storename=a,b,c,goalname,range,e1,e2,e3,e4
objname=los números
hint=

range=100
a=!randint -$range,$range
b=!randint -$range,$range
c=!randint -$range,$range
goalname=!randitem a,b,c
good1=$($goalname)

parm1=a+b+c\
 a+b+c = \
 a+b+c = ??
val1=$[$a+($b)+($c)]
weight1=1
parm2=-a+b+c\
 -a+b+c = \
 -a+b+c = ??
val2=$[-($a)+($b)+($c)]
weight2=1
parm3=a-b+c\
 a-b+c = \
 a-b+c = ??
val3=$[$a-($b)+($c)]
weight3=1
parm4=a+b-c\
 a+b-c = \
 a+b-c = ??
val4=$[$a+($b)-($c)]
weight4=1

parmcnt=4
anscnt=1
minask=2

!distribute lines 1,1,1\
-1,1,1\
1,-1,1\
1,1,-1 into e1,e2,e3,e4

!exit

:info
!exit

:final
 gotcnt=!itemcnt $gotlist
 !if $gotcnt<$minask
  !exit
 !endif
 !bound ans1 between integer -1000,1000 default ??
 !for i in $gotlist
  pmat=!append line $(e$i) to $pmat
 !next i
 pmat=!translate $\
$ to ; in $pmat
 s=!positionof item $goalname in a,b,c
 diff=!exec pari A=[$pmat]; B=vecextract(A,7-2^($s-1)); print(matrank(A)-matrank(B))
 !if $diff<1
  speculate=yes
  !exit
 !endif
 !ifval $ans1=$good1
  thisscore=1
 !endif
!exit

