Created
July 29, 2016 11:34
-
-
Save waynejo/5d604066e64335d3967a86bc0022d3b8 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
package Main | |
import java.io.{FileInputStream, FileOutputStream} | |
import scala.annotation.tailrec | |
import scala.io.StdIn | |
object Main extends App { | |
Console.setIn(new FileInputStream("example.in")) | |
Console.setIn(new FileInputStream("A-small-practice.in")) | |
Console.setOut(new FileOutputStream("A-small-practice.out")) | |
Console.setIn(new FileInputStream("A-large-practice.in")) | |
Console.setOut(new FileOutputStream("A-large-practice.out")) | |
def solve(inputs:String): String = { | |
(inputs.head.toString /: inputs.tail)((acc, x) => | |
if (acc.head > x) acc + x else x + acc | |
) | |
} | |
val cases = StdIn.readLine().toInt | |
(1 to cases) foreach { i => { | |
val inputs = StdIn.readLine() | |
println(s"Case #$i: ${solve(inputs)}") | |
}} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment