I believe "≺" should be reflexive, since connexity must hold: ∀ a,b ∈ Set (a≺b or b≺a). It means sharkovsky(a, a) should return True.
If not, an addition to the description should be done anyways.
@ 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.
Hi rowcased, can you take a look at this discourse page and change the tests in your C translation accordingly (that is: add an edge case tester( 17, 17, false ); and update the random test generator so that in 10% of the cases a==b)?
Very elegant!
I believe "≺" should be reflexive, since connexity must hold: ∀ a,b ∈ Set (a≺b or b≺a). It means sharkovsky(a, a) should return True.
If not, an addition to the description should be done anyways.
@ 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).Thank you. I've got 3 questions:
Don't you think it would have been more straightforward to add the line
if(n==6){a=b;}
in the case statements?Why did you change your "complete solution"?
Are these updates already active or do they need to approved/validated?
Hi mouloud, these two updates have now been done. Also, I put in the new description; hope that looks okay to you.
Hi rowcased, can you take a look at this discourse page and change the tests in your C translation accordingly (that is: add an edge case
tester( 17, 17, false );
and update the random test generator so that in 10% of the casesa==b
)?Thank you for the contribution.
I forked it -- try to approve that
'alr approved some time ago'
I'm still unable to approve. The process silently fails. is it because I recently updated the tests in the orginal kata?
I've tried to approve the translation but nothing happened. I will try again later.
Nice catch, thanks. Looks like I'm getting senile :-) Fixed
Loading more items...