Ad
  • Custom User Avatar

    And I think your random tests are so much wrong. I cannot put screenshots here, so I'll push the text with Console.logs(). My previous code version did the calculations correctly, but your tests showed issue when:

    frac1 = -32783 / -87302
    frac2 = -70901 / 96443

    They expect "377758809/631610602" (positive).
    My correct output is "-377758809/631610602" (negative).

    Similarly another example:

    -53524/-96771
    -76017/4842

    Test Failed
    Assert.That(Kata.divideFractions(randomFrac1, randomFrac2), Is.EqualTo(expected))
    Expected string length 20 but was 21. Strings differ at index 0.
    Expected: "259163208/1233693485"
    But was: "-259163208/1233693485"

  • Custom User Avatar

    Wtf are these tests?

    "The fractions will never be improper."

    Meanwhile your tests:

    55013/-84661

    13455/71078 :)

    or

    -91877/-61523

    82703/79988

    Since when deonomiator having "-" sign is a valid fraction? XD

  • Custom User Avatar

    Have you actually tried testing that claim? I've tested 5 solutions (mine, the linq solution commented on, yours and two others from this comment thread). Only one commenter I tested in this thread (zokeer) has a solution that actually runs faster than the Linq solutions (though at least all the solutions run in linear time against varying string lengths and varying unique character amounts). Both yours and Zub_Son's are slower than the Linq solutions despite commenting on the alleged slowness of it.

    Not only are the Linq solutions easier to write and read, this shows that most people trying to make faster/more optimized solutions end up slower than the naive Linq one. Add in that such optimizations aren't really necessary unless the method is an a hot path and I'll prefer a competently written short Linq solution 90% of the time.

  • Custom User Avatar

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

  • Custom User Avatar

    Regex as best practices? Who da hell upvotes this solution?

  • Custom User Avatar

    Who gives this piece of a bad code "best practices"? He could also name every variable a/b/c/d/e/f....

  • Custom User Avatar

    I did the solution with over 40 lines of code and time complexity was still O(N log (n) ), so looking at this solution is embarrasing

  • Custom User Avatar

    tbh yeah TC is O(nLog(n)) and SC is O(n) when it can be done with nested loops with TC of O(n^2) and SC of O(1) but seems like less code

  • Custom User Avatar

    WHO DA HELL VOTES FOR THE BEST PRACTICES? It's soooooooo SLOW!

  • Custom User Avatar

    Who press the "Best Practices" button? This solution is slower than turtle....

  • Custom User Avatar

    raise it to a positive(?) exponent

    I think it is a bit more complex than that.

  • Custom User Avatar

    Things are even better! By e = -1, you can have a positive number, raise it to a positive(?) exponent, and get a negative result! How cool is that!

    Well, kinda. All it takes is some... imagination.

  • Custom User Avatar

    See solutions
    Crying out of misery

    Literally everyone of us, with some kata, at some point of time

  • Custom User Avatar

    After 2 hours of trying to figure it out myself
    Giving up and came here to search help
    I notice wikipedia article - Complex Numbers
    Quickly reading contents trying to make sense of it all
    I dig deeper into imaginary unit article
    After hour I understand what's going on
    After 30 minutes the code is ready
    Runs without any problems and I submit
    See solutions
    Crying out of misery

  • Custom User Avatar
  • Loading more items...