final correct floyd solution with some prints