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

Current Trends in GIS and Remote Sensing(Ocean Applications)

Blog banner

IT RISK

Blog banner

Navigation With Indian Constellation(NavIC) by ISRO in Geographic Information Systems

Blog banner

E-Governance

Blog banner

Malware Defense

Blog banner

Is Pursuing a Dance Career in India Worth it?

Blog banner

Have You Explored India Yet?

Blog banner

Constrains in service design

Blog banner

Simple AI Symptom Diagnosis Using LISP – Rule-Based Expert System

Blog banner

Deadlock

Blog banner

TOP 5 GAMING GADGETS (2024)

Blog banner

Not anti-social, but pro-solitude

Blog banner

Data Visualization – Importance and tools (Tableau, Power BI)

Blog banner

Volatile Memory & Non-Volatile Memory Explained

Blog banner

Mutual exclusion

Blog banner

Risk mitigation and management

Blog banner

Fitness regime by Deepesh

Blog banner

Tiranga - Abbas Haveliwala

Blog banner

OS Evolution Achievements

Blog banner

Impacts of Data Breach On Companies Challenges and Prevention

Blog banner

Best password managers: Reviews of the top products

Blog banner

Internet of Things

Blog banner

Deadlock in operating system

Blog banner

Predictive Analysis - Ek Overview

Blog banner

DISK SCHEDULING

Blog banner

Raid

Blog banner

Understanding Endometriosis and Its Psychological Impact on Quality of Life

Blog banner

OS- Assignnment 1

Blog banner

Models of Information Security.

Blog banner

Data Warehouse Bus Matrix

Blog banner

A little bit of salt is all the hash needs!

Blog banner

Virtual Machine

Blog banner

Platonic Solids

Blog banner

Networking 101: How to Build Meaningful Connections in College

Blog banner

Sniffing: A Cyber Security Threat

Blog banner

Advantage of freedom

Blog banner

Modern Operating Systems.

Blog banner

Deadlock in operating system

Blog banner

PHISHING

Blog banner

Understanding Business Layer in Data Science

Blog banner

OPERATING SYSTEM OBJECTIVES AND FAULT TOLERENCE.

Blog banner

Top Career Paths After a B.Com Degree in Mumbai: What’s Next for You?

Blog banner