@ hobovsky ~ Thank you. I originally had created an array of integers for tests with exactly 10% zeroed out, but I thought that to be too complicated at the time. However, I will now keep this principle in mind.
Just a remark: if you generate edge cases based on random chance, it's still possible that you won't generate any, right? Especially when there is many special scenarios but you want to generate only a few instances of each. Much better would be to generate, for example, 90 "normal" cases, 5 edge cases of one kind, 5 of another, and shuffle them. This way you always know that solution is guaranteed to encounter special case of every kind.
The (rand() % 1000) < 100 more accurately acheives a 10% occurence of a==b, although agreed, it is not critical (nor the 50/50 split which just felt balanced).
I just wanted to finally translate my own Python solution because at first I used my translation of Python code by monadius (because I knew I could rely on it) and that code does still remains in place as the reference solution.
This page displays the original translation. Updates were made in the kata editor and are fully active with no need for any futher action, unless there remain any alterations you would like me to make.
When I did the translation, a == b was not tested. If it is now, then this edge case should be tested at least in the fixed tests. I will update the translation.
Rejected by someone (?
@ hobovsky ~ Thank you. I originally had created an array of integers for tests with exactly 10% zeroed out, but I thought that to be too complicated at the time. However, I will now keep this principle in mind.
Just a remark: if you generate edge cases based on random chance, it's still possible that you won't generate any, right? Especially when there is many special scenarios but you want to generate only a few instances of each. Much better would be to generate, for example, 90 "normal" cases, 5 edge cases of one kind, 5 of another, and shuffle them. This way you always know that solution is guaranteed to encounter special case of every kind.
(rand() % 1000) < 100
more accurately acheives a 10% occurence ofa==b
, although agreed, it is not critical (nor the 50/50 split which just felt balanced).Hi mouloud, these two updates have now been done. Also, I put in the new description; hope that looks okay to you.
I forked it -- try to approve that
'alr approved some time ago'
Nice catch, thanks. Looks like I'm getting senile :-) Fixed
Something still wrong with the translation?
The description should be OK (it's the same as the current, so it will not change that).
And yes, I suggest to add the edge case to python and update the random tests too.
Cheers
Updated the translation and added an edge case:
Test.assert_equals(sharkovsky(17, 17), false)
Also updated the random test generator so that in 10% of the cases
a = b
When I did the translation,
a == b
was not tested. If it is now, then this edge case should be tested at least in the fixed tests. I will update the translation.Then I may need to rewrite the solution, because I didn't use the most straightforward options ;-)
.
Loading more items...