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.
As I thought after reading the kata's description, there are only two types of numbers in given string:
Thus, numbers like 1.7976931348623157E308, 4.9E-324, 0.4445839983169688 are absent in given strings guaranteed.
Howeher, there are tests with exactly these numbers!
Please, explain.
Published a python translation
added random tests
You want random tests so that other people can't hardcode your test cases
I should indeed be fixing my solution if it is incorrect. It's still not clear to me how a random test is going to help me identify an issue with my solution. The parameters I put into building valid random problems are going to be the same ones I use to build my deterministic tests. Specifically, the limits I place on the random numbers generated are the same limits I use for my edge cases.
Anyway, I'll think about it a little more.
Random tests is a sure fire way to easily reject invalid solutions. It also prevents people from pattern-matching results from inputs.
(Of course, edge case tests are good too, but they're not easy to come up and you don't want to write lots of them yourselves.)
Also, if your solution is incorrect, then you should be fixing it, right? ;-)
I'm really having trouble seeing the value of random tests, at least for this kata. Seems like they would be meant for testing my solution more than other folks', right? The implication is that there are classes of tests that are not covered by the existing (deterministic) tests and the random test might hit one such class of tests. Is that correct?
Any insight appreciated.
oops... :o
Who approved this kata when the random tests aren't done yet?
yep... will keep adding. these are good ones.
ok, I haven't seen the modification of the description.
assertEquals(true, sc.isSurreal("", "")); => should be false (that is... if you keep it... ;) )
Is correct as written. In the def'n of surreal numbers, the empty set on either (or both) sides has special meaning. Note the definition of the form in the description... intersection is the empty set and all elements of L are less than all elements of R. Empty set on both sides satisfies this, but "1" on both sides does not. Empty set on both sides is extra special as it defines "0" in this number system (the first number that is possible to generate).
So, I'm happy to keep the empty string to represent the empty set and follow rules of surreal numbers.
Note that I had added the text:
"One or both strings may be empty and in this case the form represents a valid surreal number and isSurreal should return
true
."prior to adding those tests.
Hope this clarifies. Thanks again for the feedback.
If you want some input about random test, jsut take a look at the test cases of other kata you already solved.
EDIT: Warning, those two are incoherent:
Added max(L) == min(R) cases to tests.
Added empty set ("") tests.
Will leave this open until I get around to writing random tests.
Any pointers to writing random tests? I have never written one. Assuming I have to generate reasoanble random strings of numbers, then use my solution as truth for the return value. Is that about it?
Thanks.
Thanks for feedback. Will work on that.
Loading more items...