wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

Number Guessing game --lisp

profile
Rohan undefined
Jul 16, 2025
0 Likes
0 Discussions
0 Reads

Program (Raw):


(defun ask (question)

(format t "~%~A (yes/no): " question)

(force-output)

(let ((response (read-line)))

(string= (string-downcase response) "yes")))


(defun guess-number (low high)

(let ((mid (floor (+ low high) 2)))

(cond

((> low high)

(format t "~%Hmm, something went wrong! Are you sure you're answering honestly?"))

((ask (format nil "Is your number ~A?" mid))

(format t "~%🎉 Yay! I guessed your number: ~A" mid))

((ask (format nil "Is your number greater than ~A?" mid))

(guess-number (+ mid 1) high))

(t

(guess-number low (- mid 1))))))


(defun start-game ()

(format t "~%Think of a number between 1 and 100. I will try to guess it!")

(guess-number 1 100))


(start-game)




Comments ()


Sign in

Read Next

Women Empowerment

Blog banner

Uniprocessor scheduling

Blog banner

Virtual Memory - Explaination, Working, Steps

Blog banner

operating system

Blog banner

Direct Memory Access

Blog banner

(Input/Output) in os

Blog banner

A small world of Sockets

Blog banner

A Tourist’s Guide To Florida’s Rodeo Culture: What To Expect At The Arcadia Championship Rodeo

Blog banner

VIRUS

Blog banner

Security issues in Sensor Networks and gathering admissible evidence in Network Forensics

Blog banner

Lemon and Chilli Pickle (Limbu Mirchi Achar)

Blog banner

Concurrency and Deadlocks

Blog banner

Severe landslides continue to cause concern in Joshimath, Uttarakhand

Blog banner

Mesh Topology

Blog banner

My Favorite Sportsperson

Blog banner

Raid and levels of raid.

Blog banner

PPT methodology

Blog banner

Why am I never satisfied with my Life?

Blog banner

Platonic Solids

Blog banner

Types of email

Blog banner

Virtual Machine

Blog banner

Data Lake

Blog banner

Apache Spark :- Powerful Data Processing Tool

Blog banner

Race Condition

Blog banner

VIRTUAL MEMORY

Blog banner

Deadlocks in Operating Systems

Blog banner

Google

Blog banner

Session Hijacking Techniques

Blog banner

Fault Tolerance

Blog banner

Knowledge Management in Continual Service improvement (CSI)

Blog banner

Decoding Confusion Matrix

Blog banner

"Games and the future"

Blog banner

Mumbai local ......

Blog banner

Human Error: The weakest link in Cybersecurity

Blog banner

Deadlocks

Blog banner

The Essential Guide to Dynamic Arrays vs. Linked Lists: Which to Use and When ?

Blog banner

Article on different management system

Blog banner

PERSONALITY DEVELOPMENT

Blog banner

Veg/Non-veg/Egg Tiffin Meals That Are Nutritious and Filling

Blog banner

Memory

Blog banner

Cache Memory

Blog banner

Image Steganography: Hiding Secrets in Plain Sight

Blog banner