Added MiniScript port of 64_Nicomachus

This commit is contained in:
JoeStrout
2023-01-28 23:08:55 -07:00
parent 099368a269
commit 0a1bea9e03
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
Conversion to [MiniScript](https://miniscript.org).

View File

@@ -0,0 +1,45 @@
// Nicomachus
// originally by David Ahl
// Ported from BASIC to MiniScript by Joe Strout, 2023
print " "*33 + "NICOMA"
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
print; print; print
print "Boomerang puzzle from Arithmetica of Nicomachus -- A.D. 90!"
// Get a yes/no (or at least y/n) response from the user.
askYesNo = function(prompt)
while true
answer = input(prompt)
a1 = answer.lower[:1]
if a1 == "y" or a1 == "n" then return a1
print "Eh? I don't understand '" + answer + "' Try 'yes' or 'no'."
end while
end function
doOne = function
print
print "Please think of a number between 1 and 100."
A = input("Your number divided by 3 has a remainder of: ").val
B = input("Your number divided by 5 has a remainder of: ").val
C = input("Your number divided by 7 has a remainder of: ").val
print
print "Let me think a moment..."
print
wait 1.5
D = 70*A + 21*B + 15*C
D = D % 105 // gets the remainder after dividing by 105
yesNo = askYesNo("Your number was " + D + ", right? ")
if yesNo == "y" then
print "How about that!"
else
print "I feel your arithmetic is in error."
end if
end function
// Main loop -- press Control-C to break
while true
doOne
print
print "Let's try another."
end while