Created
August 3, 2014 15:38
-
-
Save jackliusr/17db458dc16e6d408c6b to your computer and use it in GitHub Desktop.
hackerrank Manasa and Stones implementation in Scala
This file contains 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
object Solution { | |
def main(args: Array[String]) { | |
val lines = io.Source.stdin.getLines().drop(1).toList | |
val tcs = lines.map(l => l.toInt).grouped(3) | |
def resolve(steps: Int, a: Int, b: Int) : List[String] = { | |
val maxs = (0 to steps ).map(n => n * a + (steps -n) * b) | |
maxs.distinct.sorted.toList.map(n => n.toString) | |
} | |
tcs.foreach(c => println( resolve(c(0) -1,c(1),c(2)).mkString(" ") )) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment