Skip to content

Instantly share code, notes, and snippets.

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;
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
# Huffman coding
#
class Node
attr_accessor :val, :weight, :left, :right
def initialize(val = "", weight = 0)
@val, @weight = val, weight
end
@knsmr
knsmr / wctweet.rb
Created January 2, 2011 22:53
Analyze Tweets and count the numbers of each letters used
# -*- coding: utf-8 -*-
require 'twitter'
class MyTweets
def initialize(name)
@name = name
@c = Twitter::Client.new
@tweets = []
end
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# Ruby 1.9以降必須。Array#combinationとか便利だし
# Ken Nishimura 2010/4/5
#
# (方針)
#
# 単騎待ちとそれ以外を分けて考える。再帰で3つずつ区切って幅優先探索。順
# 子、コーツ以外はその場で探索打ち切り。もう少し重複を刈り取れるけど、