Code with the removal of duplications and with execution of all given test cases