added smarter solution, added problem definition