Ad
  • Custom User Avatar

    This has been cleaned up. thank you for this suggestion

  • Custom User Avatar

    Random tests have now been added

  • Custom User Avatar

    Fair point, will update shortly

  • Custom User Avatar

    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

  • Custom User Avatar

    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.

  • Custom User Avatar

    300 cannot be the correct answer.
    With the input being 2 and the operations for add and mul (which are already defined for you), the correct result is 360.

    let i = 2
    let add(x) = x + 10
    let mul(x) = x * 30
    
    chail(2, [add, mul])
    
    ## Steps of execution
    # i = 2
    # add(2) = 2 + 10 = 12
    # mul(12) = 12 * 30 = 360
    ## 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

    ## steps of execution
    # i = 0
    # add(0) = 10 + 0 = 10
    # mul(10) = 10 * 30 = 300
    # result 300
    

    This is incorrect (and is what you got as your answer). However, you're very close - really. Almost there!

  • Custom User Avatar

    hey @chucklu, just wondering if your problems were resolved. If not - do you have any more questions??

  • Custom User Avatar

    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.

    let add(x) = x + 10
    let mult(x) = x * 30
    let i = 0
    
    # Lets call our chainer!
    chain(i, [add, mult])
    
    ## Steps of execution
    # i = 0
    # 1) add(0) => 10
    # now take that return value and feed it to the next function
    # 2) mul(10) => 300
    # all done! return 300
    
  • Custom User Avatar

    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. :'(

  • Custom User Avatar

    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?

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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?

  • Custom User Avatar

    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

    1. an IDE
      or
    2. a robustly configured text-editor.

    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...