Skip to content

Instantly share code, notes, and snippets.

@bongster
Created August 22, 2014 13:30
Show Gist options
  • Save bongster/e7f50ba39215243f354a to your computer and use it in GitHub Desktop.
Save bongster/e7f50ba39215243f354a to your computer and use it in GitHub Desktop.
import java.io.FileInputStream
/**
* Created by bongster on 2014. 8. 22..
*/
object Main extends App{
def getM(point : List[Int]): List[Int] ={
// println(point)
List((point(2) + point(0)) / 2, (point(3) + point(1)) / 2)
}
System.setIn(new FileInputStream("sample.in"))
var cases = readLine().toInt;
while(cases > 0){
val pointNum = readLine().toInt;
var list:List[List[Int]] = Nil;
(0 until pointNum) foreach {n =>
val point = readLine().split(" ").toList.map(_.toInt)
list = list :+ point
}
val ml = list.map(getM(_))
//println(ml)
val ml2 = ml.reduce((a, b) => {
println("a : " + a)
println("b : " + b)
List(a(0) + b(0) , a(1) + b(1))
})
println(ml2)
cases = cases - 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment