Created
August 4, 2014 05:32
-
-
Save jackliusr/ba84eee97aa46df6e44a to your computer and use it in GitHub Desktop.
Hackerrank Sherlock and The Beast 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
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