1
r=0..n=gets.to_i-1;puts n%2>0?"invalid":r.map{|i|r.map{|j|(i-j)*(n-i-j)==0??x:?.}*""}
You can clone a snippet to your computer for local editing. Learn more.