The algorithm kinda works but still very sketchy, the tests are passing though