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

Direct Memory Access

Blog banner

Simple Ways of Avoiding Basic Mistakes in Smart Phone Security

Blog banner

Fitness regime by Deepesh

Blog banner

TECHNOLOGY : BOON OR CURSE ?

Blog banner

Process states

Blog banner

Advantage of freedom

Blog banner

IT GOVERNANCE

Blog banner

MailChimp

Blog banner

THREADS (assignment 1)

Blog banner

?Why Does My Breath Still Smell After Brushing?

Blog banner

semaphores

Blog banner

AOL Mail

Blog banner

Device driver

Blog banner

Models of Information Security.

Blog banner

Severe landslides continue to cause concern in Joshimath, Uttarakhand

Blog banner

Phishing

Blog banner

Palm Vein Biometric Technology; Contactless vein authentication

Blog banner

WHAT IS TWITTER AND HOW DOES IT WORK

Blog banner

The Everyday Parenting Dilemma: Safety Vs Independence

Blog banner

IP Address

Blog banner

10 Interesting Facts about Attack on Titan

Blog banner

It's all about our Brain.- The Brain Metaphor

Blog banner

Process in OS

Blog banner

Microsoft powerpoint presentation

Blog banner

5 ways to save money on catering services in Mumbai

Blog banner

Toothache at night? What does this mean, and how to cope with it?

Blog banner

Threat management

Blog banner

The application udemy

Blog banner

INTRANET

Blog banner

USPS mail

Blog banner

Dos (Denial of service) Attack

Blog banner

Shoulders

Blog banner

JUSTICE FOR EVERY “BEZUBAAN ANIMAL”

Blog banner

Virtual Memory

Blog banner

Friendship

Blog banner

Place to visit in pune

Blog banner

Threat from Inside: Educating the Employees Against Cyber Threats

Blog banner

Explain the concept of ( MIS) Management information systems

Blog banner

Risk management in IT

Blog banner

10 Types of Friends in every friend group

Blog banner

Pro-Tips On How To Keep your Foot Healthy

Blog banner

HOW CAN SOCIAL MEDIA MAKE YOU HAPPIER?

Blog banner