Forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
Created
November 15, 2013 01:40
-
-
Save techlovely84/7477761 to your computer and use it in GitHub Desktop.
phase 0 unit 2 week 1
boggle class challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BoggleBoard | |
def initialize(boggle_board) | |
@boggle_board = boggle_board | |
end | |
def create_word(*coords) | |
coords.map { |coord| @boggle_board[coord.first][coord.last]}.join("") | |
end | |
def get_row(row) | |
print @boggle_board[row] | |
#write a method that takes a row number and return | |
#elements in the row. | |
#go through each row and find (arg) | |
end | |
def get_col(col) | |
print @boggle_board.map { |row| row[col]} | |
# col = boggle_board[coord.first][coord.last] | |
# identify each column as the first, second, third, fourth lts | |
end | |
end | |
dice_grid = [["b", "r", "a", "e"], | |
["i", "o", "d", "t"], | |
["e", "c", "l", "r"], | |
["t", "a", "k", "e"]] | |
boggle_board = BoggleBoard.new(dice_grid) | |
boggle_board.create_word( [2,1], [3,1], [3,2], [3,3]) | |
boggle_board.get_row(1) | |
boggle_board.get_col(1) | |
# puts create_word(boggle_board, [2,1], [1,1], [1,2], [0,4]) | |
# puts create_word(boggle_board, [0,1], [0,2], [1,2]) | |
# puts create_word(boggle_board, [3,0], [3,1], [3,2], [3,3]) #=> should return "take" | |
# puts create_word(boggle_board, [0,1], [0,2], [1,3]) #=> should return "rat" | |
# # get_row(boggle_board) #=> ["i", "o", "d", "t"] | |
# get_col(boggle_board) #=> ["r", "o", "c", "a"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment