Skip to content

Instantly share code, notes, and snippets.

@sangkeon
Last active April 26, 2019 13:13
Show Gist options
  • Save sangkeon/378ebb82dad4edb5cb5cc0a063558781 to your computer and use it in GitHub Desktop.
Save sangkeon/378ebb82dad4edb5cb5cc0a063558781 to your computer and use it in GitHub Desktop.
object Solution extends App {
def solve (number:String) = {
var bigNum = "".toList;
var smallNum = "".toList;
number.foreach( c => {
if(c == '4') {
bigNum = '1' :: bigNum;
smallNum = '3' :: smallNum
} else {
bigNum = c :: bigNum
smallNum = '0' :: smallNum
}
})
bigNum = bigNum.reverse
smallNum = smallNum.reverse.dropWhile(c => c == '0')
(bigNum.mkString, smallNum.mkString);
}
val n = readInt()
for( a <- 1 to n){
val input = readLine()
val (output1, output2) = solve(input)
println( f"Case #$a: $output1 $output2");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment