Created
February 14, 2018 20:08
-
-
Save relyks/5c55fae4ab0c34ddcb0694dd7c8dda46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = Array.new(9) { Array.new(9) { rand(0..9) } } | |
s = t = 0 | |
(0...9).each do |i| | |
(0...9).each do |j| | |
print "#{a[i][j]} " | |
s += 1 | |
if s == 3 | |
print ' | ' | |
s = 0 | |
end | |
end | |
puts | |
t += 1 | |
if t == 3 | |
# each number and spaces + each delimiter and spaces | |
puts '-' * ((2 * 9) + (3 * 3)) | |
t = 0 | |
end | |
end | |
2.times { puts } | |
(0...9).step(3) do |i| | |
(0...9).step(3) do |j| | |
(0...3).each do |y| | |
(0...3).each do |x| | |
print a[i + y][j + x].to_s + ' ' | |
end | |
puts | |
end | |
puts | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
6 6 5 | 3 3 7 | 6 6 9 |
5 9 3 | 0 9 4 | 0 0 0 |
6 7 9 | 6 9 9 | 8 5 2 |
5 1 5 | 2 6 0 | 9 5 4 |
1 7 5 | 2 8 6 | 2 9 1 |
5 8 9 | 8 3 0 | 3 0 5 |
4 5 7 | 6 3 3 | 2 9 4 |
3 0 4 | 1 9 1 | 3 1 4 |
4 3 1 | 4 0 2 | 5 7 6 |
6 6 5
5 9 3
6 7 9
3 3 7
0 9 4
6 9 9
6 6 9
0 0 0
8 5 2
5 1 5
1 7 5
5 8 9
2 6 0
2 8 6
8 3 0
9 5 4
2 9 1
3 0 5
4 5 7
3 0 4
4 3 1
6 3 3
1 9 1
4 0 2
2 9 4
3 1 4
5 7 6