オフラインリアルタイムどう書く という、 @Nabetani さん主催のイベントを模したものを ESM の社内向けに行ったものです。
出題者: @kunitoo スペシャルサンクス: @mattsan, @mtsmfm
source 'https://rubygems.org' | |
gem 'activesupport', require: 'active_support/all' | |
gem 'minitest', require: 'minitest/autorun' | |
gem 'minitest-reporters' | |
gem 'awesome_print' | |
gem 'tapp' |
source 'https://rubygems.org' | |
gem 'activesupport', require: 'active_support/all' | |
gem 'minitest', require: 'minitest/autorun' | |
gem 'minitest-reporters' | |
gem 'awesome_print' | |
gem 'tapp' |
source 'https://rubygems.org' | |
gem 'activesupport', require: 'active_support/all' | |
gem 'minitest', require: 'minitest/autorun' | |
gem 'minitest-reporters' | |
gem 'awesome_print' | |
gem 'tapp' |
require 'neo4j' | |
require 'benchmark' | |
Neo4j::Session.open(:server_db) | |
class Post | |
include Neo4j::ActiveNode | |
id_property :number | |
end |
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 |
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) } |
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 |
オフラインリアルタイムどう書く という、 @Nabetani さん主催のイベントを模したものを ESM の社内向けに行ったものです。
出題者: @kunitoo スペシャルサンクス: @mattsan, @mtsmfm
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 |
source 'https://rubygems.org' | |
gem 'neo4j' |