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 ?This comment is hidden because it contains spoiler information about the solution
Sample test contains an incorrect test case that doesn't appear in the actual tests:
all single digits are narcisitic because anything to the first power is equal to itself or
x^1 = x
7 is narcisitic because of the following.
7 has one digit so I sum that one digit raised to the first power
for comparison
IDK what language you are using, but are you taking a string and seperating the characters into an array of numbers?
If so, then your numbers may be encoded as ascii numbers and are being turned into their integer equivalents, which would explain the constant shift.
With so little information, and no code to read, that is all I can guess about.
Sorry, I meant to point out that you can recompute the sqrt every time you find a divisor to further shrink the iteration count. See my solution.
While figuring out how to format my critique, I think I forgot the reason I started writing it, and ended up spewing some nonsense.
I'm not very good at giving advice or tips or knowing when to give any, and would love any input on how to improve.
Sent from my IPhone
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Because what kind of language would have built in to hex functionality? ;p
Your solution for median time is really cool. I simply halfed it and then floored one and ceiled the other, which isn't as cool as your solution. I also like the way you do format strings, putting parethesis around a string and then calling format with it. I think it looks nicer than
string.format("")
If there was one thing I would change it is that you don't store the size of times. You only need to calculate it once since you don't change its size after you fill it. You used
#times
in 5 different places without the size ever changing. You could have used it once and put it in a variable, and then used the variable.The other thing I really liked about your solution was how you added the sums together while retrieving them so that you could calculate the mean without a seperate for loop for adding all the sums together.
One thing I didn't like so much was that you used
times\[#times+1] = time
instead oftable.insert(times, time)
The last thing that I thought you did better was put the format function outside of the main function, I put it inside, meaning I was recreating the format function with every call of the main function.