Last active
April 26, 2019 13:13
-
-
Save sangkeon/378ebb82dad4edb5cb5cc0a063558781 to your computer and use it in GitHub Desktop.
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 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