Created
May 10, 2021 22:45
-
-
Save smartwatermelon/ef24ad01332426d4c073730071de2ae3 to your computer and use it in GitHub Desktop.
@cassidoo's Interview question of the week for May 10, 2021
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 | |
if [ $# -eq 0 ] || [ -n "$(printf '%s\n' "$1" | sed 's/[0-9]//g')" ]; then | |
echo "$(basename $0): enter a positive integer" | |
exit 1 | |
else | |
echo "$(basename $0): you entered $1" | |
fi | |
BASE=$1 | |
EXPONENT=3 | |
RESULT=$((BASE**EXPONENT)) | |
L_BASE=${#BASE} | |
L_RESULT=${#RESULT} | |
if [ "$L_BASE" == "$L_RESULT" ]; then | |
echo "Yes" | |
else | |
echo "Nah" | |
fi |
Author
smartwatermelon
commented
May 10, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment