hilarybarr / phase_0_unit_2

Phase 0 Unit 2 Curriculum
0 stars 0 forks source link

Review - Boggle Board - Challenge 4 #2

Open tleung999 opened 10 years ago

tleung999 commented 10 years ago

Hi Hilary,

I enjoyed looking through your code and seeing how you solved the boggle board challenge. I actually paired up with someone else to solve ours and unfortunately we did not place our code into a class. We only used methods and changed the boggle board to a global variable $boggle_board.

Your solution definitely encapsulates everything into a nice clean package. For a minute there I was confused as to why you used [row-1]. But I see you wanted to describe the first row as the the top most row. The sample code in the instruction showed row 1 is actually [row] only.

Our initial solution to the column section was pretty close to what you had. But then my pair and I started talking about transposing the matrix and I did a search on Goggle to find a way to swap rows for columns and we found the transpose method in the Matrix class on Ruby doc. By using transpose you can just swap the rows with columns and now you can simply call col the same way you called up the row

def get_col(col)
   tboard = @board.transpose
   tboard[col-1]
end

Here's the link to the api doc http://www.ruby-doc.org/stdlib-1.9.3/libdoc/matrix/rdoc/Matrix.html#method-i-transpose

Thanks for your help on the community board! Great work on this project! Tony

hilarybarr commented 10 years ago

Hi Tony,

Thank you so much for taking the time to review my code and for your kind feedback!

The transpose method is awesome. Thanks for telling me about that.

If you’re ever unsure about whether to set methods inside a class, a good way to think about it is to ask whether the thing you are working with (in this case, the components of the boggle board array) will ever change. Because we want to be able to use different boggle boards, a class would be helpful, but it wouldn’t have been necessary if the arrangements and letters would always be the same.

Thanks for your help on the community board as well.

Sincerely, Hilary

gannoncurran commented 10 years ago

Hey Hillary -

I really liked seeing your detailed write-up of how you worked through the diagonal problem! I've been finding it really helpful to see the thought process of others. I also like your boil down of the whens-and-whys of methods and classes in your post above. Well stated and easy to remember in the heat of the moment. :)

I wound up using .abs as part of my check for "diagonal-ness" -- adding that on line 126 would also let you test for co-ordinate pairs like (3,0) (0,3) since the absolute value would be equal even if positive / negative values are different. It looks like this: (-3).abs returns 3