This file contains 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
int analogPin = 0; | |
int pwm_a = 3; //PWM control for motor outputs 1 and 2 is on digital pin 3 | |
int pwm_b = 11; //PWM control for motor outputs 3 and 4 is on digital pin 11 | |
int dir_a = 12; //direction control for motor outputs 1 and 2 is on digital pin 12 | |
int dir_b = 13; //direction control for motor outputs 3 and 4 is on digital pin 13 | |
int val = 0; //value for fade | |
int v = 0; | |
This file contains 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 'opencv' | |
require 'fileutils' | |
dropbox_dir = "/path/to/Dropbox" # ここだけ自分用に書き換えてください | |
# 0 番だと Mac のインカメラが選択されてしまうので 1 番を選択 | |
capture = OpenCV::CvCapture.open 1 |
This file contains 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
# 正定値二次形式の類を列挙するプログラム | |
# created by Junpei Tsuji <http://tsujimotter.info> | |
require 'prime' | |
require 'set' | |
# a, b, c を係数とする二次形式 f(x, y) = ax^2 + bxy + cy^2 を表すクラス | |
class QuadraticForm | |
def initialize a,b,c | |
@a = a |
This file has been truncated, but you can view the full file.
This file contains 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
# List on class number of positive definite form of discriminant D ( from -3 to -10000 ) | |
# created by Junpei Tsuji <http://tsujimotter.info> | |
D, h(D), C(D) | |
-3, 1, [x^2+xy+y^2] | |
-4, 1, [x^2+y^2] | |
-7, 1, [x^2+xy+2y^2] | |
-8, 1, [x^2+2y^2] | |
-11, 1, [x^2+xy+3y^2] | |
-12, 1, [x^2+3y^2] | |
-15, 2, [x^2+xy+4y^2],[2x^2+xy+2y^2] |
This file contains 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
# hypergeometric.rb | |
# 超幾何級数を計算するスクリプト | |
# | |
require 'rational' | |
# ポッホハマー記号 (x)_n を計算する | |
def pochhammer x, n | |
if n == 0 then | |
return 1 |
This file contains 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 'rubygems' | |
require 'gruff' | |
require 'prime' | |
# 配列を宣言 | |
primes = Array.new | |
prev_num = 0 | |
# 素数を生成する上限を決める |
This file contains 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
maximum_number = 10000000 | |
# 得られた素数を保管する配列 | |
primes = [] | |
# 素数の候補となる数の配列 | |
numbers = (2..maximum_number).to_a | |
p = numbers.first |
This file contains 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
########## | |
### 螺旋状に格子点を順に列挙する Enumerator クラス | |
# | |
# -max_levels <= x <= +max_levels | |
# -max_levels <= y <= +max_levels | |
# の範囲の格子点 (x, y) を列挙する | |
# | |
# ただし,中心 (0, 0) から | |
# -> ( 1, 0) -> ( 1, 1) -> ( 0, 1) -> (-1, 1) | |
# -> (-1, 0) -> (-1, -1) -> ( 0, -1) -> ( 1, -1) |
This file contains 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
# 1変数多項式の展開プログラム | |
class Polynomial | |
@@DEFAULT_MAX_ORDER = 200 | |
@@max_order = @@DEFAULT_MAX_ORDER # 打ち切らずに計算させる最大の次数 ( (MAX_ORDER+1) 以上の次数は打ち切られる ) | |
attr_reader :coefficients, :variable | |
# コンストラクタ |
This file contains 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
# tt21akRW1 さんによる [7, 120] における素数の個数を返す計算式の検証のためのプログラム | |
# 参考URL: http://blogs.yahoo.co.jp/donald_stinger/14413096.html | |
require 'prime' | |
def mod(n, modulo) | |
n.modulo(modulo).to_f | |
end | |
# tt21akRW1 さんによる [7, 120] における素数の個数を返す関数 |
OlderNewer