-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsol.sh
executable file
·62 lines (49 loc) · 1020 Bytes
/
sol.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
INPUT=input.txt
if [ ! -f "$INPUT" ]
then
echo "$INPUT doesn't exist"
exit
fi
maxNum=0
DAY_DIRS=`ls . | grep day`
for dir in $DAY_DIRS
do
echo $dir
maxNum=$((maxNum+1))
done
printf "Choose the day (1 - $maxNum): "
valid=false
while [ $valid = false ]
do
read chosen_day
if [ $chosen_day -lt 1 ] || [ $chosen_day -gt $maxNum ]
then
echo "Invalid day chosen"
printf "Choose the day (1 - $maxNum): "
else
valid=true
fi
done
day=day"$chosen_day"
printf "Choose the part (1 - 2): "
valid=false
while [ $valid = false ]
do
read chosen_part
if [ $chosen_part -lt 1 ] || [ $chosen_part -gt 2 ]
then
echo "Invalid part chosen"
printf "Choose the part (1 - 2): "
else
valid=true
fi
done
part=Part"$chosen_part".java
path="$day"/src
cp $INPUT "$path"/input.txt
cd "$path"
javac -d ../../out/ "$part"
cd ../..
java -cp ./out/ "$path"/"$part"
rm -rf ./out/