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
| //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 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
| 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
| //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
| //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
| //write Kazua | |
| object worldproblem1_3 { | |
| def PermutationsCheck(chkstr1 : String, chkstr2 : String) : Boolean = { | |
| if (chkstr1.length != chkstr2.length) return false | |
| val chgchkstr1 = chkstr1.toList.sortWith((o1, o2) => o1.toString.compareToIgnoreCase(o2.toString) < 0).mkString | |
| val chgchkstr2 = chkstr2.toList.sortWith((o1, o2) => o1.toString.compareToIgnoreCase(o2.toString) < 0).mkString | |
| chgchkstr1.equals(chgchkstr2) |
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 | |
| object worldproblem1_5 { | |
| def ZipStr(tgt : String, zip : String = "", acl : String = "", bktgt : String = "") : String = tgt match { | |
| case t if t.size == 0 => acl + zip.take(1) + zip.length | |
| case t => acl match { | |
| case a if a.length > 0 && a.length >= bktgt.length => bktgt | |
| case a => zip match { | |
| case z if z == "" => ZipStr(t.tail, z + t.head, a, t) | |
| case z if z.head == t.head => ZipStr(t.tail, z + t.head, a, bktgt) |
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_7 { | |
| def ZeroUpdate(tgt : Array[Array[Int]]) = { | |
| val rowbol = Map[Int, Int]() | |
| val colbol = Map[Int, Int]() | |
| for (i <- 0 until tgt.size) { |
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 java.util.Calendar | |
| import java.text.SimpleDateFormat | |
| object daydiff { | |
| def sdf = new SimpleDateFormat("yyyyMd") | |
| def daydiff(stday : Calendar, edday : Calendar, acl : List[String]) : List[String] = stday match { | |
| case s if s.compareTo(edday) > 0 => acl.reverse |