Skip to content

Instantly share code, notes, and snippets.

@SurajDadral
Created November 20, 2020 18:34
Show Gist options
  • Select an option

  • Save SurajDadral/7335a56fe5bd2dfccea6bec65f97fd0f to your computer and use it in GitHub Desktop.

Select an option

Save SurajDadral/7335a56fe5bd2dfccea6bec65f97fd0f to your computer and use it in GitHub Desktop.
Rex snippets
/* REXX */
say "I'm thinking of a number between 1 and 10."
secret = RANDOM(1,10)
tries = 1
do while (guess \= secret)
say "What is your guess?"
say "PS: Send 'Q' to exit"
pull guess
if (compare(guess, "Q") == 0) then
do
say "Exiting..."
exit
end
else if (DATATYPE(guess, "W") \= 1) then
do
say "That's not an integer number. Try again"
tries = tries + 1
end
else if (guess < 0 | guess > 10) then
do
say "What part of 1-10 did you not understand?"
say "That's not it. Try again"
tries = tries + 1
end
else if (guess \= secret) then
do
say "That's not it. Try again"
tries = tries + 1
end
end
say "You got it! And it only took you" tries "tries!"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment