wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

Number Guessing game --lisp

profile
Rohan undefined
Jul 16, 2025
0 Likes
0 Discussions
2 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

Mumbai Metro 3

Blog banner

Booting Process In Operating System

Blog banner

Data Acquisition in Cyber Forensics

Blog banner

Data Analytics in Data Science

Blog banner

Deadlock and Starvation

Blog banner

Can a Water Flosser Replace Manual Flossing? Here’s What Dentists Say

Blog banner

Multiple processor scheduling

Blog banner

Worms, viruses and Bots

Blog banner

Multiprocessor and Multicore Organization

Blog banner

Clarizen

Blog banner

Data Lake

Blog banner

SNAPCHAT

Blog banner

Continual service improvement vs maintenance phase in IT

Blog banner

DIGITAL TECHNOLOGY

Blog banner

How can parents support a child’s mental health?

Blog banner

Device driver

Blog banner

Why Personalized Return Gifts Are the Perfect Choice for Every Kid’s Birthday Party?

Blog banner

Child labour

Blog banner

I/O Buffering

Blog banner

MODERN OPERATING SYSTEM

Blog banner

Uniprocessor and Types

Blog banner

Starvation

Blog banner

Top 4 Places To Stay In Copenhagen

Blog banner

Theads

Blog banner

TECHNOLOGY : BOON OR CURSE ?

Blog banner

Different Types of Data

Blog banner

Im Photographer

Blog banner

I/O Buffering

Blog banner

THE LEGAL ISSUES OF COMPUTER FORENSICS IN INDIA

Blog banner

Business Engineering

Blog banner

Process, process creation and process termination

Blog banner

Music is life

Blog banner

COMFORT IS ALL ABOUT FASHION

Blog banner

Severe landslides continue to cause concern in Joshimath, Uttarakhand

Blog banner

Synchronization

Blog banner

Memory input output management

Blog banner

Deadlock

Blog banner

Deadlock and starvation

Blog banner

Technological Advancement

Blog banner

Building a Better You: Fitness Tips and Inspiration.

Blog banner

Real time scheduling

Blog banner

How to lose belly fat

Blog banner