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

Deadlock and starvation

Blog banner

Kernel Modes: User Mode vs. Kernel Mode - 80

Blog banner

Decoding the Weave — How to Identify Original Patola Art on a Fabric

Blog banner

Amazon

Blog banner

The Right way of cooking

Blog banner

Earth with no trees

Blog banner

Meshoo

Blog banner

Android Application Components and Activity Lifecycle

Blog banner

What Makes Patola the Queen of Silk?

Blog banner

Instagram

Blog banner

TEAMWORK

Blog banner

Why Skipping Afternoon Meals Affects More Than Just Your Hunger?

Blog banner

operating system

Blog banner

Understanding Univariate, Bivariate, and Multivariate Analysis in Data Science

Blog banner

10 Amazing facts about Tokyo Ghoul

Blog banner

IOT- Internet Of Things

Blog banner

Ethical Hacking

Blog banner

Security in Operating Systems

Blog banner

The Truth Behind Viral DIY Dental Hacks

Blog banner

Some web vulnerabilities

Blog banner

SQL Injection

Blog banner

Heart Fulness Meditation

Blog banner

E-Cash (Electronic Cash)

Blog banner

10 Survival Tips that might save your life

Blog banner

Cyber Forensics

Blog banner

Race Condition in Operating Theatre

Blog banner

The Golden Temple , Amritsar

Blog banner

Salt, Sand, and Smiles: Does the Maroubra Lifestyle Affect Your Enamel?

Blog banner

Uniprocessor scheduling

Blog banner

Who decides your overthinking, anyway?

Blog banner

Save Environment

Blog banner

Uber

Blog banner

Working with Sniffers for monitoring network communication

Blog banner

Digital marketing spotlight “Dove’s Real Beauty Campaign”

Blog banner

21ST CENTURY PATRIARCHY

Blog banner

Blockchain Security Technique

Blog banner

Busted : Common Web Security Myths

Blog banner

Human factor, a critical weak point in the information security of an organization’s IOT

Blog banner

Exploring Human Factors in Cyber Forensics Investigations.

Blog banner

Service Design Principles

Blog banner

Blog name

Blog banner

Mobile Security

Blog banner