Four sides of square: Difference between revisions

No edit summary
Line 1,186:
[http://keptarhely.eu/view.php?file=20220218v00x6hugz.jpeg Four sides of square]
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">def square_sides(size = 9)
Array.new(size){|n| n==0 || n==size-1 ? [1]*size : [1]+[0]*(size-2)+[1]}
end
 
puts square_sides.map{|line| line.join (" ") }
</syntaxhighlight>
{{out}}
<pre>1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1
</pre>
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">var n = 5
1,149

edits