View 3d_maze_generate.rb
class CubeMaze
class Wall
def initialize(x, y, h, ob)
@wall = Array.new(h + 1) {Array.new(y) {Array.new(x, 1)}}
@x, @y = x, y
@cube = ob
end
attr_reader :wall
def break(num, n)
View oekaki_sample19a.rb
require 'oekaki'
Oekaki.app width: 500, height: 500 do
draw { clear(color(0x1694, 0x3447, 0x8d60)) }
t = Oekaki::Turtle.new
t.color(0xfe5f, 0xaa9a, 0x212a)
ln = 10
e = Enumerator.new do |y|
View prime_table.rb
def prime_table(n)
return [] if n < 2
return [2] if n == 2
table = [2, 3]
i, step = 5, 2
while i <= n
guard = Math.sqrt(i).to_i
table.each do |prime|
break if (i % prime).zero?
if prime > guard
View blackjack.rb
deck = nil
shuffle = ->{
print "カードをシャッフルします\n\n"
deck = []
4.times do |i|
1.upto(13) {|j| deck << i * 100 + j}
end
deck.shuffle!
View linuxmint_backup.rb
require 'fileutils'
class String
def cut
/.+tomoki\/(.+)$/.match(self)[1]
end
end
def get_file_names(f)
dirs = Dir.glob("*")
View lifegame_for_RubyPico.rb
class LifeGame
W, H = 124, 38
def initialize(n)
@field = new_field
scatter(n)
end
def set_cell(x, y)
@field[y + 1][x + 1] = 1
end
View calender.rb
#for RubyPico (mruby)
#mrubyには String#center がないので適当に実装
class String
def center(n)
i = (n - length).div(2)
" " * i + self + " " * (n - i - length)
end
end
View kaki-lifegame.rb
require 'gtk2'
module LifeGame
class Field
MG = 4
Small, Large = [70, 50], [85, 60]
def initialize
@width, @height = Small
@size = :small
View n_queen.go
package main
import "fmt"
const num = 15
var count = 0
func get_space(field []int) [num]int {
result := [num]int{}
l := len(field)
for i, queen := range field {
View lsystem.rb
require 'oekaki'
class Lsystem
def initialize(width, height, title = "L-system")
@width = width
@height = height
@title = title
@procedure = ""
@command = {}
@rule = {}