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.
range returns a single integer which is not iterable but enumerate returns an integer and the index
the fastest code
This comment is hidden because it contains spoiler information about the solution
I think the clever thing of this solution is that you will only iterate arr to do the sum once. In the current top solution you iterate over it and do the sum len(arr) times making it O(n^2). Also, by using enumerate instead of range(len(arr)) you are already getting the element of the list to add it or substract it from the variables currently containing the sums.
Could someone explain why using
flatMap(_:)
would be preferable tojoined()
?Edit: I just ran some benchmarks and using
joined()
was almost twice as fast.Can somebody explain why it’s so common to take the closure out of the function?
I.e.,
.reduce(into: [String]()) { ... }
as opposed to.reduce(into: [String](), { ... })
While that’s helpful in this specific situation, I don’t think that’s a recommended way of using
extension
.Love your solution with the identity function, very elegant.
This comment is hidden because it contains spoiler information about the solution
This runs around 10x faster than the set comparison solution. They are also not complete passes.
This is by far the best implementation.
That makes sense, thank you so much! I just started learning C++.
I see that it happens with input:
"one hundred"
in functiontwo_digit_parse
in lineauto word = group.front()
, because group is empty.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...