Thoughtworks interview question

The most difficult part was both logic and code test.