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.
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.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.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.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 represent2 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 forma cos^n(x)
. But theSinCos
format wasn’t clear to me at all. I eventually figured out it means the terms should bea sin(x)^n cos(x)^m
wheren + 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
withstaticmethod
makes no sense in Python. Just make it a normal function like any other kata. Theenum
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
andRandom Tests
, show the input ranges and the number of tests — that’s also a solid option.Approved at average rank, outliers ignored.
genius, twice
Very interesting !!
why do you have so much time?
👍
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.
This comment is hidden because it contains spoiler information about the solution
Also, random tests are definitely required. Details below (so I can make a separate, spoiled post)
Well, turns out this kata has a lot of cheese possible: https://www.codewars.com/kata/reviews/621a6ba3ed65eb00011656cb/groups/64ded0a3798ed900010bddd8
Hello,
My advice to all Kata authors, add a proper validator
Hi,
Small advise: don't use that again.
Cheers
Thank you!
I deliberately decided not to provide the "right answer" in the error messages (or the feedback) because:
On another note, I disabled exception raising.
Loading more items...