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
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) } |
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
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 |
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 'neo4j' | |
require 'benchmark' | |
Neo4j::Session.open(:server_db) | |
class Post | |
include Neo4j::ActiveNode | |
id_property :number | |
end |
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
source 'https://rubygems.org' | |
gem 'activesupport', require: 'active_support/all' | |
gem 'minitest', require: 'minitest/autorun' | |
gem 'minitest-reporters' | |
gem 'awesome_print' | |
gem 'tapp' |
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
source 'https://rubygems.org' | |
gem 'activesupport', require: 'active_support/all' | |
gem 'minitest', require: 'minitest/autorun' | |
gem 'minitest-reporters' | |
gem 'awesome_print' | |
gem 'tapp' |
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
source 'https://rubygems.org' | |
gem 'activesupport', require: 'active_support/all' | |
gem 'minitest', require: 'minitest/autorun' | |
gem 'minitest-reporters' | |
gem 'awesome_print' | |
gem 'tapp' |
OlderNewer