tleung999 / phase_0_unit_2 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from smileyface525/phase_0_unit_2
Phase 0 Unit 2 Curriculum
This project forked from smileyface525/phase_0_unit_2
Phase 0 Unit 2 Curriculum
Hey Tony!
I enjoyed looking through this code - there were several places where we were using the same techniques to do things, but I really liked seeing the way you dealt with diagonals. Iterating through you diag loop and changing the state of startcoord until it was the same as endcoord was really clever. I would never have thought of that.
I also liked your use of inject on line 45 - I feel like I'm behind on really learning and remembering to use all the powerful methods Ruby offers for working with arrays and hashes. Seeing that stuff encourages me to get better on that.
Only nitpick I would have is on indentation โ so minor tho. Nice work on this.
Great job on the refactored 'total' array. I felt in my gut there had to be a better way to do it than just the each method but couldn't think it and never used that method before.
One thing to shorten your code the tiniest of bit at the end is to leave out the statement "return". Any statement in ruby automatically returns the value of the last evaluated expression. Good Ruby style is said to leave out explicit returns unless needed clarity in complex code. Ruby is big on code minimalism/implicit magic. I reference the following when I'm not sure I'm styling it "The Ruby Way":
http://github.com/styleguide/ruby
Hey Tony,
I liked your solution to the easy math challenge because it was different. I didn't realize that we didn't need to put the array in parameters after defining the method's name. Very interesting - how does that work exactly?
Also, I think you're supposed to do 2 challenges (i.e., easy, medium, hard, harder)
Hey again Tony (yep, I'm doing my reivews and decided to do 2 of yours).
Your refactored solution is, for lack of a better term, impressive.
I believe I understand everything you're doing but as I tend to use Arrays instead of Hashes... it took me a bit to figure out exactly what methodology you were pursuing. I had to run the code on my own to make sure what I thought was going to happen, actually did happen.
Another facet I found interesting, that I didn't really try out... though thought about was the idea of "buckets". We can put 4 people into each bucket... which is seemingly what you did/pursued in your initial solution.
The other way I thought about it was "# of students" / 4 == Is how many buckets I need.
"# of students" % 4 = the number of students I'm going to "push" onto other groups. I figured that while we may be allowed to have a group of 5, we cannot have one of 3, for instance.
Again, codin' up a storm and lookin' good while doing it :)
John
I think your code looks great. I like how you used transpose, I had to look it up but haven't used it yet in code.Your code was readable, indentation was a bit inconsistent. Also, I don't think attr_reader is necessary for this challenge. Maybe it is, with my code I didn't use it and everything worked fine.
Hi Tony,
Your pseudocode is great, your code looks really clean and DRY. From everything including your reflection it really seems like you were applying things from the first challenge and putting them to good use here! Good work!
Hi Tony.
Hope all is going well for you so far this week.
This wasn't the most diffucult challenge, and your solution is nice. Very clean.
As I've been looking at other people's work on this, I came across a couple of things I thougth were cool and thought I'd pass them along:
attr_reader :sides
This one line will actually generate the following method automatically:
def sides
@sides
end
More here: http://stackoverflow.com/questions/5046831/why-use-rubys-attr-accessor-attr-reader-and-attr-writer
and also came across Random.rand(x..y) - another way to get a random number within a range. Not totally sure what the differences are between it and rand tho... and I think it only works in newer versions of ruby.
Hi Tony...
Seeing your comments, it seems you really understand whats going on within the dynamics of this program.
The only real suggestions I have are when defining what something is doing, such as .zip... perhaps don't use "zip" in the definition? Though, it is difficult to define methods and what they're doing sometimes... sort of like defining the color red... without calling it red :)
Great work as always :)
John
Your code is very methodical, which makes it very easy for me to follow along! Two suggestions that I have to make your code even more DRY are:
I hope that this helps, and I will actually try to follow your method and be very step-by-step; I tend to be all over the place.
Hey Tony,
I like what you did originally with your "Initial Solutions". Taking them down to 1 line Refactored solutions was pretty great as well. I believe you fall guilty to naming conventions as well as it took me a second to figure out what you were doing with "first + sentence + last" but perhaps its the way I read the code.
While there wasn't a lot of "meat" on this assignment, it does seem as though you have a great understanding of how you want to approach your code and then put it in to practice... your pseudocode exemplifies this as well.
Looking forward to working with you more and reading more of your code :)
John
Hi Tony -
Just left this comment for John ... thought I would copy here for you as well:
I liked looking through this - I think our ASCII conversion was kind of novel, but I like this better. Ruby arrays have so many built in features that serve this problem well. Using (a..z).to_a is a clear, compact way to get the array set up, and then relying on Ruby's "count back from the end" feature means you can do the shift -4 and not have to manually deal with wrapping around the end of the alphabet like we did with the ASCII numbers.
Slick.
Your solution got me thinking, could you use a literal array with all the $,%,@ stuff and "include?" to do the test for converting spaces?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.