combination by shlomif

def f(x)
x[Y-1]?puts(x*' '):((x[-1]||0)+1..X).map{|d|f(x+[d])}
end
gets=~/ /
X=$`.to_i
Y=$'.to_i
f([])

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page