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.
Funny kata, great to exercise and have fun with, I can't wait to solve and figure out more and better of them.
JS reference solution treats addition as higher priority than subtraction, and probably crucially, division as higher priority than multiplication.
Fixed tests use exact equality, but that's not the problem; random tests use approximate equality.
The problem is expected values get so big that
1e-6absolute error is not enough for approximate equality. Relative errors on the order of1e-16get blown up to absolute errors larger than1e-6.The real problem is testing with an absolute instead of a relative margin, because
chaidoes not offer the correct assertion.I have same code in Python and JS
Python code passed all the tests, but JS code is having too tiny differences like .0000000000000000000000000001 difference in some tests.
It should accept too close results. it is illogical to 0.000000000000000000000000000001 to not pass, lol. (Python tests / difference indicators are different from those in JS)
Need to add one extra test case where there are multiple whitespaces in row.
yeah like ("5++5) and (+9+9)
what do you expect from the successor to java script
i agree!
Seriously a kata 8 kyu in C that forces you to do super stupid memory allocations instead of allowing you to copy string and replace space with nul terminator... Why??? I really hate that most C katas just force you to do dynamic allocation, especially when it makes no sense. It is imho stupid to allocate when you do not need to and it is almost never a good practice to allocate when you are not in control of freeing.
Please do not post solutions in kata discussions, thanks :)
This comment is hidden because it contains spoiler information about the solution
Facilito
Your solution is buggy. You wrote the second initial to the wrong position in the output array. Also, you attempt to null-terminate at an incorrect index, and your output array ends up with incorrect characters. You need to make sure the initials are stored in the correct locations of your output buffer.
By writing out of bounds of allowed buffer, you trigger undefined behavior, which breaks tests completely instead of failing gracefully with readable output.
Example of what the test falsely "expects":
Sam Harris
expected:
A^A_Ðf.�
but got:S.@H
Yeah, I regret writing that translation. The problem with letting the user return nested pointers like
char **is that in good logic they should then also write a corresponding custom freeing function, e.g.void free_words(size_t n, char *words[n]);. But then many users would just leave it blank, because the tests would not check its correctness (it's not impossible to do so, but it is very cumbersome and clunky); so it would make for an awkward kata that asks to write two functions but can only reliably test one of them.I don't like how this kata enforces a specific memory layout of C strings. If it wasn't so strict I could have just stored them back to back in a single allocation and just used the strtok output. That would have been nice
Loading more items...