Algorhithm works, doesn't work though

asdf