• ###### Klelikresolved an issue on "Linear Movement Destination Solver" kata

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)

• ###### LRDPRDXcreated an issue for "Linear Movement Destination Solver" kata

I don't understand. Take a look at the following setting :

\begin{matrix}
\circ & \circ & \times & \circ & B \\
\circ & \circ & \circ & \times & \circ \\
\circ & \circ & A & \circ & \times \\
\circ & \circ & \circ & \circ & \circ \\
\circ & \circ & \circ & \circ & \circ
\end{matrix}


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

• ###### LRDPRDXcommented on "The size of a sand pile" kata

How ? I don't have the Republish button anymore --- only Publish ? Should I press it ?

• ###### monadiuscommented on "The size of a sand pile" kata

A reminder: Do not forget to republish this kata.

• ###### LRDPRDXcommented on "Matrix Determinant" lua solution

This comment is hidden because it contains spoiler information about the solution

• ###### monadiusresolved an issue on "The size of a sand pile" kata

Everything works now. Don't forget to republish the kata.

By the way, there is another way to solve the problem with local variables:

describe('Random tests', function()
for _ = 1, 20 do
local n_0, T = math.random(0, 10000), math.random(4, 100)
it(string.format("n_0 = %d, T = %d", n_0, T), function()
assert.are.same({ref(n_0, T)}, {s.pile_size(n_0, T)})
end)
end
end)


Local variables are declared inside the for block and they are different for each loop iteration.

• ###### monadiusresolved an issue on "The size of a sand pile" kata

Looks good now.

• ###### LRDPRDXcommented on "The size of a sand pile" kata

"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 :)

• ###### LRDPRDXcommented on "The size of a sand pile" kata

Ah, I see. the same function has the message parameter. Thank you !

• ###### monadiuscommented on "The size of a sand pile" kata

Did you try to print values of n_0 and T 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:

it('Random tests', function()
for _ = 1, 20 do
local n_0, T = math.random(0, 10000), math.random(4, 100)
assert.are.same({ref(n_0, T)}, {s.pile_size(n_0, T)}, string.format("n_0 = %d, T = %d", n_0, T))
end
end)

• ###### LRDPRDXcommented on "The size of a sand pile" kata

n_0, T = math.random(0, 10000), math.random(4, 100)
it(string.format("n_0 = %d, T = %d", n_0, T), function()
assert.are.same({ref(n_0, T)}, {s.pile_size(n_0, T)})
end)


do this

it(string.format("n_0 = %d, T = %d", n_0, T), function()
local n_0, T = math.random(0, 10000), math.random(4, 100)
assert.are.same({ref(n_0, T)}, {s.pile_size(n_0, T)})
end)


? In the latter case I don't know how to provide the values of n_0 and T 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.