Ad
  • Custom User Avatar

    You don't need second reverse as you end up using reduce :)

  • Custom User Avatar

    Hey! what's the name of your formula or how did you come up with it ?
    I literally spent the whole day (8 hrs ) in this problem creating my own formula

    Math and me dont really get along!

    :-(

  • Custom User Avatar

    Hey! what's the name of your formula or how did you come up with it ?
    I literally spent the whole day (8 hrs ) in this problem creating my own formula

    Math and me dont really get along!

    :-(

  • Custom User Avatar

    Nobody forbids you to give a solution with big integers, who can do more can do less!-)

  • Custom User Avatar

    I spent the first hour creating a method that returns the most efficient set of steps to finish in the same position as the original array of steps,

    then after failing the test cases I had to start over because it seems that that is not what the OP wanted, take as an example the second test case, you end up in the same position if you dont move at all.

    it was really annoying having to start over because that wasn't clear enough since the beginnign.

    so this exersice is NOT about finding the most efficient set of steps, like it says at the begining, its about some weird cancellation if the directions are opposite and next to each other.

  • Custom User Avatar

    I know about the big integers, that's not the issue, what I'm saying is that the template for the exersice doesn't match the description (because its using long datatype, which its not enough in c#), its up to you if you want to fix it. all Im saying is that you should update the template to use either ulong or biginteger, and add more test cases to test big numbers,
    this is to contribute to have a better exercise if you dont want to fix its up to you.

  • Custom User Avatar

    The kata is made unique for different languages. Python, Ruby, Clojure supports big integers without further ado. In C# you can use big integers too.
    https://msdn.microsoft.com/fr-fr/library/system.numerics.biginteger%28v=vs.110%29.aspx

  • Custom User Avatar

    it passes the tests indeed that doesn't mean that the test are right, with the current test you'll never see any results with the letters J,K,L,M,N,O,P....

    from "So we extend 0..9 with letters A to Z. With these 36 digits we can code up to 36! − 1 = 37199332678990121746799944815083519999999910 (base 10)"

    let me put it this way, whats the factorial of 21 ?
    51,090,942,171,709,440,000

    thats a bigger number than what long supports, and we are supposed to support factorial of 36

  • Custom User Avatar

    Where does this big number come from? In C# long are sufficient to pass the tests.

  • Custom User Avatar

    37199332678990121746799944815083519999999910 is not supported with long datatype, I had to use ulong:

    ulong acc = 1;
    ulong[] Factors = Enumerable.Range(1, 36).Select(i => acc *= (ulong) i).ToArray();

    if I use long it overflows and half of the table is negative

  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Great Job, I just started to learn regex, and I find it really useful ( rather than iterate over each caracter and check), it could be a little faster if you replace .sort.pop for .max, I'm still not sure how regex does it, because in order to find all chunks starting with 9 and 4 more digits it still needs to iterate over all the array, so Im not sure why my solution is slower, maybe because the regex is executed in a binary library rather than interpreted like ruby ?