Created
August 24, 2023 23:45
-
-
Save smartwatermelon/f1a345658d2308d8c3d193ccaaa8dde2 to your computer and use it in GitHub Desktop.
@cassidoo's interview question from August 20, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu -o pipefail | |
TRIES=0 | |
NUM="${RANDOM}" # 0-32767 | |
read -p "Your guess: " GUESS | |
(( TRIES+=1 )) | |
while [ $GUESS -ne $NUM ]; do | |
if [ $GUESS -lt $NUM ]; then | |
echo "guess higher!" | |
else | |
echo "guess lower!" | |
fi | |
read -p "Your guess: " GUESS | |
(( TRIES+=1 )) | |
done | |
echo "You got it in ${TRIES} guesses!" |
Author
smartwatermelon
commented
Aug 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment