working ratio algorithm and added testcases