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.
This comment is hidden because it contains spoiler information about the solution
Thank you for the reply. I'd forgotten about this website, there are just so many options for learning out there :)
It does not. In fact, this is not even necessary - you can just do
for age, handicap in data
.The (x, y) syntax in these sort of loops will perform tuple unpacking.
This is same sort of syntax as:
a, b = [1, 2]
, or(a, b) = [1, 2]
.What does "That's all the purpose of it" mean? I'm confused. It seems to me that append items to a list based on a conditional within a for loop should be doable with a list comprehension. I need to look into this further.
because you're not supposed to use it in a list comprehension! That's all the purpose of it.
I'm having difficulty using an append method within a list comprehension.
It doesn't appear your code is putting only distinct letters in new string. It seems all you're doing is combining the two strings, and sorting the new string.
Why does it not return 0 everytime, then?
Could you not set a flag to prevent that?
While I did not do this kata using recursion, it's the perfect scenario for one! Anytime you're repeatedly performing a mathematical operation, where time is a factor, use recursion.
I think that mapping the elements to the variables is really cool!
I thought the same thing about my solution. We know which is more readable, but which is faster?
Does (age, handicap) become a TUPLE? I don't know if that means anything in the grand scheme of things, but it looks like a tuple. I'm guessing it's not a tuple, because otherwise wouldn't each element have to be referenced by its index?
Yes, it is very readable, but the problem is the "shape" of the logic. There is redundancy with the shape. That is when the lightbulb came on for me, and I found list comprehensions!
List comprehensions ARE clever, but there's a time and place for them ;)