5 kyu
Java Functional Programming (Part 4: Row Row Row Your Boat, Gently Down the...)
287Azuaron
Loading description...
Streams
Functional Programming
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
how is "the guide that tell us to do everything" actually making the task at least 5 times difficult than the original task
I have completed this, and still want this one to be permantly deleted
Very nice kata!
This took me a really long time (almost the whole day) and I struggled a lot. I found the previous exercises in the series fairly simple but this one I really struggled with. I plodded on, searching online for various things and I seemed to be progressing. I started by commenting out all but the first / simplest test, and worked to get that working. Once it did, I uncommented the next... now I have to deal with the iteration on creation... then I revealed the next one etc... that definitely made it more manageable... but then when submitting, I hit the createFilter tests... I swear, it simply wasn't clear to me how that was supposed to work at all. At this point I was guessing and it seemed like no combination of logic would get my tests to pass. Eventually I did 'reveal solutions' which meant that I didn't get credit for completion, but I actually learned that I was super close and it was simpler than I thought. I would have like to have seen the createFilter tests in the main Kata versus hidden until submission.
I got through, and I think I learned something about streams and conversions etc., but I have to be honest I don't think I'll retain what I took from creating the custom functions or predicate... They still seem obtuse to me and when I look at the code that was created as a result, it doesn't necessarily make sense to me why I'd use these.
Really enjoyed the series, thank you! This one was tough for me.
I don't get it. For what I need howMany() method? Ok. I understood that I need to create stream from init string, then with map function, transform n times the curve, and the with I need to remove all letters a and b, but I didn't get how I should use method howMany() ?
Approved
The filter part wasn't clear (for me), you should have made a test case for that I had to rewrite it since my filter wasn't working when submitting
Not a issue, at most a
suggestion
.I strongly disagree. The description is simply not explicit enough in this respect, which of my understanding violates the codewars best practices, namely the criterion of clarity. Seems like an issue to me.
Ok... I really don't get it - when the IntPredicate createFilter produces should return true? I've tried like all possible combinations...
For me the most logical would be: c -> c != filterWhat || keep;
You need to think through what needs to happen when on keep == true vs keep == false. If keep == true, you still only want to keep the specific character coming in from filterWhat.
The description of this method is not ideal and it's possible to pass all the "curve" tests while failing the "createFilter" tests.
The "trick" is to know that a filter with keep either removes ONLY one character or keeps ONLY one character. This last bit was the one that forced me to reverse engineer the expected behaviour to satisfy the tests.
This comment has been hidden.
Your stream should definitely be stateless. This does not mean that values inside the stream shouldn't change (they should, that's what map is for), but they must not change (or, ideally, even rely upon) values outside the stream*. Additionally, once a stream has been used (IntStream output, in your case), it can't be used again. If you look at the method signature for IntStream::mapToObject, you'll notice it returns a new Stream. If you want to perform additional functions upon your stream, this new stream is the one you need to act upon.
* Depending on what you're doing, you may want something like an AtomicInteger for counting, but you must remember it can be acted upon by multiple instances of the stream in a parallel environment (if you aren't synchronized). When it comes to lambdas, if something can be done stateless, it should be done stateless.
The use of Strings throughout the program rather than IntStreams prevents the use of the "flatMap" function in the IntStream class (because mapFunction must return an IntStream, not a String). This means the programmer must essentially write their own "flatMap" function to use Strings which is unnecessary. Also, converting from an IntStream back to a String is a pain and it unneccesary in the case of the creation of the dragon curve. Just use IntStreams instead of Strings and this Kata is pretty good.
This is the last kata in a series, and, as such, it makes you use all the things you learned in the series. Part of that is converting from a String into an IntStream and back again (a common task in Java streaming). There's no "essentially" about the programmer writing their own flatMap function; that's a specifically defined part of the kata.
Further, it's essentially a translation of another kata of the Dragon's Curve (http://www.codewars.com/kata/dragons-curve), but forces the use of Java streams. As such, it keeps to the contract of that kata as much as possible, which is also heavily reliant on String manipulation and String out.
Finally, a stylistic complaint is a "Suggestion", not an "Issue".
Ok fair enough. And yeah i shouldn't have marked it as an issue. Sorry about that.
Im just not big on reinventing the wheel, but you're right there is nothing wrong with the Kata.
I love the idea of applying a mapping multiple times. Good idea! But I don't like the way the tests try to force me to solve the kata in a very specific way.