-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrote do homework and integrated all the other scripts to play nice w…
…ith argv/
- Loading branch information
uberj
committed
Dec 2, 2011
1 parent
bcb3c51
commit e4759b8
Showing
5 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
do_problem2 () { | ||
solutions=0 | ||
for ((i=0; i<$2; i++)) | ||
do | ||
for ((j=0; j<$3; j++)) | ||
do | ||
echo "Knights tour with initial move ($i, $j)" | ||
python knights_tour.py $1 $i $j | ||
if [ $? -eq 0 ] | ||
then | ||
solutions=$((solutions+1)) | ||
fi | ||
echo | ||
done | ||
done | ||
echo "There were $solutions successful tours out of $1 attempts." | ||
echo | ||
} | ||
|
||
echo "====================================================" | ||
echo "====================================================" | ||
echo "Problem 2 and 3 . Test your program by using as starting square each of the 25 squares on a 5 by 5 gameboard. How many tours did it find?" | ||
echo "====================================================" | ||
do_problem2 5 5 5 | ||
|
||
echo "====================================================" | ||
echo "====================================================" | ||
echo "Problem 4. Run your program from 4 different initial squares on a 6 by 6 gameboard. Does your program always find a tour? Are the tours you found open or closed? How many different tours does your program?" | ||
echo "====================================================" | ||
do_problem2 6 2 2 | ||
|
||
echo "====================================================" | ||
echo "====================================================" | ||
echo "Problem 4. Run your program from 4 different initial squares on a 8 by 8 gameboard. Does your program always find a tour? Are the tours you found open or closed? How many different tours does your program?" | ||
echo "====================================================" | ||
do_problem2 8 2 2 |
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
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