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.
I made this a long time ago. But if I remember correctly, the distance from from cell 1 to cell 2 must always be computed not by abs(x2-x1) + abs(y2-y2) but instead more precisely with pythagorean's theorem sqrt((x2-x1)^2 + (y2-y1)^2)
Using this formula, the distance of the three spaces in your example from the target or start would be 2, ≈1.41, and 2.
So if i remember the kata correctly, the correct answer is the middle one of those three or (1,1) because it is the closest box within the circle of radius = 2 to the target box (2,2)
I don't understand. Take a look at the following setting :
where
$A$
is where you start from and$B$
is the target cell. The cells with the cross$\times$
inside are all equally distant from the target. This means the kata is not consistent as it assumes that there can be only 2 equidistant cells. Am I missing something ?Done ! :)
PRESS
How ? I don't have the Republish button anymore --- only Publish ? Should I press it ?
A reminder: Do not forget to republish this kata.
This comment is hidden because it contains spoiler information about the solution
Everything works now. Don't forget to republish the kata.
By the way, there is another way to solve the problem with local variables:
Local variables are declared inside the
for
block and they are different for each loop iteration.Looks good now.
What about now ? BTW
"and large random tests with the current values of n_0 and T"
I don't quite understand what does the current values mean here :)
Ah, I see. the
same
function has the message parameter. Thank you !Did you try to print values of
n_0
andT
in the solution function? If you print these values you will see that all values are the same in random tests. The test labels are different because they are computed outside callback functions.I don't know much about tests in Lua but many existing Lua translations put all random tests inside a single
it
block and add custom messages to assertions:Do you mean instead of
do this
? In the latter case I don't know how to provide the values of
n_0
andT
to the user. Could you provide an example of such a test ?"Right now, the same values of n_0 and T are tested for all random tests "
I don't understand. I see different values for every test.
Loading more items...