Last active
August 29, 2015 14:17
-
-
Save fancellu/07fbd9b78f10ec2e4212 to your computer and use it in GitHub Desktop.
Quick coding test. Given tasks to people, find person with most tasks, that finished first
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Broken apart to ease understanding. | |
val s1=Seq(1,1,1,2,2,2,3,3,3,3,4,4,4,4,1) | |
val groups=s1.groupBy { identity } | |
val sizes=groups.mapValues { _.size} | |
val maxSize=sizes.values.max | |
val maxUsers=sizes.filter(_._2==maxSize).keys.toSet | |
val pop=s1.filter(maxUsers).zipWithIndex | |
val lastPlaces=pop.groupBy(_._1).mapValues(_.last) | |
val quickest=lastPlaces.values.minBy(_._2)._1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment