# the actual value the program is looking for (we pretend that the guess function is unaware of this variable)
TRUE_VALUE=$(($(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -d' ' -f1) % 100))



# $1 should be the guess
# using echo as return is for little skibidi toilets, hence im using error codes
# (this function is implemented for testing purposes)
submit() {
    echo "guess: $1"
    # Too big
    if (( $1 < TRUE_VALUE )); then
        return -1 # overflows to 255

    elif (( $1 > TRUE_VALUE )); then
        return 1

    elif [[ $1 -eq $TRUE_VALUE ]]; then
        return 0

    else
        while true; do
            printf "crazy? i was crazy once. they put me in a room. a rubber room. a rubber room with rats. the rats made me ..."
        done
    fi

}

guess() {
  # I was initially planning to do a perfectly suboptimal search (binary search, but guessing all values in the wrong direction before proceeding), but then it occurred to me... i couldn't be bothered
  for i in {0..100}; do

    submit $i

    if [[ $? -eq "0" ]]; then
        echo "welp that was fun, im off"

        return 0
    fi
  done
}

guess
