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 has been cleaned up. thank you for this suggestion
Random tests have now been added
Fair point, will update shortly
Excellent - However I suggest looking at the other solutions. Most of them use Aggregate, so it might be useful to see how to use Aggregate in this scenario
Unfortunately, I cannot change the test cases anymore - they are locked.
The only error in the test cases is the order in which the messages are printing (something I stated as well). So, in your mind just swap the "expected" and "got" messages. I'll be contacting the admins about unlocking the test cases so I can fix that, however that doesn't change the fact that your solution is still wrong.
As far as linq + C#, although I don't know much of about the language itself, I've learned enough languages to grasp what Aggregate does (it's not an uncommon concept for other higher order languages).
0 may be for the sum, but I'm giving you a starting value in the Chain method that you aren't even using. You need to use that instead of 0, otherwise you will constantly get the wrong answer. It's a very small but important change.
300 cannot be the correct answer.
With the input being
2
and the operations foradd
andmul
(which are already defined for you), the correct result is 360.Looking at your code - I can see what the problem is. What do you use 0 as your starting value when call Aggregate? If you did that, this is what you get as your execution steps
This is incorrect (and is what you got as your answer). However, you're very close - really. Almost there!
hey @chucklu, just wondering if your problems were resolved. If not - do you have any more questions??
I realize now why this was an issue for you, there is no example in the description for C#! My apologies - the C# addition wasn't done by me (and I have little to no knowledge of C#).
Example code as well as a modified description has been added and should definitely help you understand what the result should be.
We can do some psuedo-code right here however.
Upon further exposure to programming and awareness of my lack of understanding of anything - tetreault you are correct. This is not chaining. it's a foldr method with an array of functions. that is all. I concede to you sir. However I can't change the name of this kata. I must apologize profusely. :'(
Sorry I didn't get a notification until now about your reply. Weird.
so fs.Last() will return the last function in the array of functions. How could it return the right result, if it only executed the last function in the list?
Just post the solution here and mark it as having spoiler content.
Regardless, the solution for this is definitely possible and if you look at the other solutions (I know, you won't get the points for the kata), you might be able to see what you're doing wrong.
I'm going to mark the issue as resolved. Your implementation needs work. I know you were just trying to get the right message to pop up, but seeing (above) what the issue is, you should now know what to expect. Happy coding.
ok. so as I thought. the tester for the C# environment is printing the statements incorrectly. That's not something that can be fixed right now. So in the mean-time, just imagine "expected" and "but was" were flipped. That should make more sense.
Hm, that's really weird. However, looking at the test cases - it seems to be working as it should. It might be that Codewars tester is not displaying the useful information in the proper way for C#.
Just to be sure - what is your current solution?
No the formatting is something you'll have to manage manually. Usually the answers aren't going to be too long so that shouldn't be too much of a worry. However, an IDE like experience would only be possible in
or
Neither of these things is within what codewars is trying to accomplish so I would suggest if you want code formatting, do it in whatever favorite editor/environment you wish and just copy/paste the final code you want into the submission box.
Loading more items...