E-Book Content
The Alien, Numbereater and other Programs for Personal Computers
Some other computing books from the Macmillan Education Press
Beginning BASIC P. E. Gosling Continuing BASIC P. E. Gosling Microprocessors and Microcomputers Eric Huggins A Practical Introduction to Pascal I. R. Wilson and A. M. Addyman
The Alien, Numberea ter and other Programs for Personal Computers John Race Senior Lecturer, Department of Computer Science Brunei University
©JohnRace 1981 All rights reserved. No part of this publication may be reproduced or transmitted, in any form or by any means, without permission
Firstpublishedl981 by THE MACMILLAN PRESS LTD
London and Basingstoke Associated companies in Delhi Dublin Hong Kong Johannesburg Lagos Melbourne New York Singapore and Tokyo ISBN 978-0-333-28079-9 ISBN 978-1-349-05175-5 (eBook) DOI 10.1007/978-1-349-05175-5
The paperback edition of this book is sold subject to the condition that it shall not, by way of trade or otherwise, be lent, resold, hired out, or otherwise circulated without the publisher's prior consent in any form of binding or cover other than that in which it is published and without a similar condition including this condition being imposed on the subsequent purchaser
Contents Introduction Palindromes Brackets Orbit Pascal's Triangle Superlife Double Density Histograms Spiral Program Remover Prime? Playfair The Alien General Input Program Clear Numbereater Appendix: Amendments to Programs for later PETs with revised ROMs Index
2
4 8 13
25
26 39 45
50
61
62
67 71 75 77
80
83
Introduction From the age of sixteen we can own machines which are physically much more powerful than we are. A Victorian engine driver would have been quite shocked and alarmed at the way young people can now afford to buy, and are allowed to drive, weird conveyances that are more convenient and efficient than his. His engine was far too complex and expensive for amateurs. To some extent, the older generation of computer users look upon the mass market in home computers with the same shocked alarm as the Victorian engine driver would have viewed the moped - even to the extent of denying that the new machine was a real vehicle at all. But now you can buy, and you should buy as soon as you can, a machine - the home computer - which can outperform some of your mental muscles, as the moped outperforms your leg muscles. Of course you are its superior in many other ways. Unlike it, you can reason by analogy, think laterally, use your imagination. But it can calculate quickly and precisely, follow specified procedures without deviating by accident or impulse, and write and draw tirelessly. A teacher of the old school would certainly call such abilities mental ones, and award high marks to pupils who showed them. What is happening is that, just as we had to learn to accept, and then enjoy, the fact that machines could be stronger than us, so we must now learn how to accept and enjoy the intellectual powers of computers, which in general happily complement our own. Again, the motorbike overcomes air resistance and friction more spectacularly than we can, but needs us to balance it and direct it. Similarly a computer will beat us in following defined logical and mathematical procedures, but needs us to set the problem and define the procedures. Then, together, we can set off and travel far afield for enjoyment and profit. This book is for people - students, teachers, or just enthusiasts, at home or in school or college. It is intended as a source of ideas for projects, a series of examples of techniques and applications, and a comfort to those who, like the author, write programs too often that do not work properly, and who then brood over our shortcomings and try to discover more relia