Skip to content

Instantly share code, notes, and snippets.

@jackliusr
Created August 3, 2014 15:38
Show Gist options
  • Save jackliusr/17db458dc16e6d408c6b to your computer and use it in GitHub Desktop.
Save jackliusr/17db458dc16e6d408c6b to your computer and use it in GitHub Desktop.
hackerrank Manasa and Stones implementation in Scala
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