Squares Round 3 by test

a=['']+[*$<]+['']
($.+1).times do |i|
    j = 0
    s=a[i][0]==?. ? '|' : ' '
    while a[i+1][j] || a[i][j] do
        b = '  '
        b[0]= ?_ if (a[i][j]==?. || a[i+1][j]==?.) && !(a[i][j]==?. && a[i+1][j]==?.)
        b[1]= ?| if (a[i][j]==?. || a[i][j+1]==?.) && !(a[i][j]==?. && a[i][j+1]==?.)
        s += b
        j += 1
    end
    puts s.gsub(/_ (?=_)/,'__').rstrip
end

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

download

return to the top page