Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Elasticsearch shards matrix
m = []
size = 15
def shards(s, r)
s * r + s
end
size.times { |y| m << Array(0..size).map { |x| shards(y, x) }.join(' | ') }
print '| '
size.times { |header| print "| #{header} " }
puts '|'
size.times { |header| print "| - " }
puts '| - |'
m.each_with_index do |row, index|
next if index == 0
print "| #{index} | #{row} |"
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment