Tell us what’s happening:
I can’t seem to pass the script tests, despite outputting the correct results.
Part of my code, under a spoiler since it’s a required project:
Check the data type of the input value
if [[ “$1” =~ [1]+$ ]]; then
# Integer case: Search by atomic number
ATOMIC_NUMBER=$($PSQL “SELECT atomic_number FROM elements WHERE atomic_number = $1”)
# Symbol case: Search by symbol
elif [[ $1 =~ [2]{1,2}$ ]]; then
ATOMIC_NUMBER=$($PSQL “SELECT atomic_number FROM elements WHERE symbol = ‘$1’”)
# Name case: Search by name
elif [[ $1 =~ [3]{3,40}$ ]]; then
ATOMIC_NUMBER=$($PSQL “SELECT atomic_number FROM elements WHERE name = ‘$1’”)
fi
check if element was found
if [[ -z $ATOMIC_NUMBER ]]; then
echo -e “\nI could not find that element in the database.”
exit 1
fi
[…]
echo -e “\nThe element with atomic number $ATOMIC_NUMBER is $NAME ($SYMBOL). It’s a $TYPE, with a mass of $MASS amu. $NAME has a melting point of $MELTING_POINT celsius and a boiling point of $BOILING_POINT celsius.”
else
echo -e “\nPlease provide an element as an argument.”
fi
Can provide more snippets, or full code if needed.
I’ve run ./elements several times with the same result:
Tried with He:
Tried with non-existent elements:
Did it with no argument:
Still:
Tried refreshing, closing, restarting PC.
The code might look a bit messy, I tried rewriting several parts several times already, and switching approaches.
Any help or suggestions would be appreciated, thank you!
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0
Challenge Information:
Periodic Table Database - Build a Periodic Table Database