Skip to content

Instantly share code, notes, and snippets.

@jackliusr
Created August 4, 2014 05:32
Show Gist options
  • Save jackliusr/ba84eee97aa46df6e44a to your computer and use it in GitHub Desktop.
Save jackliusr/ba84eee97aa46df6e44a to your computer and use it in GitHub Desktop.
Hackerrank Sherlock and The Beast implementation in Scala
import scala.math.BigInt
object Solution {
def main(args: Array[String]) {
val lines = io.Source.stdin.getLines().drop(1).toList
val nums = lines.map(l => l.toInt)
def decentNum(n: Int) : String ={
for( i <- (n to 0 by -1) ) {
if( i % 3 ==0 && (n -i) % 5 ==0 ) return ("5" * i + "3" * (n-i))
}
return "-1";
}
nums.foreach( n => println(decentNum(n)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment