Working through some algorithms