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
| package euler.zerosum | |
| object Euler0033 { | |
| val TWO_DIGIT_NUMS = (10 to 99).toStream | |
| def main(args: Array[String]) { | |
| val fractions = | |
| TWO_DIGIT_NUMS | |
| .foldLeft(List((1, 1)))((x, y) => |
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
| package euler.zerosum | |
| object Euler0031 { | |
| val P1 = 1 | |
| val P2 = 2 | |
| val P5 = 5 | |
| val P10 = 10 | |
| val P20 = 20 | |
| val P50 = 50 |
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
| package euler.zerosum | |
| import io.Source | |
| object Euler0081 { | |
| def main(args: Array[String]) { | |
| val f = Source.fromFile("matrix.txt") | |
| val matrix = f.getLines.foldRight(List(List(0)))((x, y) => | |
| x.split(",").toList.map(_.toInt) :: y |
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
| package euler.zerosum | |
| import euler.zerosum.Prime._ | |
| import euler.zerosum.Number._ | |
| import euler.zerosum.Divisors._ | |
| object Euler0027 { | |
| def main(args: Array[String]) { | |
| val a = (-999 to 999).toStream |
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
| package euler.zerosum | |
| import euler.zerosum.Number._ | |
| object Euler0092 { | |
| def main(args: Array[String]) { | |
| val n = from(0).take(1000) | |
| 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
| package euler.zerosum | |
| object Euler0065 { | |
| def main(args: Array[String]) { | |
| val a = e.take(100) | |
| val numer = a.init.foldRight(new Rational(a.last, 1))(new Rational(_, 1) + new Rational(1, 1) / _).numer | |
| println(numer.toString.toList.map(_.toInt - 48).sum) | |
| } |
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
| package euler.zerosum | |
| import euler.zerosum.Prime._ | |
| import euler.zerosum.Divisors._ | |
| object Euler0035 { | |
| def main(args: Array[String]) { | |
| println(provideCircularPrimes(primes(1, 1000000), Nil).length) | |
| } |
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
| package euler.zerosum | |
| import euler.zerosum.Prime._ | |
| object Euler0007 { | |
| def main(args: Array[String]) { | |
| println(primes(1, 110000).take(10001).last) | |
| } | |
| } |
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
| package euler.zerosum | |
| import io.Source | |
| object Euler0089 { | |
| def main(args: Array[String]) { | |
| val f = Source.fromFile("resources/roman.txt") | |
| val roman = f.getLines.toList | |
| f.close() |
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
| package euler.zerosum | |
| import euler.zerosum.Prime._ | |
| import euler.zerosum.Number._ | |
| import euler.zerosum.Divisors._ | |
| object Euler0046 { | |
| private val oddComposites = from(2).filterNot(n => n % 2 == 0 || primes(1, n).contains(n)) |