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 guess your writing style is as good as that solution you were talking about lol
As this is my first ever kata, the issues were inevitable. Thanks for your suggestions.
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.The user solution is called twice per test on the random tests. This is both unnecessary and confusing for the user. Just save the returned value to a variable, then do your thing.
Honestly, I'm not even sure why you're doing all this
number_of_true
andnumber_of_false
stuff at all, just dofor _ in range(150)
and you'll get the same result.Also, the tests should providee a helpful message upon failure, use a message like
Solution failed for input=<serial_number>
or something similar, rather than justRogues succeeded
.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.Great math kata.
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.You sly cheater! 😜
But indeed, the test suite should be improved so that your solution is rejected.
Moreover, there are less than 81 valid outputs, this makes the problem worse.
This comment is hidden because it contains spoiler information about the solution
Yes, this is regarding Python. Just have a solution like
jump_to_zero = lambda x: x
and hit attempt. It will reach max buffer size.Is this for Python, I don't see such logs?
I agree with B4B here, I couldn't solve it until I ran the random tests. The
Basic Tests
were a plain waste of time.Though, to be honest, I never enjoy these "Thinking and Testing" katas.
Oh, I understand. No worries my wording could have been better.
Yeah, that warning would be very unnecessary. What the user does is their problem.
Sorry, I misunderstood your first post. I thought you were saying the author should add a warning to the description that warns users not to print every input. I see now that you meant that the tests should not output the full contents of very large arrays.
Loading more items...