Skip to content

Instantly share code, notes, and snippets.

@kunitoo
kunitoo / Gemfile
Created July 17, 2018 14:12
積み木の水槽 〜 横へな 2013.9.6 の回答 http://nabetani.sakura.ne.jp/hena/ord13blocktup/
source 'https://rubygems.org'
gem 'activesupport', require: 'active_support/all'
gem 'minitest', require: 'minitest/autorun'
gem 'minitest-reporters'
gem 'awesome_print'
gem 'tapp'
@kunitoo
kunitoo / Gemfile
Created July 14, 2018 05:21
[フォークじゃない 〜 横へな 2014.2.1 問題](http://nabetani.sakura.ne.jp/hena/ord18notfork/) の回答
source 'https://rubygems.org'
gem 'activesupport', require: 'active_support/all'
gem 'minitest', require: 'minitest/autorun'
gem 'minitest-reporters'
gem 'awesome_print'
gem 'tapp'
@kunitoo
kunitoo / Gemfile
Last active December 9, 2017 06:28
オフラインリアルタイムどう書くE20 http://nabetani.sakura.ne.jp/hena/orde20maze/ をオンラインで Neo4j を使った回答
source 'https://rubygems.org'
gem 'activesupport', require: 'active_support/all'
gem 'minitest', require: 'minitest/autorun'
gem 'minitest-reporters'
gem 'awesome_print'
gem 'tapp'
@kunitoo
kunitoo / neo4j_benchmark.rb
Last active May 14, 2016 07:36
neo4jrb bulk create benchmark | neo4j (7.0.6) neo4j-core (6.1.4) neo4j-rake_tasks (0.5.4)
require 'neo4j'
require 'benchmark'
Neo4j::Session.open(:server_db)
class Post
include Neo4j::ActiveNode
id_property :number
end
@kunitoo
kunitoo / janken.rb
Created May 6, 2016 09:47
ESM オフラインリアルタイムどう書く 拡大版 Ruby 実装例
def solve(input)
players = input.scan(/\w+/)
tournament = make_tournament(players)
"(#{winner(tournament)})"
end
def make_tournament(players)
sub = (2 ** (Math.log2(players.size).ceil)) - players.size
players.map.with_index(0) {|p, i| sub > i ? [p, p] : p }.flatten
end
@kunitoo
kunitoo / q2.rb
Last active April 16, 2016 08:35
Toyama.rb #05 問題2
module Q2
def self.strike
board = *(1..9)
count = deliver(board)
two_numbers = (board.zip(board.rotate) + board.zip(board.rotate(3))). #=> [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 1], [8, 2], [9, 3]]
select {|ns| ns[0] < ns[1] }.
reject {|ns| ns.include?(5) }.
reject {|n| [[3, 4], [6, 7]].include?(n) }
@kunitoo
kunitoo / q1.rb
Last active April 16, 2016 05:06
Toyama.rb #05 問題1
module Q1
def self.count
coins = [10, 50, 100, 500]
result = []
(2..15).each do |n|
coins.repeated_combination(n).each do |cs|
result << cs if cs.inject(:+) == 1000
end
end
@kunitoo
kunitoo / README.md
Last active May 6, 2016 09:33
ESM オフラインリアルタイムどう書く 拡大版

ESM じゃんけん大会 - 拡大版 ESM オフラインリアルタイムどう書く (2016/03/24,25)

オフラインリアルタイムどう書く という、 @Nabetani さん主催のイベントを模したものを ESM の社内向けに行ったものです。

出題者: @kunitoo スペシャルサンクス: @mattsan, @mtsmfm

問題

@kunitoo
kunitoo / bouwkamp.rb
Created February 14, 2016 13:15
まわせ! Bouwkamp!! 横へな2016.2.6 問題
class Rectangle
attr_accessor :x, :y, :size
def initialize(x, y, size)
@x = x
@y = y
@size = size
end
def include?(x, y)
@x <= x && @x + @size > x && @y <= y && @y + @size > y
@kunitoo
kunitoo / Gemfile
Last active January 15, 2016 04:22
瞬き星 〜 第2回 ESM オフラインどう書く ( Ruby + Neo4j ) https://gist.github.com/mattsan/07674b095908fda117a0
source 'https://rubygems.org'
gem 'neo4j'