function Tree() {
this.lines = [
[]
]
}
var pp = Tree.prototype
pp.genNode = function(line, i) {
var top = line -
var topLine = this.lines[top] || [, , ]
var curLine = this.lines[line]
if (!curLine) {
curLine = this.lines[line] = []
}
if (i in curLine)
return
curLine[i] = (topLine[i - ] || ) + (topLine[i] || )
}
pp.genLine = function(n) {
for (var i = ; i <= n; i++) {
this.genNode(n, i)
}
}
pp.print = function() {
for (var i = ; i < this.lines.length; i++) {
var el = this.lines[i]
console.log(el.join(', '))
}
}
var tree = new Tree
for (var i = ; i < ; i++) {
tree.genLine(i)
} tree.print()