Skip to content

Commit

Permalink
Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
msatmod committed Aug 30, 2022
1 parent efceff6 commit ca6cb67
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Day 12/Two-dimensional_array-1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 2D Array

cells = [['a', 'b', 'c', 'd', 'e'],['f', 'g', 'h', 'i', 'j']]

puts cells[1][2]

cells.each do|row|

row.each do|col|

print col.to_s + " "

end

puts

end



cells.each do|row|

puts row.join(', ')

end
22 changes: 22 additions & 0 deletions Day 12/Two-dimensional_array-2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 2D Array - Create 10*10 2D array with each element as "0"

box = []

10.times do |row|

box[row] = []

10.times do

box[row] << 0

end

end


for row in box

puts (row.inspect)

end

0 comments on commit ca6cb67

Please sign in to comment.