This file contains hidden or 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 '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 [email protected]? ? "#{@winner} 💫" : "draw 😒" | |
end |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
# 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/' |