8-Bit Software Online Conversion
Puzzle Answer - Listing
10DEFFNS="Answer"
20MODE7
30PRINT"100 People. £100. Men get £10
."'"Women get .50p. Children get 12.5p."
40PRINT"How many men women and childr
en?"
50PRINT"Working"
60TIME=0
70DIM S%(100,3)
80FORC%=1TO100
90S%(C%,1)=RND(9)
100S%(C%,2)=RND(100-S%(C%,1))
110S%(C%,3)=100-S%(C%,1)-S%(C%,2)
120NEXT
130REPEAT
140Z=RND(-TIME)
150A=0:B=0
160FORC%=0TO100
170T=10*S%(C%,1)+.5*S%(C%,2)+.125*S%(C
%,3)
180IF T=100 A=C%:B%=-1
190IF ABS(100-A)>ABS(100-T) A=T:A%=C%
200IF ABS(100-B)>ABS(100-T) AND T<>A B
=T:B%=C%
210NEXT
220IFB%<1 B%=A%
230IF A=100 B=100:B%=A% ELSE IF B=100
A=100:A%=B%
240FORX%=1TO3:S%(0,X%)=(S%(A%,X%)+S%(B
%,X%))/2:S%(1,X%)=S%(A%,X%):S%(2,X%)=S%(
B%,X%):NEXT
250IF10*S%(0,1)+.5*S%(0,2)+.125*S%(0,3
)=100 A=100:A%=0
260IF (A<>100 AND B<>100) FORC%=3TO100
:S%(C%,1)=ABS(S%(0,1)+(RND(3)-2)*RND(2))
:REPEATS%(C%,2)=ABS(S%(0,2)+(RND(3)-2)*R
ND(30)):S%(C%,3)=100-S%(C%,1)-S%(C%,2):U
NTILS%(C%,3)>0:NEXT
270UNTILA=100 OR B=100
280PRINT;S%(A%,1)" - Men"
290PRINT;S%(A%,2)" - Women"
300PRINT;S%(A%,3)" - Children"
310PRINT"Time taken - ";INT(TIME/100)"
seconds."