File: puzzle.input

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (132 lines) | stat: -rw-r--r-- 3,944 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
!set anstype=yes
!!set anstyle=dprompt
!set ans_require=

!set author=Bernadette, Perrin-Riou
!if $wims_read_parm=def
  !exit
!endif
!reset nx ny taille width
!set answer=!lines2rows $(replygood$i)
!set answer=!lines2rows $answer
!set N=!replace internal x by , in $(answer[2;])
!set image=$(answer[1;])
!distribute items $N into ny, nx, width
!default nx=3
!default ny=3
!set nb_im=$[$nx*$ny]
!set taille=!replace internal x by , in $inputsize
!default taille=500,500
!set taille=$taille,100
!set cutx=!values $(taille[1])/$nx*x for x=0 to $nx
!set cuty=!values $(taille[2])/$ny*x for x=0 to $ny
!set cutx=!exec pari round([$cutx])
!set cuty=!exec pari round([$cuty])
!default width=$(cutx[2])
!set height=$[round($(cuty[2])/$(cutx[2])*$width)]
!set list=!makelist x for x=1 to $[($nx)*($ny)]
!set Zshuf=!shuffle $list
!set Zurl=
!set Zurl2=$list
!set Z2=$list
!set img_nb=!itemcnt $image
!if $img_nb=1
  !for t=1 to $nb_im
    !set s=$(Zshuf[$t])
    !set x=$[$s%$nx]
    !if $x=0
      !set x=$nx
    !endif
    !set y=$[($s-$x)/$nx+1]
    !readproc oef/draw.phtml $(cutx[2]),$(cuty[2])\
      copy 0,0,$(cutx[$x]),$(cuty[$y]),$(cutx[$x+1]),$(cuty[$y+1]),$image
    !set Zurl=!append item <img src="$ins_url" style="width:$(width)px" alt=""> to $Zurl
    !set Zurl2=!replace internal item number $s by <img src="$ins_url" style="width:$(width)px" alt=""> in $Zurl2
    !set Z2=!replace internal item number $s by $t in $Z2
  !next
!else
  !if text notwordof $(replyoption$i)
    !set Zurl2=!makelist <img src="$imagedir/x" style="width:$(width)px" alt=""> for x in $image
    !set Zurl =!makelist <img src="$imagedir/x" style="width:$(width)px" alt=""> for x in $image
  !else
    !set Zurl2=!makelist x for x in $image
    !set Zurl =!makelist x for x in $image
  !endif
!endif
!set oef_answer_option$i=$Z2\
$Zurl2\
$ny,$nx,$width,$height

:shuffle
!set scramble=!shuffle $list
!if $scramble issametext $list
  !goto shuffle
!endif

!read anstype/puzzle_css.inc

!if text notwordof $(replyoption$i)
  !set row_style=$empty
!else
  !set row_style=style="flex-wrap:wrap"
!endif

!for y=1 to $ny
  <div class="puzzle_row" $row_style>
  !for x=1 to $nx
    !set t=$[$x+($y-1)*($nx)]
    !set t_=!item $x+($y-1)*($nx) of $scramble
     <div class="puzzle_piece active" id="p$(i)_$t" onclick="javascript:click$i($t);" style="width:$(width)px;height:$(height)px">
      <div id="img$(i)_$(x)_$(y)">$(Zurl[$t_])</div>
     </div>
  !next x
  </div>
!next y

<script>
/*<![CDATA[*/
var fl_clic$i=false;
var tableurl$i=Array() ; var table$i=Array() ;
!for t=1 to $nb_im
  tableurl$i[$t]='$(Zurl[$(scramble[$t])])'
  table$i[$t]=$(scramble[$t])
!next
var nb_clic$i=0
function click$i(n)
{
  if (!fl_clic$i) //pour mmoriser le 1er click..
     {
      fl_clic$i=true;
      n_memo$i=n;
      document.getElementById('p$(i)_' + n).classList.add('selected');
     }
  else {
        newurl=tableurl$i[n];number=table$i[n];
        tableurl$i[n]=tableurl$i[n_memo$i]; table$i[n]=table$i[n_memo$i];
        tableurl$i[n_memo$i]=newurl;table$i[n_memo$i]=number;
        document.getElementById('p$(i)_' + n_memo$i).classList.remove('selected');
        fl_clic$i=false;
        if(n != n_memo$i){ nb_clic$i ++}
        for(var x=1;x<=$nx;x++) {
          for(var y=1;y<=$ny;y++) {
            document.getElementById('img$(i)_' + x + '_' + y).innerHTML=tableurl$i[x + (y-1)*($nx)];
          }
       }
    }
}
function sendanswer$i()
  { var reply=table$i[1] ; var replyurl=tableurl$i[1] ;
     if (nb_clic$i < 1 ) {document.getElementById('oefvar$i').value=''}
     else {
       for (var t = 2 ; t <= $nb_im ; t ++){
         reply = reply + ',' + table$i[t] ;
         replyurl = replyurl + ',' + tableurl$i[t] ;
       }
       document.getElementById('oefvar$i').value=reply + ';' + replyurl + ';' + nb_clic$i
     }
  }
/*]]>*/
</script>
<input type="hidden" name="reply$i" id="oefvar$i" value="">

!set oef_js_submit=$oef_js_submit; sendanswer$i()