Forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
Last active
August 29, 2015 13:55
-
-
Save justinphelps/8747127 to your computer and use it in GitHub Desktop.
phase 0 unit 2 week 1boggle 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
SIZE = 10 | |
class BoggleBoard | |
attr_reader :board | |
def initialize | |
@board = Array.new(SIZE){ Array.new(SIZE){ (('a'..'z').to_a[rand(26)]) }} | |
end | |
def get_row(row) | |
@board[row] | |
end | |
def get_col(col) | |
board.map { |x| x[col]} | |
end | |
def print_board | |
board.each { |x| p x} | |
end | |
def create_word(*coords) | |
coords.map { |coord| @board[coord.first][coord.last]}.join("") | |
end | |
def board= | |
board = @board | |
end | |
def inbounds?(*coords) | |
coords.flatten.each {|x| puts x.between?(0, (SIZE-1))} | |
end | |
def highest(*) | |
end | |
end | |
derps = BoggleBoard.new | |
derps.print_board | |
p derps.get_col(2) | |
p derps.get_row(1) | |
puts derps.create_word([2,1], [1,1], [1,2], [0,3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment