This file contains 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
hash = { "C" => [[0,1],[0,3]], | |
"O" => [[0,2],[1,0]], | |
"M" => [[1,3], [2,0]], | |
"E" => [[0,0], [2,2]] | |
} | |
#puts hash["C"] | |
arr = [] | |
hash.each_key { |key| | |
arr << hash[key]} |
This file contains 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
def gen_index(num_ele) | |
arr = [] | |
num_ele.times do |index| | |
arr = add_index(arr, index) | |
end | |
arr | |
end | |
def add_index(arr, index) | |
arr + arr.reverse.map { |ele| ele.dup << index } << [index] |
This file contains 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(board) | |
@board = board | |
end | |
def create_word(*coords) | |
coords.map { |coord| @board[coord.first][coord.last]}.join("") | |
end |