add third problem and scala solution