bewerking=bewerking2.proc
!if $taal=nl
    nivo_title=Een fiets tochtje.
    fietstijd=fietstijd in minuten
    ADRESSEN=adressen
    dingen=!randitem kranten,brieven,uitnodigingen,rekeningen,oliebollen,bloemstukjes,bestellingen
!else
    nivo_title=A bicycle tour
    fietstijd=bicycle time in minutes
    ADRESSEN=adresses
    dingen=!randitem letters,newspapers,magazins,deliveries,parcels,invitations

!endif
n=$teller
bewegen=1
min=5
max=10
HLINE=$empty
VLINE=$empty
VTEXT=$empty
HTEXT=$empty
LIJN=$empty
adressen=!randint $min,$max
goedewoorden=min,minuten,minutes,minute

!if $graad=0
    R=$teller
!else
    R=$graad
!endif        
!for p=1 to $adressen
     getal$p=!randint 5,40
     getallen=!append item $(getal$p) to $getallen
!next p

getallen=!sort numeric item  $getallen
ymax=!item -1 of $getallen

!for p=1 to $adressen
    A=!item $[$p-1] of $getallen
    B=!item $p of $getallen
    LIJN=!append line line $[$p-1],$A,$p,$B,red to $LIJN
    HLINE=!append line dline 0,$A,$[$adressen+1],$A,blue to $HLINE
    HLINE=!append line dline 0,$B,$[$adressen+1],$B,blue to $HLINE
    VTEXT=!append line text black,-0.5,$A,normal,$A to $VTEXT
    VTEXT=!append line text black,-0.5,$B,normal,$B to $VTEXT
    VLINE=!append line dline $p,0,$p,$[$ymax+1],blue to $VLINE
    HTEXT=!append line text black,$[0.1+$p],-0.3,normal,$p to $HTEXT
!next

zoveel=!item $adressen of $telwoorden
!if $taal=nl
    zij=!randitem zij,hij
    !if $zij=zij
	namen=!record 43 of woorden.$taal
	naam=!randitem $namen
	haar=haar
    !else
	namen=!record 42 of woorden.$taal
	naam=!randitem $namen
	haar=zijn
    !endif    
    somtekst$n=<b><em>$naam</b></em> gaat met de fiets $zoveel adressen langs.<br>\
    Je ziet hier de grafiek van $haar fietstocht.<p align=left>
!else
    zij=!randitem she,he
    !if $zij=she
	namen=!record 43 of woorden.$taal
	naam=!randitem $namen
	haar=her
    !else
	namen=!record 42 of woorden.$taal
	naam=!randitem $namen
	haar=his
    !endif    
    somtekst$n=<b><em>$naam</b></em> is bicycling past $zoveel adresses.<br>\
    Here you see the graph of $haar tour.<p align=left>
!endif


plaatje$n=300,300\
transparent white\
xrange -1,$[$adressen+1]\
yrange -2,$[$ymax+1]\
linewidth 3\
hline 0,0,blue\
vline 0,0,blue\
arrow -0.6,$[$ymax-10],-0.6,$[$ymax-1],10,red\
linewidth 1\
$HLINE\
$VLINE\
linewidth 4\
$LIJN\
$VTEXT\
$HTEXT\
textup black,-1,10,huge,$naam 's $fietstijd\
text black,5,-0.9,huge,$ADRESSEN\
arrow 2,0.5,$[$adressen-1],0.5,10,red


!if $R=1
    GOED$n=$ymax
    !if $taal=nl
	opgave$n=lees uit de grafiek hoeveel minuten $naam in't totaal heeft gefietst.
	antwoord$n=$naam heeft in het totaal $ymax minuten gefietst over deze $zoveel adressen.
    !else
	opgave$n=Read from the graph the total bicycling time of $naam .
	antwoord$n=$naam has bicycled $ymax minutes over $zoveel adresses.
    !endif
!endif

