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.io.PrintWriter | |
| import scala.collection.mutable.ListBuffer | |
| import scala.io.Source | |
| import scala.actors._ | |
| import scala.actors.Actor._ | |
| object RecommendIndexBuilder { | |
| // Massage for Actors | |
| case class Ready() |
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
| (function() { | |
| var Fragment, FragmentController, FragmentView, User, | |
| __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | |
| $.ajaxSetup({ | |
| cache: false | |
| }); | |
| User = (function() { |
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 | |
| # n=5で50%のつもり | |
| def hit?(n) | |
| rand(10) <= (n-1) ? true : false | |
| end | |
| # パターン1:かぶりなし=10回成功したら終わり | |
| def pattern1(r) | |
| count = 0 |
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 | |
| (1..100).each do |n| | |
| puts case | |
| when n % 15 == 0 | |
| 'FizzBuzz' | |
| when n % 3 == 0 | |
| 'Fizz' | |
| when n % 5 == 0 | |
| 'Buzz' | |
| else |
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.annotation.tailrec | |
| object BF { | |
| class Parser(val str: String) { | |
| val cmap = Map( | |
| ">" -> 'pinc, | |
| "<" -> 'pdec, | |
| "+" -> 'inc, | |
| "-" -> 'dec, |
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 | |
| module Geolocation | |
| def distance_to(lat, lon, mode = nil) | |
| return unless (lat && lon) | |
| return unless (self.respond_to?(:latitude) && self.respond_to?(:longitude)) | |
| earth_distance(self.latitude, self.longitude, lat, lon, mode) | |
| end | |
| def distance_between(point, mode = nil) |
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
| # encoding: utf-8 | |
| require 'mail' | |
| MAIL_ENCODING = 'ISO-2022-JP' | |
| MYADDR = "hogehoge" | |
| def send_message | |
| mes = "mini来た!!" | |
| m = Mail.new |
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 | |
| def read_data(count) | |
| c = count.to_i | |
| return if c < 0 | |
| ret = [] | |
| count.times do | |
| s = gets | |
| next unless s | |
| ret << s.to_i | |
| end |
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
| height, width = gets.split(' ').map(&:to_i) | |
| # bitとして扱う | |
| lines = [] | |
| (1..height).each do |h| | |
| lines << gets.chomp.to_i(2) | |
| end | |
| # 対象を解析 | |
| targets = {} |
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
| # 再帰的探査 | |
| def search(list, i, need, nco, maxind, mincost, limit_mem) | |
| c = list[i] | |
| nmem = need - c[0] | |
| cost = nco + c[1] | |
| return mincost if cost > mincost # すでにわかっている答えより大きいので無駄 | |
| return cost if nmem <= 0 # メンバーが埋まった | |
| return mincost if i >= maxind # 終端までいったが、メンバーが埋まらない | |
| # 自身の効率*残り人数+現在のcostがmincostを超える |
OlderNewer