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
RESERVEDS = %w{ PROGRAM CONST TYPE VAR PROCEDURE FUNCTION | |
BEGIN END ARRAY OF INTEGER CHAR CALL | |
IF THEN ELSE WHILE DO FOR TO } |
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/ruby -Ku | |
$:.unshift File.join(File.dirname(__FILE__), "..", "lib") | |
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 'pp' | |
$KCODE = 'UTF8' | |
module Ngram | |
def run(str) | |
analyze(cut(str,3)) | |
end | |
def cut(str, n) | |
list = str.split(//) |
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/ruby | |
# -*- coding: utf-8 -*- | |
# オセロの石を置くプログラム | |
# based on http://bkc.g.hatena.ne.jp/coconutsfine/20081010/1223651539 | |
# 新しい盤面のArrayを作って返す | |
def setup_box | |
# 盤面オブジェクトを生成(8x8の:empty) | |
box = Array.new(8){ Array.new(8, :empty) } | |
#盤面の初期値を設定 |
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/ruby | |
def parse(string) | |
string.each_line do |line| | |
list = line.split(" ") | |
print "#{list.first}: " | |
list[1..-1].each do |token| | |
raise "input's size should 2(#{token})" if token.size != 2 | |
token.split("").each do |char| | |
num = char.chomp.hex.to_s(2) | |
print "#{'0'*(4-num.size%4) if num.size%4 != 0}#{num}" |
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 Stone | |
@@STONE_COLORS = [:white, :black] | |
def initialize(heads_color) | |
raise "Invalid type" unless @@STONE_COLORS.include?(heads_color) | |
@heads = heads_color | |
end | |
attr_reader :heads # 表の色 | |
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
* N: NUMBER OF INPUT | |
N: EQU 80H | |
* CUR: CURRENT RESULT (AND RESULT) | |
CUR: EQU 81H | |
* P1: PREVIOUS RESULT | |
P1: EQU 82H | |
* P2: PRE-PREVIOUS RESULT |
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
LINE = "="*80 | |
Dir.glob("*.cpp\0*.h") do |file| | |
puts LINE | |
puts " " + file | |
puts LINE | |
system("cat -n #{file}") | |
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/ruby | |
# -*- coding: utf-8 -*- | |
# マルコフ連鎖をしてみるやつ | |
$KCODE = 'UTF8' | |
# Array::choiseを追加 | |
class Array | |
def choise | |
self[rand(self.size)] |
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
;; default encodingをutf-8に変更 | |
(set-default-coding-systems 'utf-8) | |
;; status-barにカーソルのcolumn表示(4,29とか) | |
(column-number-mode t) | |
;; ファイル名補完で大文字小文字を区別しない | |
(setq completion-ignore-case t) | |
;; バックアップファイルを作らない |
OlderNewer