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
| require 'fileutils' | |
| File.open("./numeric.c", "r") do |klass| | |
| File.open("./numeric.tmp", "w") do |tmpfile| | |
| while line = klass.gets | |
| tmpfile.write line | |
| if line =~ /fix_to_s\(int argc, VALUE \*argv, VALUE x\)/ | |
| 2.times {tmpfile.write klass.readline} | |
| tmpfile.write <<PATCH | |
| int val; |
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
| class BoardFactory | |
| def self.create(text_or_state) | |
| case text_or_state | |
| when String | |
| text = text_or_state | |
| state = [] | |
| text.each_line do |l| | |
| next if l =~ /^$/ | |
| state << l.chomp.split(//) | |
| 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
| # Huffman coding | |
| # | |
| class Node | |
| attr_accessor :val, :weight, :left, :right | |
| def initialize(val = "", weight = 0) | |
| @val, @weight = val, weight | |
| 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
| # -*- coding: utf-8 -*- | |
| require 'twitter' | |
| class MyTweets | |
| def initialize(name) | |
| @name = name | |
| @c = Twitter::Client.new | |
| @tweets = [] | |
| 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
| #!/usr/bin/env ruby | |
| # -*- coding: utf-8 -*- | |
| # | |
| # Ruby 1.9以降必須。Array#combinationとか便利だし | |
| # Ken Nishimura 2010/4/5 | |
| # | |
| # (方針) | |
| # | |
| # 単騎待ちとそれ以外を分けて考える。再帰で3つずつ区切って幅優先探索。順 | |
| # 子、コーツ以外はその場で探索打ち切り。もう少し重複を刈り取れるけど、 |
NewerOlder