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
| val maltiplicativeResults = 1 to 999 flatMap(i => 1 to 999 map(_ * i)) | |
| val answer = maltiplicativeResults.filter({i => | |
| if (i.toString.length % 2 != 0) { | |
| false | |
| } | |
| i.toString.reverse == i.toString | |
| }) | |
| Console.print(answer.max) |
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
| lazy val ps: Stream[Int] = 2 #:: Stream.from(3).filter( | |
| i => { | |
| // 素数だけのリストを作る。jはiの平方根より小さい数で、iが割り切れる数である。 | |
| ps.takeWhile(j => { j * j <= i }).forall(i % _ > 0) | |
| } | |
| ) | |
| val n = 600851475143L | |
| // 素因数の素朴試し割り法では、割る数の最大値はその数の平方根まででよい。 |
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
| $("a[rel=popover]").popover({trigger: 'manual'}).click(function(e){ | |
| $(this).popover('toggle'); | |
| e.preventDefault(); | |
| }); |
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
| .search-form { | |
| position: relative; | |
| padding: 30px 19px 5px; | |
| background-color: white; | |
| border: 1px solid #DDD; | |
| -webkit-border-radius: 4px; | |
| -moz-border-radius: 4px; | |
| border-radius: 4px; | |
| } |
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.util.control.Breaks._ | |
| object Problem3 extends App { | |
| val target: Long = 600851475143L | |
| var maxOfAnswer = 600851475143L | |
| // val answer = number(target).takeWhile(1 < _).filter(n => target % n == 0 && isPrime(n)).head | |
| var n = 2; | |
| breakable{ |
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
| object Problem2 extends App { | |
| def fibFrom(a: Int, b: Int): Stream[Int] = a #:: fibFrom(b, a + b) | |
| val answer = fibFrom(1, 2).takeWhile( _ < 4000000).filter(_ % 2 == 0).sum | |
| Console.println(answer) | |
| } |
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
| object Problem2 extends App { | |
| def fibonacci(first: Int, second: Int, max: Int): mutable.LinkedList[Int] = { | |
| var a = first | |
| var b = second | |
| var list = new mutable.LinkedList[Int]() | |
| if (a % 2 == 0) list :+= a | |
| if (b % 2 == 0) list :+= b | |
| breakable { |
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
| object Problem1 extends App { | |
| val answer = (1 until 1000).view.filter(x => { x % 3 == 0 || x % 5 == 0 }).sum | |
| Console.println(answer) | |
| } |
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
| object Problem1 extends App { | |
| val list = List.range(1, 1000) | |
| val nums = list.filter(x => { x % 3 == 0 || x % 5 == 0 }) | |
| val answer = nums.sum | |
| Console.print(answer) | |
| } |
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
| # coding: utf-8 | |
| require 'rubygems' | |
| require 'net/irc' | |
| class TaeClient < Net::IRC::Client | |
| def on_rpl_welcome(m) | |
| post JOIN, opts.channel | |
| end | |
| def on_privmsg(m) |