I don't have any code for you, but you can find several useful links here http://bioinformaticsonline.com/bookmarks/view/4098/bioinformatics-algorithm-demonstrations-and-tutorials which might help you to resolve the problems.
Note: If you are not...
I found some good resources from AI articles, specifically from McGill University's COMP-644 (Pattern Recognition) course.
http://cgm.cs.mcgill.ca/~godfried/teaching/pr-web.html