How to resolve the algorithm Guess the number/With feedback step by step in the EchoLisp programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Guess the number/With feedback step by step in the EchoLisp programming language
Table of Contents
Problem Statement
Write a game (computer program) that follows the following rules:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Guess the number/With feedback step by step in the EchoLisp programming language
Source code in the echolisp programming language
;;(read ) prompts the user with a default value using the browser dialog box.
;; we play sounds to make this look like an arcade game
(lib 'web) ; (play-sound) is defined in web.lib
(define (guess-feed (msg " 🔮 Enter a number in [0...100], -1 to stop.") (n (random 100)) (user 0))
(set! user (read user msg))
(play-sound 'ko)
(unless (eq? n user ) ; user is the last user answer
(guess-feed
(cond ;; adapt prompt according to condition
((not (integer? user)) "❌ Please, enter an integer")
(( < user 0) (error "🌵 - It was:" n)) ; exit to top level
((> n user) "Too low ...")
((< n user) "Too high ..."))
n user))
(play-sound 'ok )
" 🔮 Well played!! 🍒 🍇 🍓")
You may also check:How to resolve the algorithm Integer sequence step by step in the R programming language
You may also check:How to resolve the algorithm String concatenation step by step in the MAXScript programming language
You may also check:How to resolve the algorithm 100 doors step by step in the HolyC programming language
You may also check:How to resolve the algorithm Loops/While step by step in the Draco programming language
You may also check:How to resolve the algorithm Knuth shuffle step by step in the Phix programming language