add implementation using stdin, algs4 from Princeton site