[ create a new paste ] login | about

Link: http://codepad.org/Das6rGZH    [ raw code | fork ]

Plain Text, pasted on Nov 4:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
object Ibm {
    def get_list(n: Int, r: Double) = {
        def process_coord(t: (Int, Int)) : List[(Double, Int)] = t match {
            case (x,y) => {
                val base_angle = Math.atan2(y,x)
                val delta_angle = Math.asin(r / (Math.sqrt (x*x + y*y)))
                List((base_angle - delta_angle, 1), (base_angle + delta_angle, -1))
            }
            case _ => List()
        }
        val res = (for (x <- 0 until n;
                        y <- 0 until x 
                        if (x * x + y * y < n * n) && (x * x + y * y > 0)) yield (x,y)).flatMap(process_coord)
        res
        //res.sorted
    }

  def main(args: Array[String]): Unit = println(get_list(9801, 0.02).length)
}



Create a new paste based on this one


Comments: