Skip to content

Instantly share code, notes, and snippets.

require 'terminal-table'
def play(board_size:)
@board = Array.new(board_size.to_i) { Array.new(board_size.to_i) }
while true
break if [:p1, :p2️].any? { |s| turn(s) }
end
puts !@winner.nil? ? "#{@winner} 💫" : "draw 😒"
end
# Given a number of keys how many binary search trees can be formed?
def num_trees(n)
return 1 if n == 0 || n == 1
(1..n).map do |j|
num_trees(j - 1) * num_trees(n - j) # left * right (summed)
end.reduce(:+)
end
p num_trees 0 # should be 1
p num_trees 1 # should be 1
# Script to automate Pull Request creation and description
# Pick up your commits tagged with an ENG-XXX Jira Id
# Outputs link to opened PR so you can fine-tune stuff
# /!\ assumes you branched off dev for your topic branch
# /!\ assumes you have Hub installed locally (`brew install hub` if not) -> Hub will ask for your credentials to store an Oauth token
# /!\ assumes the crucial commits have been tagged in the following fashion: ENG-XXXX <description>
JIRA_BROWSE_PATH = 'https://company-subdomain.atlassian.net/browse/'