def make_da_hash(n)
a = (0..n*n-1).to_a
a.zip(a.each_slice(n).flat_map { |e| [e]*n }).to_h
end
make_da_hash(3)
#=> {0=>[0, 1, 2], 1=>[0, 1, 2], 2=>[0, 1, 2],
# 3=>[3, 4, 5], 4=>[3, 4, 5], 5=>[3, 4, 5],
# 6=>[6, 7, 8], 7=>[6, 7, 8], 8=>[6, 7, 8]}
make_da_hash(4)
#=> {0=>[0, 1, 2, 3], 1=>[0, 1, 2, 3], 2=>[0, 1, 2, 3], 3=>[0, 1, 2, 3],
# 4=>[4, 5, 6, 7], 5=>[4, 5, 6, 7], 6=>[4, 5, 6, 7], 7=>[4, 5, 6, 7],
# 8=>[8, 9, 10, 11], 9=>[8, 9, 10, 11], 10=>[8, 9, 10, 11],
# 11=>[8, 9, 10, 11], 12=>[12, 13, 14, 15], 13=>[12, 13, 14, 15],
# 14=>[12, 13, 14, 15], 15=>[12, 13, 14, 15]}