Skip to content

Instantly share code, notes, and snippets.

@toeic990
Last active January 30, 2016 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toeic990/b5251e4baac03716aa0a to your computer and use it in GitHub Desktop.
Save toeic990/b5251e4baac03716aa0a to your computer and use it in GitHub Desktop.
libraryDependencies += "org.skinny-framework" %% "skinny-http-client" % "2.0.2"
libraryDependencies += "org.slf4j" % "slf4j-simple" % "1.6.4"
mainClass := Some("Main")
scalaVersion := "2.11.7"
import skinny.http._
object Main extends App {
val response: Response = HTTP.get("http://www.geocities.jp/f9305710/PAI1000000.html")
//val response: Response = HTTP.get("http://www.example.com")
var r = response.textBody
r = r.substring(r.indexOfSlice("141592"), r.lastIndexOfSlice("</FONT>")).withFilter(_.isDigit).map(c => c)
var incount = 0;
var oncount = 0;
var outcount = 0
(r grouped 32) foreach { s =>
if (s.length == 32) {
print("0." + s.substring(0, 14) + "\t0." + s.substring(15, 29) + "\n")
var p: Double = Math.pow(("0." + s.substring(0, 15)).toDouble, 2) + Math.pow(("0." + s.substring(16, 31)).toDouble, 2)
//print(p)
p match {
case q if q < 1 => incount += 1
case 1 => oncount += 1
case q if q > 1 => outcount += 1
}
//println(" " + incount + " " + oncount + " " + outcount + " " + (4.0 * incount / (incount + outcount)))
println(" "+ (4.0 * incount / (incount + outcount)))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment