When I started solving this kata (Rust), I thought it was too easy to merit a 2 kyu rating.
Then I started fighting with the poorly written test suite. Christ. Now I see why it's 2 kyu.
It's not enough to meet the explicit requirements. You also have to anticipate how the author thinks about math.
The tests are so finicky. For example, you fail if you express
d
-- ln(f(x))
dx
as
f'(x)
-----
f(x)
instead of the less simple
1
f'(x) * ----
f(x)
And God help you if you don't assume the power operator's second operand is a constant.
Almost did the same thing...but I changed the trait bounds on array_diff to also require that T implement the Copy trait.
Then I used iter and copied instead of just using into_iter like I should have...because I initially misspelled into_iter while trying this exact thing :P
It's funny how so few people have completed this kata when the description spells out the algorithm for you. I guess people find the math jargon intimidating and run away.
No, it doesn't fail. It correctly returns false.
The kata description has "No whitespaces / underscore" as one of the necessary conditions for a true return value.
Edit: Oh! I see what you mean. You're right, it incorrectly returns true.
That's not quite true. If the multiline flag is not set,
$
matches the end of the string or the position before a trailing newline.Fails on inputs that are otherwise valid with a trailing newline such as
'helloworld\n'
hardly elegant to use isalnum, more hamfisted and lazy in context of the kata
When I started solving this kata (Rust), I thought it was too easy to merit a 2 kyu rating.
Then I started fighting with the poorly written test suite. Christ. Now I see why it's 2 kyu.
It's not enough to meet the explicit requirements. You also have to anticipate how the author thinks about math.
The tests are so finicky. For example, you fail if you express
as
instead of the less simple
And God help you if you don't assume the power operator's second operand is a constant.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Almost did the same thing...but I changed the trait bounds on
array_diff
to also require thatT
implement theCopy
trait.Then I used
iter
andcopied
instead of just usinginto_iter
like I should have...because I initially misspelledinto_iter
while trying this exact thing :Pcheck this
This comment is hidden because it contains spoiler information about the solution
It's funny how so few people have completed this kata when the description spells out the algorithm for you. I guess people find the math jargon intimidating and run away.
This comment is hidden because it contains spoiler information about the solution
In Rust, the description doesn't say the returned list needs to be in ascending order, but tests fail if it's not.
Upvoted for the single pass with early return algorithm :)
You can get rid of that awkward
Ord::cmp()
call by replacing.sorted_by
with.sorted_by_key
.Loading more items...