This file contains hidden or 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
| //write kazua | |
| import scala.collection.mutable._ | |
| object worldproblem1_1 { | |
| def UniqueCheck(chkstr : String) : Boolean = { | |
| if (chkstr.length == 0 && chkstr.length > 256) return false | |
| val chrmp = Map[Char, Boolean]() |
This file contains hidden or 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
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2028 | |
| //K.A | |
| object problem28 { | |
| def CornerNumSum(len : Int, acl : List[Int]) : List[Int] = len match { | |
| case i if i <= 1 => | |
| acl ::: List(i) | |
| case l => | |
| val mn = math.pow(l, 2).toInt | |
| val cn = l - 1 |
This file contains hidden or 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
| import java.sql._ | |
| import java.io._ | |
| import scala.Array | |
| import com.itextpdf.text._ | |
| import com.itextpdf.text.pdf._ | |
| import com.itextpdf.text.pdf.fonts._ | |
| import com.itextpdf.text.pdf.BaseFont._ | |
| object kakeiboPDFPrint { | |
| def main(args : Array[String]) { |
This file contains hidden or 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
| import java.sql._ | |
| import java.io._ | |
| import scala.Array | |
| object kakeiboMonthBackup { | |
| def using[A <: { def close() : Unit }, B](closable : A)(f : A => B) : B = try { f(closable) } finally { closable.close() } | |
| def main(args : Array[String]) { | |
| try { | |
| val year = args(0) | |
| val month = args(1) |
This file contains hidden or 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
| //K.A | |
| object BetrothedNum { | |
| def getBetrothedNum(min : Int, max : Int) = (min to max).map(i => List(i, (2 until i).filter(i % _ == 0).sum)).map(j => List(j.head, j.tail.head, (2 until j.tail.head).filter(j.tail.head % _ == 0).sum)).filter(k => k.head == k.tail.tail.head).map(k => List(k.head, k.tail.head)).filter(n => n.head < n.tail.head) | |
| def main(args : Array[String]) { | |
| val min = 1 | |
| val max = 10000 | |
| getBetrothedNum(min, max).foreach(println) | |
| } | |
| } |
This file contains hidden or 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
| import scala.math._ | |
| object semiperfectnum { | |
| def getSemiPfnList(mn : Int) : Seq[Int] = { | |
| lazy val pr : Stream[Int] = 2 #:: Stream.from(3).filter(i => pr.takeWhile(j => pow(j, 2) <= i).forall(i % _ > 0)).takeWhile(_ <= sqrt(mn * 2)) | |
| (1 to sqrt(mn * 2).toInt).map(i => pr.filter(_ % 2 != 0).takeWhile(_ < pow(2, i + 1)).map(j => (pow(2, i) * j).toInt).toList.map(k => (1 to (mn / k).toInt).map(n => k * n))).flatten.flatten.distinct.sortWith((a, b) => (a compareTo b) < 0) | |
| } | |
| def main(args : Array[String]) { | |
| val mn = 1000 |
This file contains hidden or 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
| import scala.math._ | |
| object perfectnum { | |
| def getPfnList(mn : Int) : Seq[BigInt] = { | |
| lazy val pr : Stream[Int] = 2 #:: Stream.from(3).filter(i => pr.takeWhile(j => pow(j, 2) <= i).forall(i % _ > 0)).takeWhile(_ <= sqrt(mn * 2)) | |
| (1 to sqrt(mn * 2).toInt).map(i => (BigInt(1) << i) - 1).filter(pr.contains).map(j => j * (j + 1) / 2) | |
| } | |
| def main(args : Array[String]) { | |
| val mn = 100000000 |
This file contains hidden or 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
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2097 | |
| //K.A | |
| object problem97 { | |
| def problem97 = (28433 * (BigInt(1) << 7830457) + 1) % BigInt(10).pow(10) | |
| def main(args : Array[String]) { | |
| println(problem97) | |
| } | |
| } |
This file contains hidden or 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
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2027 | |
| //K.A | |
| import scala.collection.mutable._ | |
| import scala.math._ | |
| object problem27 { | |
| lazy val pr : Stream[Int] = 2 #:: Stream.from(3).filter(i => pr.takeWhile(j => pow(j, 2) <= i).forall(i % _ > 0)).takeWhile(_ < 1000) | |
| val memo = Map[Int, Boolean]() | |
| def isPrime(n : Int) = if (n < 2) |
This file contains hidden or 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
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2017 | |
| //K.A | |
| object problem17 { | |
| val u20 = List(0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8) | |
| val t10 = List(0, 0, 6, 6, 5, 5, 5, 7, 6, 6) | |
| def calcChrLen(nm : Int, acl : Int) : Int = nm match { | |
| case a if a < 20 => acl + (if (acl > 0 && a > 0) 3 else 0) + u20(a) | |
| case a if a < 100 => calcChrLen(a % 10, acl + t10(a / 10)) | |
| case a if a < 1000 => calcChrLen(a % 100, acl + u20(a / 100) + 7) |