!if $R=2
    p=!randint 1,$[$adressen-1]
    GOED$n=!item  $p of $getallen
    P=!item $p of $rangwoorden
    !if $taal=nl
	opgave$n=lees uit de grafiek af in hoeveel minuten $zij van startpunt\
	 adres 0 naar adres $p is gefietst.
	antwoord$n=$naam is in $(GOED$n) minuten naar het $P adres gefietst.  
    !else
	opgave$n=Read from the graph the total bicycling time in minutes of $naam \
	from startpoint adres 0 to adres $p .
	antwoord$n=$naam has bicycled $(GOED$n) minutes from start adress to the $P adress .  
    !endif
!endif

!if $R=3
    p=!randint 1,$[$adressen-1]
    AA=!item $[$p+1] of $getallen
    BB=!item $p of $getallen
    GOED$n=$[$AA-$BB]
    !if $taal=nl
	opgave$n=lees uit de grafiek af in hoeveel minuten $zij van adres $p naar adres $[$p+1] is gefietst.
	antwoord$n=Over de afstand tussen adres $p en $[$p+1] \
	heeft $zij dus $AA - $BB minuten = $(GOED$n) minuten gefietst.
    !else
	opgave$n=read from the graph the bicycling time of $naam from adress $p to adress $[$p+1] .
	antwoord$n=$zij mastered the distance between adress $p en $[$p+1] \
	in $AA - $BB minutes = $(GOED$n) minutes bicycling time.
    !endif
!endif

!if $R>3
    extra=
    hoeveel=!listuniq $getallen
    hoeveel=!itemcnt $hoeveel
    !if $taal=nl
	!if $hoeveel=$adressen
	    GOED$n=nee
	    antwoord$n=Nee, volgens de grafiek zijn er geen adressen zo dicht bijelkaar dat ze er in "nul" minuten naar toe kon fietsen.
	!else
    	    !for p=1 to $adressen 
    		AA=!item $p of $getallen
		BB=!item $[$p+1] of $getallen
		!if $AA=$BB
		    extra=!append item $p,$[$p+1] to $extra
		!endif
	    !next p
	    extra=!listuniq $extra
    	    GOED$n=ja
	    antwoord$n=Ja, volgens de grafiek zijn liggen adressen <em><b>$extra</b></em> zo dicht bijelkaar dat ze er in "nul" minuten naar toe kon fietsen
	!endif
        opgave$n=Lagen er volgens de grafiek twee of meerdere adressen zo dicht bij elkaar<br>\
	dat $zij niet eens op $haar fiets hoefde te stappen? ?<br>\
        En zo ja ,welke nummers hebben deze twee (of meerdere) adressen.<br><small>\
	Noteer je antwoord in die gevallen als<br> <em>ja hoor adres 1 en 2 en adres 5 en\
	 adres 6</em><br> of sneller...<br> <em>ja 1,2,5,6</em><br></small>
    !else
	!if $hoeveel=$adressen
	    GOED$n=no
	    antwoord$n=No, according to the graph there are no adresses that close that $zij could master the distance in zero (0) minutes.
	!else
    	    !for p=1 to $adressen 
    		AA=!item $p of $getallen
		BB=!item $[$p+1] of $getallen
		!if $AA=$BB
		    extra=!append item $p,$[$p+1] to $extra
		!endif
	    !next p
	    extra=!listuniq $extra
    	    GOED$n=yes
	    antwoord$n=yes, according the graph the adresses <em><b>$extra</b></em> are so close the $zij did not even have to get on $haar bike
	!endif
        opgave$n=Are there according to the graph, one or more adresses so close to eachother that $zij doesn't\
	have to get on $haar bike?<br>\
	And if "yes", at which adresses was this the case? <br><small>\
	<ul>\
	<li>Attention: you don't have to guess; use the integers of the x-axis\
	<li>write your answers like:\
	<ul><li> yes on adresses  1 and 4 and 8\
	<li>or shorthand : yes, 1,4,8\
	<li>or naturally : no </ul></ul>

    !endif
!endif
