Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ashleehouse/8233162 to your computer and use it in GitHub Desktop.
Save ashleehouse/8233162 to your computer and use it in GitHub Desktop.
phase 0 unit 2 week 1 boggle class challenge
class BoggleBoard
def initialize(board)
@board = board
end
def create_word(*coords)
coords.map { |coord| @board[coord.first][coord.last]}.join("")
end
def get_row(row)
@board.each_index do |index|
if index == row
return @board[index]
end
end
end
def get_col(col)
@board.each_index do |index|
@board.each_index do |index_dos|
if col == index_dos
return @board[col]
end
end
end
end
end
dice_grid = [["b", "r", "a", "e"],
["i", "o", "d", "t"],
["e", "c", "l", "r"],
["t", "a", "k", "e"]]
first = BoggleBoard.new(dice_grid)
puts first.create_word([3,2], [3,1], [2,2], [3,3])
puts first.create_word([3,2]) #for the single coordinate.
puts first.get_col(2)
puts first.get_row(0)
#I hate classes. Just kidding. Well, not really. Not 'entirely', anyway. This worked out just fine and wasn't too hard!
#Boggle is not a fun game though. Not at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment