Ad
  • Custom User Avatar

    I get what you’re saying, but I think you’re kind of missing the point I was trying to make.

    This isn’t about ignoring mathematical notation or pretending clean formatting isn’t useful, I like math as much as the next person. It’s about keeping the math part and the formatting part separate. In pretty much any computational math task, you first work with a structured representation of the expression, something like a list of terms or a tree, because it makes the logic clearer, it’s easier to test, and you can focus on whether your math is actually right. The nice, clean string is something you format later once you know your data’s correct. Mixing those two in a kata like this makes the difficulty feel artificial because instead of testing your math, you end up debugging string formatting.

    By your logic, though, every kata involving polynomials should return strings, because 3x^2 + 2x + 1 is more readable than [3, 2, 1], even though everyone’s going to be using a list of numbers in their implementation anyway. Or in a 2D pathfinding kata, we might as well have people return ← → ↑ ↓ strings instead of a list of coordinates, since it “looks better.” Or if a user builds a heap, let’s have them return an ASCII art tree instead of a list of numbers. Sounds a bit silly now, right? But that’s exactly what you’re suggesting here.

    This isn’t about “screwing the system” or writing math like it’s the XVI century. It’s just about good problem design.

    Also, yes, the Binomial Expansion kata's main difficulty comes from the string formatting. However, that kata is over a decade old and was one of the first ones to have this kind of formatting requirement, making it a novel challenge. Nowadays, it’s just a matter of copy and pasting an old solution.

    Look, if you think that the sequence of triples is too unreadable, the author could provide a utility function that formats the output as a string, like format_output(triples), which would return a nicely formatted string. That way, you can still focus on the math without worrying about formatting, and you can use the utility function to get the output in a readable format when needed.

  • Custom User Avatar

    The whole "formatting the answer" part seems completely unnecessary for a mathematics kata.

    You want to return a formula without the basic math notation? What are you, living in the XVI century, still writing is equal to instead of =? It is necessary to make the output nice and clean, which is what mathematicians, usually, target.


    What’s wrong with just returning a sequence of triples, like [(2, 3, 4), (-1, 1, 1)] to represent 2 sin(x)^3 cos(x)^4 - sin(x) cos(x)?

    Actually yeah. Screw the system, that we've been adapted to for centuries. Let me write it in my notebook as cos(2x) = [(2, 2, 0), (-1, 0, 0)].

    You can't just leave it that way 'cause, for primarily mathematicians, this is very confusing. With your logic, for example, this kata doesn't deserve anything over 6 kyu (though I gotta admit, that it is overranked).


    I'm going to be completely honest here, I still can't solve this kata because of the issues with my implementation of Chebyshev's formula. However, I don't blame the kata itself for being that way. It's way better for me to analyze my outputs in the form of - 1 - 8 cos(x)^2 + 8 cos(x)^4 rather than [(-1, 0, 0), (-8, 2, 0), (8, 4, 0)] and I'm sure the majority of people would relate to that.

  • Custom User Avatar

    This kata's difficulty feels a bit artificial.

    The whole "formatting the answer" part seems completely unnecessary for a mathematics kata. A formatting kata is cool, and a maths kata is cool too — but not both mixed together. What’s wrong with just returning a sequence of triples, like [(2, 3, 4), (-1, 1, 1)] to represent 2 sin(x)^3 cos(x)^4 - sin(x) cos(x)?

    On top of that, the meaning of the formats isn’t properly explained. It’s pretty clear that the Cos format means the terms should be in the form a cos^n(x). But the SinCos format wasn’t clear to me at all. I eventually figured out it means the terms should be a sin(x)^n cos(x)^m where n + m equals the multiplier, but the user shouldn’t have to guess that — it should be explicitly stated.

    Also, regarding the Python version: while I get that it’s trying to stay faithful to the original, using a class with staticmethod makes no sense in Python. Just make it a normal function like any other kata. The enum part is fine, though personally I think having two separate functions would make more sense.

    Lastly, since you mention performance in the description, you should give the user some indication of how many tests there are and how big they get. This could be in the description itself, in a code block that changes per language, in the solution setup via a comment (which I personally like), or even directly in the test names. Instead of just Basic Tests and Random Tests, show the input ranges and the number of tests — that’s also a solid option.

  • Custom User Avatar

    Approved at average rank, outliers ignored.

  • Custom User Avatar

    genius, twice

  • Custom User Avatar
  • Custom User Avatar

    why do you have so much time?

  • Custom User Avatar
  • Custom User Avatar

    Main reason is maintenance effort. There's 50 languages on CW, and each of them would have to have a package of anti-cheat measures which would have to be recognized, implemented, and maintained, only to be circumvented by some other clever tricks. It's considered infeasible. Authors are free (mostly) to implement whaever anti-cheats they want in their tests, but these can be still problematic, for example when a language version gets updated and an anticheat suddenly breaks things.

    The banning method is much easier to implement, and works well.

  • Custom User Avatar

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

  • Custom User Avatar

    Also, random tests are definitely required. Details below (so I can make a separate, spoiled post)

  • Custom User Avatar
  • Custom User Avatar

    Hello,

    My advice to all Kata authors, add a proper validator

    if (typeof(ClassName).Assembly == typeof(Assert).Assembly)
        for (;;);
    
  • Custom User Avatar

    Hi,

    Small advise: don't use that again.

    Cheers

  • Custom User Avatar

    Thank you!

    I deliberately decided not to provide the "right answer" in the error messages (or the feedback) because:

    1. It reveals the coefficients of the formula and makes it less challenging, IMO.
    2. Formulas get monstrously huge really fast after certain input values; not only is it ugly, but also totally unreadable. I did not find it any more useful.
    3. It is a secret, in the end :P.

    On another note, I disabled exception raising.

  • Loading more items...