Skip to content

Instantly share code, notes, and snippets.

@yclim95
Forked from nextacademy-private/nested_arrays.rb
Last active January 14, 2016 02:11
Show Gist options
  • Save yclim95/96d404aa00a20203a1fc to your computer and use it in GitHub Desktop.
Save yclim95/96d404aa00a20203a1fc to your computer and use it in GitHub Desktop.
Nested Arrays
# Objective 1 Chess
chessboard=[["B Rook","B Knight","B Bishop","B Queen","B King","B Bishop","B Knight","B Rook"],
["B Pawn","B Pawn","B Pawn","B Pawn","B Pawn","B Pawn","B Pawn","B Pawn"],
[],
[],
[],
[],
["W Pawn","W Pawn","W Pawn","W Pawn","W Pawn","W Pawn","W Pawn","W Pawn"],
["W Rook","W Knight","W Bishop","W Queen","W King","W Bishop","W Knight","W Rook"]]
puts chessboard[7][0] == "W Rook" # outputs TRUE
# Objective 2 **Table
table=[["Number","Name","Position","Points per Game"],
[12,"Joe Schmo","Center",[14,32,7,0,23]],
[9,"Ms. Buckets","Point Guard",[19,0,11,22,0]],
[31,"Harvey Kay","Shooting Guard",[0,30,16,0,25]],
[18,"Sally Talls","Power Foward",[18,29,26,31,19]],
[22,"MK DiBoux","Small Foward",[11,0,23,17,0]]]
puts table[3][2] == "Shooting Guard" # outputs TRUE
puts table[1][3] == [14,32,7,0,23] # outputs TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment