Skip to content

Instantly share code, notes, and snippets.

@Wolwer1nE
Created November 1, 2019 11:30
Show Gist options
  • Save Wolwer1nE/cda3557ea32c4844eb0469888b4ed7de to your computer and use it in GitHub Desktop.
Save Wolwer1nE/cda3557ea32c4844eb0469888b4ed7de to your computer and use it in GitHub Desktop.
for_triplets.rb
a = [[0,1,1], [1,2,2], [2,0,1]]
def select_row(a, i, n)
row = Array.new(n, 0)
a.select{ |x| x[0] == i }.each do |x|
row[x[1]] = x[2]
end
row
end
p select_row(a, 0, 3)
p select_row(a, 1, 3)
p select_row(a, 2, 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment