Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Although this is a perfect refactor of the code, I don't see it as being the best practice for this excersise, since the job was explicitly to debug the existing code (for practicing loops) and not entirely refactor it to something else.
This comment is hidden because it contains spoiler information about the solution
Didn't know about the argument for
with_index
. Great!https://github.com/bbatsov/ruby-style-guide#sprintf
http://ruby-doc.org/core-2.3.0/Kernel.html#method-i-format
THank you! But what do you call this sort of operation? - "%.2X%.2X%.2X" % [arr]- I'm looking for a key term to google so I can learn more about how to use this tool, and how it works. Is it shorthand for something else?
Absolutely agree, this has been a fun challenge. Though I think I'll have to keep myself from ordering an 'yvvi' in the future :]
You're right. His solution doesn't correctly validate all sudokus - it just passes all the test cases. Find any valid sudoku and swap the 6th and 7th rows to create an example invalid solution that this solution incorrectly passes.
This is how it's broken down:
First, look at the two BIG pieces: "String Format" % what_to_format (takes array as input)
So, left side is saying, "format as hexidecimal", right side is saying...
"take r,g,b array, and "map" it. What map does is take each element, and transform it somehow. How? you tell it how in the function that you pass it. The function he's passing is taking the r,g,b numbers and ensuring that they are between 0 and 255. if they're not, it forces them into that range.
So in the end it looks something like this "%.2X%.2X%.2X" % [27,255,133] (or whatever rgb values it is)
Is there anyway someone can lead me to a doc as to explain whats going on in this solution? I solved it but my code looks very procedural in comparison and I'm always trying to learn new things. Thanks.
Is there someone I can ask about how this works? It's one of the few katas I've skipped over and want to gain an understanding for it. I can read how the hashes translate over, but I'm unfamiliar with the rest of the code.
Wonderful!
Great solution. I originally was wondering how you got the increments to work then I broke down your variables and figured it out. Nicely done!~
I like this solution the best, very readable and straightforward. Great job!
This comment is hidden because it contains spoiler information about the solution
Thank you for that, I was able to add the additional code to make it work because of your tip on Sudoku.
Loading more items...