diff --git a/Bash-arith/README.md b/Bash-arith/README.md new file mode 100644 index 0000000..0072e77 --- /dev/null +++ b/Bash-arith/README.md @@ -0,0 +1,23 @@ +# Bash Arithmetic Lab +Make a shell script that performs * operations with the flags -a -b, +i.e. +``` +./math -a 1 -b 2 +>>> 2 +./math -a 4 -b 8 +>>> 32 +``` + +## Assesment Language +Bash + +## Autograder Language +Python + +## Autograding Environment Packages +Python3 + +## Hand-in Format +`math.sh` + + diff --git a/Bash-arith/autograde-Makefile b/Bash-arith/autograde-Makefile new file mode 100644 index 0000000..f004e5a --- /dev/null +++ b/Bash-arith/autograde-Makefile @@ -0,0 +1,9 @@ +all: + tar xvf autograde.tar + tar xvf handin.tar + cp math.sh test_autograder + + (cd test_autograder; python3 driver.py) + +clean: + rm -rf *~ test_autograder diff --git a/Bash-arith/autograde.tar b/Bash-arith/autograde.tar new file mode 100644 index 0000000..6def71b Binary files /dev/null and b/Bash-arith/autograde.tar differ diff --git a/Bash-arith/math.sh b/Bash-arith/math.sh new file mode 100755 index 0000000..80d1573 --- /dev/null +++ b/Bash-arith/math.sh @@ -0,0 +1,12 @@ +#!/usr/bin/bash + +while getopts a:b: flag +do + case "${flag}" in + a) X=${OPTARG};; + b) Y=${OPTARG};; + esac +done + +echo $((X * Y)) + diff --git a/Bash-arith/refsol.tar b/Bash-arith/refsol.tar new file mode 100644 index 0000000..2e46db2 Binary files /dev/null and b/Bash-arith/refsol.tar differ diff --git a/Bash-arith/refsol/math.sh b/Bash-arith/refsol/math.sh new file mode 100755 index 0000000..80d1573 --- /dev/null +++ b/Bash-arith/refsol/math.sh @@ -0,0 +1,12 @@ +#!/usr/bin/bash + +while getopts a:b: flag +do + case "${flag}" in + a) X=${OPTARG};; + b) Y=${OPTARG};; + esac +done + +echo $((X * Y)) + diff --git a/Bash-arith/test_autograder/driver.py b/Bash-arith/test_autograder/driver.py new file mode 100644 index 0000000..a84566b Binary files /dev/null and b/Bash-arith/test_autograder/driver.py differ diff --git a/Bash-arith/test_autograder/tests.py b/Bash-arith/test_autograder/tests.py new file mode 100644 index 0000000..e529f3f --- /dev/null +++ b/Bash-arith/test_autograder/tests.py @@ -0,0 +1,6 @@ +tests = [ + ["Basic", [1, 2, 2]], + ["Zero", [0, 4, 0]], + ["Identity", [1, 8, 8]], + ["Large", [123456789, 2, 246913578]] +]