Skip to content

Instantly share code, notes, and snippets.

@duane
Created July 17, 2019 17:00
Show Gist options
  • Save duane/3ae51f2da6c098c3a7007d7c71c691c9 to your computer and use it in GitHub Desktop.
Save duane/3ae51f2da6c098c3a7007d7c71c691c9 to your computer and use it in GitHub Desktop.
# Prints out a tree like this (branches_height = 5) with a pedestal:
#
# x
# xxx
# xxxxx
# xxxxxxx
# xxxxxxxxx
# |
# ===
def render_tree(branches_height)
raise "branches_height must be at least 2" if branches_height < 2
raise NotImplmentedError
end
# Looks for parens in the string, '(' for opening and ')' for closing.
# Return true if every opening paren is eventually followed by a matching closing paren,
# and every closing paren is following a matching opening paren.
# It should ignore all other characters.
def balanced(string)
raise NotImplmentedError
end
# Casees to test:
# ()
# )
# (()))
# ()(()
# ()((()(()))())
# (hello, (some) more text (to complicate the process))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment