!Fred v.Q7a dp-j 29Oct95 3PM Cursor keys to scroll up/down Subject:- Chris's ANSWER ref. 8BS-45 * * LIGHT ENTERTAINMENT * * * * LIGHT ENTERTAINMENT * * Well really Chris! I ran ANSWER, got bored, made a coffee, thought about the problem, wrote the program, went back to the Master and STILL had to wait for it to finish. I do hope your ambulance has a better algorithm under the bonnet or it's in for a 'stiff' dose of Brady- Cardia. OK, OK, so that's my copy of 8BS-46 up the spout. (That's true -Ed.) * * IN THE DARK * * The problem posed gives two equations as follows :- a) m + w + c = 100 and b) 10m + .5w + .125c = 100 Two equations and three unknowns: m, w and c (the number of men, women and children respectively). So algebra is out, well nearly, and it's back to trial and error. The most obvious points are :- 1) m has to be <10 (To leave some cash for the others) 2) Even if there ain't any children, with m=5 it would need 100 women to make up the `100 total, and that's already too many people (105) So m>5. 3) c must be a multiple of 4 as the total amount for the children must be a multiple of 50p else it would be impossible to end up with `100 exactly. 4) c cannot be >96 (Too many people for `100 total). We could refine the possible range of values still further but the algorithm for computer solution is so simple that it can be counter productive to introduce further conditions. The listing is a nested FOR/NEXT loop :- F.c=4TO96S.4:F.m=6TO9:IF10*m+.5*(100-m-c) +.125*c=100 P.'m" men"'100-m-c" women"'c" children" ELSE N.:N. Yes that's it! A one-liner. * * THE SWITCH ON * * Start the ambulance Chris and forget the de-caffeinated. No time to hang about. 100 TachyCardias on the way; a `10 tip from the men, 50p from....... To see the answer:- …Press Q/q and…COPY the above one-liner now, then …Press f0 to return to this text. * * SEARCH LIGHTS * * OK Chris? You also asked if there was a way of finding other variations. Just run the one-liner as above with the =100 changed to =101.5 or whatever. Also change the 10*m to 8*m (`8 each), and/or the .50*(100-m-c) to say :- .75*(100-m-c) to give 75p to the women. Change this 100 to say 85 for fewer people in total... etc, etc. You may or may not get an answer. If not you may have to change the FOR loop limits or STEP value to accord with the numbers that you select, as I did at the start. Or maybe you found an impossible one! (Some values may of course make it tedious to solve by hand, see PENCIL TORCH below). Press…Q/q and…COPY the one-liner again but type a line number first, say 10. The program will now stay permanently in memory so you can then…RUN, LIST etc and play around with the variables. …f0 to get back to text, or…f5 after a mode change. * * SEEN THE LIGHT? * * Anyone spot the lulu? What about the ELSE in the one-liner? It means the search stops as soon as an answer is found. Maybe there is more than one answer? To find out remove ELSE and write it in normal Basic line format.(The one-liner will not perform without the ELSE ). Think about it! Try this:- 10V.14 20F.c=4TO96S.4:F.m=6TO11 30x=10*m+.5*(100-m-c)+.125*c 40IFx>=100 AND x<=120 P.'m" men, ";100-m-c" women, ";c" children = ` ";x 50N.:N.:V.15 This gives all the solutions for total sums of money from `100 to `120. Note the wider m range, 6-11, and when it's run notice the negative women! Nothing unusual about that. Mathematics is never wrong, just canny. At least I can imagine two universes, one full of positive women, the other with negative ones. You chance your luck by falling through the 'The Black Hole' megapub. Could make an arcade game! …Q/q, (NEW), COPY program, RUN etc. then…f0 to return here. or…f5 after a mode change. Bet you're sorry you asked. Best get on to the game. OVER TO YOU. * * PENCIL TORCH * * Forget the computer. Take a look at this nearly-algebra I mentioned at the start of this lot. Multiply equation a) by 10 :- 10m + 10w + 10c = 1000 and subtract equation b) 10m + .5w + .125c = 100 We get:- 9.5w + 9.875c = 900 By sheer good fortune this tells us that w and c must be numerically nearly the same value since their coefficients 9.5 and 9.875 are similar. Their mean value will be roughly 900/(9.5+9.875) = 46.45 Now the guessing:- Say c=44 (nearest multiple of 4 to 46.45 ) and w=47 (a bit bigger) to give mean value = (44+47)/2=45.5. A bit low perhaps but carry on. check 9.5*47 + 9.875*44 = 881 No joy, should be 900. Try c=44 w=49 Mean =46.5, that's better check 9.5*49 + 9.875*44 = 900 Voila, j'ai got eet! So the answer is c=44 w=49 m=(100-44-49)=7. Now to be rigorous (mortis, already?) we should also do a few checks with c a bit bigger (=48) than w, to make sure there isn't another solution to this equation. But I'll leave that to you. Lemma. If I've convinced you that for overall speed and simplicity you don't need to bother with that computer ..... donations gratefully accepted. * * MOON SHINE * * I wonder why our schools do all that Shakespeare crap? Big deal; so '...... Birnam wood do come to Dunsinane.'? Very inane. Typical lefty trick to confuse the ambulance drivers and put the Health Service in schtuck, if you ask me. And he was useless with Assembler did you know? The fool couldn't think in a straight line and you should see his algorithms, all out of step with his metre;ruddy Euro nonsense, obviously he started it all. Give him 25.4mm and he was kilometre-ing through Agincourt, and flogging our lamb up a Venetian canal in dollops of 0.4535924 kg to some damn Shylock. And all that depraved bit about Pistol loading his revolver. We can well do without the sex stuff. Oh, excuse me, here's the Avon lady...... Where was I? Ahem, yes. Our educationalists should tailor the curriculum to concise logical thought disciplines and away with all the arty crafty, irrational, bow-legged deviousness. Or as Shakespeare himself, on finally seeing the light, said, albeit rather circuitously as usual, What manner of man be this Whose orbs do hang in parenthesis? thus clearly dangling a testimonial to the supremacy of the sciences. In view of this celebrated admission I challenge our Education Minister to ˆ illuminate‰ her own viewpoint.