Skip to content

Instantly share code, notes, and snippets.

@tomlea
Created October 15, 2009 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomlea/210959 to your computer and use it in GitHub Desktop.
Save tomlea/210959 to your computer and use it in GitHub Desktop.
height = 10
base = [height / 6, 8].max
width = lambda{|r| r * 2 - 1}
to_center = lambda{|s| s.center([height, base].map(&width).max)}
to_stars = '*'.method(:*)
tree = lambda{|v| v.map(&width).map(&to_stars) }
puts (
tree[1..height] +
tree[[2]*3] +
tree[5..base].reverse
).map(&to_center)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment