Created
December 25, 2013 09:25
-
-
Save eban/8121696 to your computer and use it in GitHub Desktop.
https://gist.github.com/1011836 を rubyで
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
STAR = " \u2605" | |
FSLASH = "\uFF0F" | |
BSLASH = "\uFF3C" | |
ORNAMENTS = %W(\u0069 \u0020 \u0020 \u0020 \u0020 \u0020 | |
\u0020 \u0020 \u0020 \u0020 \u0020 \u0020 | |
\u0020 \u2E1B \u2042 \u2E2E \u0026 \u0040 \uFF61) | |
ORNAMENT_COLORS = [ 21, 33, 34, 35, 36, 37 ] | |
HAT = "\u005e" | |
def tree(h) | |
printf("\n%*s\e[33m#{STAR}\n", h, "") | |
m = h * 2 - 1 | |
1.upto(h) { |l| | |
o = l * 2 - 2 | |
s = (m - o) / 2 + 1 | |
printf("%*s\e[32m#{FSLASH}", s, "") | |
o.times { | |
print("\e[#{ORNAMENT_COLORS.sample}m#{ORNAMENTS.sample}") | |
} | |
print("\e[32m#{BSLASH}\n") | |
} | |
hats = "\e[32m#{HAT}" * (h - 1) | |
print(" #{hats}| |#{hats}") | |
if h > 10 | |
printf("\n %*s| |%*s", h - 1, "", h - 1, "") | |
end | |
print("\n\n") | |
end | |
tree(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment