diff options
| author | Abigail <abigail@abigail.be> | 2021-03-17 20:08:55 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-03-17 20:14:49 +0100 |
| commit | de5f61d242597618622ab9d377d7fa6eca0f8c02 (patch) | |
| tree | 63f4d3a1fdf32a105ae07b53c81145e5d9c64919 /challenge-104/abigail/basic/ch-2.bas | |
| parent | c585402ac87611b8f92cae30fbe3e8e6be6f4394 (diff) | |
| download | perlweeklychallenge-club-de5f61d242597618622ab9d377d7fa6eca0f8c02.tar.gz perlweeklychallenge-club-de5f61d242597618622ab9d377d7fa6eca0f8c02.tar.bz2 perlweeklychallenge-club-de5f61d242597618622ab9d377d7fa6eca0f8c02.zip | |
BASIC solution for week 104, part 2
Diffstat (limited to 'challenge-104/abigail/basic/ch-2.bas')
| -rw-r--r-- | challenge-104/abigail/basic/ch-2.bas | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/challenge-104/abigail/basic/ch-2.bas b/challenge-104/abigail/basic/ch-2.bas new file mode 100644 index 0000000000..5cb6804e97 --- /dev/null +++ b/challenge-104/abigail/basic/ch-2.bas @@ -0,0 +1,54 @@ +0100 REM +0101 REM See ../README.md +0102 REM + +0200 REM +0201 REM Run as: basic.pl ch-2.bas +0202 REM + +1000 LET tokens = 12 +1010 LET maxtake = 3 + +1100 REM +1101 REM Print the prompt +1102 REM + +1110 PRINT "How many tokens do you take? ("; +1120 IF tokens < 10 THEN PRINT " "; +1130 PRINT tokens; +1140 PRINT "tokens are left) "; + + +1200 REM +1201 REM Read input and validate. Not going to work well if +1202 REM anything non-numeric is given as input. +1203 REM + +1210 INPUT ""; take +1220 IF take < 1 THEN 1100 +1230 IF take > maxtake THEN 1100 + +1300 REM +1301 REM Calculate the amount of tokens the computer is +1302 REM going to take, and print it. +1303 REM + +1310 LET takes = maxtake + 1 +1315 LET takes = takes - take +1320 PRINT "Computer takes "; +1330 PRINT takes; +1340 IF takes = 1 THEN PRINT "token" +1345 IF takes > 1 THEN PRINT "tokens" + +1400 REM +1401 REM Update the number of tokens, and check whether we're done. +1402 REM + +1410 tokens = tokens - 4 +1420 IF tokens <> 0 THEN 1100 + +1500 REM +1501 REM We have won the game! +1502 REM + +1510 PRINT "Computer wins" |
