\input methode
\message{ok}%
%\input dutch.sty
%\lefthyphenmin62
%\righthyphenmin62
\catcode`\@11\relax
\mathchardef\oc@mma="013B %{\mathord`,}
\mathchardef\pc@mma="613B %{\mathpunct`,}
\mathcode`\,="8000      % active character in math mode
{\catcode`\,=\active    % what should a ',' do in math mode ?
 \gdef,{\obeyspaces\futurelet\next\sm@rtcomma}}
 % note that ',' is only active until this definition is done!
 \def\sm@rtcomma{\if\space\next\pc@mma\else\oc@mma\fi}
\catcode`\@12\relax
\input epsf
\input pstricks
% rough approximation
\def\colorlet#1[#2]#3{%
\expandafter\let\csname\string\color@#1\expandafter\endcsname\csname\string\color@#3\endcsname
\message{defining color #1: \expandafter\meaning\csname\string\color@#1\endcsname}%
}
\input pst-plot
\input fp
\FPmessagesfalse
\input vec2d
\input antw
\frenchspacing
\def\d{{\rm d}}
\def\frac#1#2{{#1 \over #2}}
\newcount\cx
\newcount\dx
\newcount\punten
\newcount\bonuspunten
\newcount\opgaveno
\newcount\vraagno
\newcount\sub
\newcount\werkbladno
\newcount\antwoordno
\newif\ifopgstart
\newdimen\vraagin
\newdimen\opgavein
\newdimen\twocolwidth
\newdimen\threecolwidth
\newdimen\fourcolwidth
\newdimen\colsep
\newdimen\colht
\newskip\opgaveskip
\newskip\lastvraagskip
\newdimen\currin
\bonuspunten=0
\punten=0
\opgaveno=0
\werkbladno=0
\antwoordno=0
\parindent0pt 
\def\totaalpunten{?}%
\def\totaalbonuspunten{0}%
\def\totaalpaginas{0}%
\def\alph#1{\ifcase#1
  a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or
  n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else
  \errmessage{te veel subvragen (alfabet is op!)}\fi
}%
\def\lazypar{\par}%
\def\col#1{%
  \hbox to#1{\hskip\vraagin
    \localvraag{\csname tmpct\romannumeral\cx\endcsname}%
    \expandafter\expandafter\ifnum\csname tmpbon\romannumeral\cx\endcsname=0
    	\localpunten{\csname tmppt\romannumeral\cx\endcsname}%
    \else
        \localbonuspunten{\csname tmppt\romannumeral\cx\endcsname}%
	{\bf BONUS:}
    \fi
    \csname tmptx\romannumeral\cx\endcsname\hfil
  }%
}%
\def\setfourcol{%
  \cx=\sub\dx=0\loop\advance\cx by-4\advance\dx by1\ifnum\cx>0\repeat
  %\message{fourcol #1, \the\sub}
  \advance\sub by-\dx
  \advance\sub by-\dx
  \advance\sub by-\dx
  \cx=0
  \loop
    \advance\cx by1
    \noindent
    \ifopgstart\localopgave\opgstartfalse\fi
    {%
      \currin=\vraagin
      \col\fourcolwidth
      \currin0pt
      \hfill
      \advance\cx by\dx
      \col\fourcolwidth
      \hfill
      \advance\cx by\dx
      \col\fourcolwidth
      \hfill
      \advance\cx by\dx
      \ifnum\sub>0\col\fourcolwidth\else\hbox to\fourcolwidth{\hfil}\fi
    }%
    \lazypar
    \advance\sub by-1
  \ifnum\cx<\dx
  \repeat
  \sub=0
}%
\def\setthreecol{%
  \cx=\sub\dx=0\loop\advance\cx by-3\advance\dx by1\ifnum\cx>0\repeat
  \advance\sub by-\dx
  \advance\sub by-\dx
  \cx=0
  \loop
    \advance\cx by1
    \noindent
    \ifopgstart\localopgave\opgstartfalse\fi
    {%
      \currin=\vraagin
      \col\threecolwidth
      \currin0pt
      \hfill
      \advance\cx by\dx
      \col\threecolwidth
      \hfill
      \advance\cx by\dx
      \ifnum\sub>0\col\threecolwidth\else\hbox to\threecolwidth{\hfil}\fi
    }%
    \lazypar
    \advance\sub by-1
  \ifnum\cx<\dx
  \repeat
  \sub=0
}%
\def\settwocol{%
  \cx=\sub\dx=0 \loop\advance\cx by-2\advance\dx by1\ifnum\cx>0\repeat
  \advance\sub by-\dx
  \cx=0
  \loop
    \advance\cx by1
    \noindent
    \ifopgstart\localopgave\opgstartfalse\fi
    {%
      \currin=\vraagin
      \col\twocolwidth
      \currin0pt
      \hfill
      \advance\cx by\dx
      \ifnum\sub>0\col\twocolwidth\fi
    }%
    \lazypar
    \advance\sub by-1
  \ifnum\cx<\dx
  \repeat
  \sub=0
}%
\def\setonecol{%
  \advance\leftskip\vraagin
  \currin=\vraagin
  \cx=1
  \loop
    \noindent
    \ifopgstart\localopgave\opgstartfalse\fi
    \localvraag{\csname tmpct\romannumeral\cx\endcsname}%
    \expandafter\expandafter\ifnum\csname tmpbon\romannumeral\cx\endcsname=0
    	\localpunten{\csname tmppt\romannumeral\cx\endcsname}%
    \else
        \localbonuspunten{\csname tmppt\romannumeral\cx\endcsname}%
	{\bf BONUS:}
    \fi
    \csname tmptx\romannumeral\cx\endcsname\lazypar
    \advance\sub by-1
    \advance\cx by1
  \ifnum\sub>0
  \repeat
  \currin0pt
  \leftskip=\opgavein
}%
\def\checkvrgout{%
  \everypar={}%
  \ifnum\sub>0
    \cx=0
    \colsep=0pt
    \colht=0pt
    \loop
      \advance\cx by1
      \setbox0=\hbox{\hskip\vraagin \csname tmptx\romannumeral\cx\endcsname}%
      \ifdim\wd0>\colsep\colsep\wd0\fi
      \ifdim\ht0>\colht\colht\ht0\fi
    \ifnum\cx<\sub\repeat
    \ifdim\colsep<\twocolwidth
      % als de vragen extra hoog zijn; gebruik sneller en meer kolommen
      \ifdim\ht0>1cm
	\ifdim\colsep<\threecolwidth
	  \ifdim\colsep<\fourcolwidth
	    \ifnum\sub=4
	      \setfourcol
	    \else
	      \ifnum\sub=8
	        \setfourcol
              \else
		\ifnum\sub=7
		  \setfourcol
		\else
	          \ifnum\sub>9
		    \setfourcol
		  \else
		    \ifnum\sub>2
		      \setthreecol
		    \else
		      \settwocol
		    \fi
		  \fi
		\fi
              \fi
	    \fi
	  \else
	    \ifnum\sub>4
	      \setthreecol
	    \else
	      \ifnum\sub=3
	        \setthreecol
	      \else
	        \settwocol
	      \fi
	    \fi
	  \fi
	\else
          \settwocol
	\fi
      \else
        \ifnum\sub>5
          \settwocol
        \else
          \setonecol
        \fi
      \fi
    \else
      \setonecol
    \fi
  \fi
}%
\long\def\opgave#1\par{%
  \checkvrgout
  \opgstarttrue
  \advance\opgaveno by1
  \vraagno=-1
  \sub=0
  \ifnum\opgaveno>1\goodbreak\vskip\opgaveskip\fi
  \currin0pt
  \leftskip=\opgavein
  \everypar={\global\everypar={}\localopgave\opgstartfalse}%
}%
\long\def\vraag#1p #2\par{%
  \advance\vraagno by1
  \advance\punten by#1
  \ifnum\vraagno=1\immediate\write\aux{%
    \string\def\string\notsingle\romannumeral\opgaveno{}}\fi
  \expandafter\ifx\csname notsingle\romannumeral\opgaveno\endcsname\relax
    \noindent
    \localpunten{#1}%
    #2
    \par
  \else
    \advance\sub by1
    \expandafter\def\csname tmppt\romannumeral\sub\endcsname{#1}%
    \expandafter\edef\csname tmpct\romannumeral\sub\endcsname{\the\vraagno}%
    \expandafter\def\csname tmptx\romannumeral\sub\endcsname{#2}%
    \expandafter\def\csname tmpbon\romannumeral\sub\endcsname{0}%
    \everypar={\checkvrgout\vskip\lastvraagskip\indent}%
  \fi
}%
\long\def\bonusvraag#1p #2\par{%
  \advance\vraagno by1
  \advance\bonuspunten by#1
  \ifnum\vraagno=1\immediate\write\aux{%
    \string\def\string\notsingle\romannumeral\opgaveno{}}\fi
  \expandafter\ifx\csname notsingle\romannumeral\opgaveno\endcsname\relax
    \noindent
    \localbonuspunten{#1}%
    {\bf BONUS:} #2
    \par
  \else
    \advance\sub by1
    \expandafter\def\csname tmppt\romannumeral\sub\endcsname{#1}%
    \expandafter\edef\csname tmpct\romannumeral\sub\endcsname{\the\vraagno}%
    \expandafter\def\csname tmptx\romannumeral\sub\endcsname{#2}%
    \expandafter\def\csname tmpbon\romannumeral\sub\endcsname{1}%
    \everypar={\checkvrgout\vskip\lastvraagskip\indent}%
  \fi
}%
\long\def\werkblad#1\par{%
  \advance\werkbladno by1
  \expandafter\def\csname werkbladcontent\romannumeral\werkbladno\endcsname{#1}%
  \expandafter\edef\csname werkbladopg\romannumeral\werkbladno\endcsname{\the\opgaveno}%
  \advance\sub by-1
  \expandafter\edef\csname werkbladsub\romannumeral\werkbladno\endcsname{\the\sub}%
  \advance\sub by1
}%
\long\def\antwoord#1\par{%
  \advance\antwoordno by1
  \expandafter\def\csname antwoordcontent\romannumeral\antwoordno\endcsname{#1}%
  \expandafter\edef\csname antwoordopg\romannumeral\antwoordno\endcsname{\the\opgaveno}%
  \advance\sub by-1
  \expandafter\edef\csname antwoordsub\romannumeral\antwoordno\endcsname{\the\sub}%
  \advance\sub by1
}%
%
% read info from previous run
\def\firstrun{1}%
\newread\aux
\openin\aux \jobname.aux
\ifeof\aux\else\def\firstrun{0}\input\jobname.aux\fi
\closein\aux
\newwrite\aux
\immediate\openout\aux=\jobname.aux % two pass info file
\outer\def\bye{\checkvrgout
  \immediate\write\aux{\string\def\string\totaalpunten{\the\punten}}%
  \immediate\write\aux{\string\def\string\totaalbonuspunten{\the\bonuspunten}}%
  \immediate\write\aux{\string\def\string\totaalpaginas{\the\count0}}%
  \par\vfill
  \ifnum\werkbladno>0\ifnum\firstrun=0\break\localwerkblad\vfil\fi\fi
  \ifnum\antwoordno>0\ifnum\firstrun=0\break\localantwoord\vfil\fi\fi
  \supereject\end}%
\def\unit#1{\ \hbox{\rm #1}}%
\def\tabel#1{\vskip1ex\def\\{\vadjust{\hrule}\cr}\noindent\hskip2cm\vbox{\offinterlineskip\halign{\strut\ \ ##\hfil\ \ &&\vrule height11pt\ \ $##$\ \ \cr#1\crcr}}\vskip1ex}%
\def\vgttabel#1{\vskip1ex\def\\{\vadjust{\hrule}\cr}\noindent\hskip2cm\vbox{\offinterlineskip\halign{\strut\ \ ##\hfil\ \ \vrule height11pt\hskip1pt&&\vrule height11pt\ \ $##$\ \ \cr#1\crcr}}\vskip1ex}%
\def\vgttabelnomath#1{\vskip1ex\def\\{\vadjust{\hrule}\cr}\noindent\hskip2cm\vbox{\offinterlineskip\halign{\strut\ \ ##\ \ \hfil\vrule height11pt\hskip1pt&&\vrule height11pt\ \ ##\ \ \cr#1\crcr}}\vskip1ex}%
\def\assenstelselnietxy#1#2#3#4#5#6{%
  \SpecialCoor
  \psset{unit=.71cm}%
  \FPset{border}{.2}%
  \FPsub{\xmin}{#3}{\border}%
  \FPsub{\ymin}{#4}{\border}%
  \FPadd{\xmax}{#5}{\border}%
  \FPadd{\ymax}{#6}{\border}%
  \pspicture(\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmax},\FPprint{\ymax})%
    \psclip{\pspolygon[linestyle=none](\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmin},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymin})}%
      \psgrid[subgriddiv=0,gridlabels=0,gridwidth=.2pt](!#3 1 sub #4 1 sub)(!#5 1 add #6 1 add)%
      \psline[linewidth=.6pt](0,\FPprint{\ymin})(0,\FPprint{\ymax})%
      \psline[linewidth=.6pt](\FPprint{\xmin},0)(\FPprint{\xmax},0)%
      \rput[tr](0,-.1){$\scriptscriptstyle O$}%
      \psset{framesep=1pt}%
      % plaats getallen bij de x-as
      \FPset{\cur}{#3}%
      \loop
        \FPclip{\cur}{\cur}%
        \FPifzero{\cur}\else
          \rput*[t](\FPprint{\cur},-.1){$\scriptscriptstyle \FPprint{\cur}$}%
        \fi
        \FPadd{\cur}{\cur}{1}%
      \FPiflt{\cur}{\xmax}\repeat
      % plaats getallen bij de y-as
      \FPset{\cur}{#4}%
      \loop
        \FPclip{\cur}{\cur}%
        \FPifzero{\cur}\else
          \rput*[r](-.1,\FPprint{\cur}){$\scriptscriptstyle \FPprint{\cur}$}%
      \fi
      \FPadd{\cur}{\cur}{1}%
      \FPiflt{\cur}{\ymax}\repeat
    \endpsclip
  \rput[b](0,\FPprint{\ymax}){$\scriptstyle #2$}%
  \rput[l](\FPprint{\xmax},0){$\scriptstyle #1$}%
}
\def\assenstelsel#1#2#3#4{%
  \SpecialCoor
  \psset{unit=.71cm}%
  \FPset{border}{.2}%
  \FPsub{\xmin}{#1}{\border}%
  \FPsub{\ymin}{#2}{\border}%
  \FPadd{\xmax}{#3}{\border}%
  \FPadd{\ymax}{#4}{\border}%
  \pspicture(\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmax},\FPprint{\ymax})%
    \psclip{\pspolygon[linestyle=none](\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmin},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymin})}%
      \psgrid[subgriddiv=0,gridlabels=0,gridwidth=.2pt](!#1 1 sub #2 1 sub)(!#3 1 add #4 1 add)%
      \psline[linewidth=.6pt](0,\FPprint{\ymin})(0,\FPprint{\ymax})%
      \psline[linewidth=.6pt](\FPprint{\xmin},0)(\FPprint{\xmax},0)%
      \rput[tr](0,-.1){$\scriptscriptstyle O$}%
      \psset{framesep=1pt}%
      % plaats getallen bij de x-as
      \FPset{\cur}{#1}%
      \loop
        \FPclip{\cur}{\cur}%
        \FPifzero{\cur}\else
          \rput*[t](\FPprint{\cur},-.1){$\scriptscriptstyle \FPprint{\cur}$}%
        \fi
        \FPadd{\cur}{\cur}{1}%
      \FPiflt{\cur}{\xmax}\repeat
      % plaats getallen bij de y-as
      \FPset{\cur}{#2}%
      \loop
        \FPclip{\cur}{\cur}%
        \FPifzero{\cur}\else
          \rput*[r](-.1,\FPprint{\cur}){$\scriptscriptstyle \FPprint{\cur}$}%
      \fi
      \FPadd{\cur}{\cur}{1}%
      \FPiflt{\cur}{\ymax}\repeat
    \endpsclip
  \rput[b](0,\FPprint{\ymax}){$\scriptstyle y$}%
  \rput[l](\FPprint{\xmax},0){$\scriptstyle x$}%
}
\def\endassenstelsel{\endpspicture}%
\def\plotgrafiek#1{%
  \psclip{\pspolygon[linestyle=none](\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmin},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymin})}%
    \psplot[linewidth=.8pt]{\FPprint{\xmin}}{\FPprint{\xmax}}{#1}%
  \endpsclip
}%
\def\plotcurve#1{%
  \psclip{\pspolygon[linestyle=none](\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmin},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymin})}%
    \pscurve[linewidth=.8pt]#1%
  \endpsclip
}
% xmin, xmax, ymin, ymax, psunit
\def\tsnlruitjes#1#2#3#4#5{%
  \SpecialCoor
  \psset{unit=#5}%
  \FPset{border}{.2}%
  \FPset{xmin}{#1}\FPset{xmax}{#2}\FPset{ymin}{#3}\FPset{ymax}{#4}%
  \FPset{xscl}{1}%
  \FPset{yscl}{1}%
  \FPifzero\xmin\else\FPsub{\xmin}{\xmin}{\border}\fi
  \FPifzero\xmax\else\FPadd{\xmax}{\xmax}{\border}\fi
  \FPifzero\ymin\else\FPsub{\ymin}{\ymin}{\border}\fi
  \FPifzero\ymax\else\FPadd{\ymax}{\ymax}{\border}\fi
  \pspicture(\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmax},\FPprint{\ymax})%
    \psclip{\pspolygon[linestyle=none](\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmin},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymin})}%
      \psgrid[subgriddiv=0,gridlabels=0,gridwidth=.2pt](!#1 1 sub #3 1 sub)(!#2 1 add #4 1 add)%
  \endpsclip
  \rput[tr](0,-.1){$\scriptscriptstyle O$}%
}%
\def\tsnlhoraxis#1#2#3{%
  \psline[linewidth=.6pt](\FPprint{\xmin},0)(\FPprint{\xmax},0)%
  \psset{framesep=1pt}%
  \FPdiv\xscl{\xscl}{#2}%
  \FPmul\xscl{\xscl}{#1}%
  \FPround\xscl{\xscl}{5}%
  % plaats getallen bij de as
  \FPset{\cur}{0}\FPset{\curi}{0}%
  \loop
    \FPadd{\cur}{\cur}{#1}\FPadd{\curi}{\curi}{#2}%
    \FPclip{\cur}{\cur}\FPclip{\curi}{\curi}%
    \FPiflt{\cur}{\xmax}
      \rput*[t](\FPprint{\cur},-.15){$\scriptscriptstyle \FPprint{\curi}$}%
    \repeat
  \FPset{\cur}{0}\FPset{\curi}{0}%
  \loop
    \FPsub{\cur}{\cur}{#1}\FPsub{\curi}{\curi}{#2}%
    \FPclip{\cur}{\cur}\FPclip{\curi}{\curi}%
    \FPifgt{\cur}{\xmin}
      \rput*[t](\FPprint{\cur},-.15){$\scriptscriptstyle \FPprint{\curi}$}%
    \repeat
  \rput[l](\FPprint{\xmax},0){$\scriptstyle #3$}%
}%
\def\tsnlveraxis#1#2#3{%
  \psline[linewidth=.6pt](0,\FPprint{\ymin})(0,\FPprint{\ymax})%
  \rput[b](0,\FPprint{\ymax}){$\scriptstyle #3$}%
  \FPdiv\yscl{\yscl}{#2}%
  \FPmul\yscl{\yscl}{#1}%
  \FPclip\yscl{\yscl}%
  \FPround\yscl{\yscl}{5}%
  \psset{framesep=1pt}%
  % plaats getallen bij de as
  \FPset{\cur}{0}\FPset{\curi}{0}%
  \loop
    \FPadd{\cur}{\cur}{#1}\FPadd{\curi}{\curi}{#2}%
    \FPclip{\cur}{\cur}\FPclip{\curi}{\curi}%
    \FPiflt{\cur}{\ymax}
      \rput*[r](-.15,\FPprint{\cur}){$\scriptscriptstyle \FPprint{\curi}$}%
    \repeat
  \FPset{\cur}{0}\FPset{\curi}{0}%
  \loop
    \FPsub{\cur}{\cur}{#1}\FPsub{\curi}{\curi}{#2}%
    \FPclip{\cur}{\cur}\FPclip{\curi}{\curi}%
    \FPifgt{\cur}{\ymin}
      \rput*[r](-.15,\FPprint{\cur}){$\scriptscriptstyle \FPprint{\curi}$}%
    \repeat
}%
\def\tsnlfunctie#1{%
  \psclip{\pspolygon[linestyle=none](\FPprint{\xmin},\FPprint{\ymin})(\FPprint{\xmin},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymax})(\FPprint{\xmax},\FPprint{\ymin})}%
    \psplot[linewidth=.8pt]{\FPprint{\xmin}}{\FPprint{\xmax}}{x \xscl\space div #1 \yscl\space mul}%
  \endpsclip
}%
\def\tsnlruitjesend{\endpspicture}%
