In Scala -
case class Student(name : String, fives: Int, tens: Int, twenties: Int) { override def toString = s"${name} -> ${worth}" def worth: Int = 5 * fives + 10 * tens + 20 * twenties } val students = List( Student("1", 5, 1, 4), Student("2", 5, 1, 4), Student("3", 5, 1, 4) ) val winner = students.maxBy(f => f.worth) val winners = (winner :: students.filter(f => f.worth == winner.worth)).distinct if (winners.size == students.size) println("all") else println(winner)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In Scala -