Created
December 20, 2021 14:54
-
-
Save hexaflexahexagon/e6ff44020629703d3feee15f990e2df7 to your computer and use it in GitHub Desktop.
# Give a, b, and c, solve a quadratic equation using the public heroku quadratic API
This file contains 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
#!/bin/bash | |
# Give a, b, and c, solve a quadratic equation using the public heroku quadratic API | |
load() { | |
echo $output | python3 -c "import sys, json; print(json.load(sys.stdin)['$1'])" | |
} | |
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then | |
echo "Usage: $0 a b c" | |
echo "Where ax^2 + bx + c" | |
exit -1 | |
fi | |
output=$(curl -s "https://quadratic-solver-api.herokuapp.com/?a=$1&b=$2&c=$3") | |
if ! [[ $(echo $output | grep message) == "" ]]; then | |
echo "Error: "$(load 'message') | |
exit -1 | |
fi | |
echo "The function is: "$(load 'function') | |
echo "The roots are "$(load 'roots' | awk '{print $2, $4}' | tr -d } | sed 's/,/ and/g') | |
echo "The vertex is "$(load 'vertex' | awk '{print $2, $4}' | tr -d }) | |
echo "It opens "$(load 'parabolaOpening') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment