Skip to content

Instantly share code, notes, and snippets.

View keroxp's full-sized avatar

Yusuke Sakurai keroxp

View GitHub Profile
@keroxp
keroxp / dame.rb
Created July 22, 2012 10:32
プログラミングコンテストの問題
#ダメ解答
f = 1
s = 0
for i in 1..100 do
f *= i
end
n = f
@keroxp
keroxp / report2-3.js
Created June 27, 2012 12:29
自分の学籍番号と一文字違いの文字列を認識するプログラム
(function(){
$(function(){
var ID = $("#id").val(),
IDArray = [],
$input = $("#input2")
red = "#CD2525",
green = "#adff2f",
blue = "#1E90FF";
for(var i = 0 , max = ID.length ; i < max ; i++){
@keroxp
keroxp / report2-2.js
Created June 27, 2012 12:27
自分の学籍番号を認識するプログラミング
(function(){
$(function(){
var __VARS__,
ID = $("#id").val(),
red = "#CD2525",
green = "#adff2f",
blue = "#1E90FF",
$input = $("#input1");
$input.on("keydown keyup",checkID).val(ID).css("backgroundColor",green);
@keroxp
keroxp / fib.rb
Created June 27, 2012 12:25
フィボナッチ数を出力するプログラム
class Fib
def self.calc
fibs = [1,1]
loop do
yield fibs[0]
fibs.push fibs.shift + fibs[0]
end
end
end
@keroxp
keroxp / prime.rb
Created June 27, 2012 12:24
素数を出力するプログラム
class Prime
def self.calc
primes = [2]
puts 2
i = 3
loop do
max = Math.sqrt(i).floor
primes.each do |p|
if p > max then
yield i
@keroxp
keroxp / report.rb
Created June 27, 2012 12:23
素数かつフィボナッチ数を出力するプログラム
require "rubygems"
require "Monitor"
require "./fib.rb"
require "./prime.rb"
l = Monitor.new
h = {}
threadF = Thread.new do
Fib.calc { |f|