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

Apache Kafka

Blog banner

Efficiency of SQL Injection Method in Preventing E-Mail Hacking

Blog banner

What is OS Fingerprinting?

Blog banner

Introduction to Data Science: Life Cycle & Applications

Blog banner

Direct Memory Access

Blog banner

Risk management in IT

Blog banner

INDIAN CHEAPEST COSMETICS BRAND

Blog banner

What is Brute Force Attack? How to defend against it?

Blog banner

Starvation

Blog banner

Solving Problems with AI: The Power of Search Algorithms

Blog banner

Swiggi

Blog banner

The launch of UniMap by HERE

Blog banner

Europe Through My Lens

Blog banner

Memory Management

Blog banner

Dove’s Real Beauty Campaign- Case Study

Blog banner

38_Network Sniffing Techniques_SBC

Blog banner

Artificial Intelligence (AI)

Blog banner

PYTHON

Blog banner

THREADS (assignment 1)

Blog banner

Topic: Sessions in Operating system

Blog banner

Virtual memory in Operating System

Blog banner

Satellite Based Positioning

Blog banner

Assignment-3

Blog banner

Types of threads

Blog banner

Memory Management

Blog banner

Time Series Analysis

Blog banner

Improving the Accuracy of GPS and GNSS

Blog banner

Fashion design

Blog banner

SECURITY RISKS OF REMOTE WORKING

Blog banner

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

Blog banner

Health and fitness

Blog banner

Different types of e-commerce platforms or advantages and disadvantages

Blog banner

RAID

Blog banner

File sharing

Blog banner

MAHAKAL LOK UJJAIN

Blog banner

The art of being alone

Blog banner

BIRYANI ! The history you never knew about

Blog banner

Memory Management - operating system

Blog banner

Cloud Forensic Tools And Storage :A Review Paper

Blog banner

Raid

Blog banner

Spotify

Blog banner

POSITIVE ATTITUDE IN LIFE

Blog banner