I also found debugging was not easy during main tests. What you can do is, inside the body of each method, print messages that allow you to know first which method is called, and then whatever you're interested in (arguments received by the method, state of the list at the beginning, state of the list after applying the method...). This way you may find out which operation your code is not doing right.
So I generally agree with the sentiment (especially with geometry/physics katas) but the sum of the first n numbers is such an important formula in the study of algorithms that I think it deserves its place here.
discard = 2
array 0 = 800,1200,2100,4100,1300,700 // discard 800,1200 at start and 1300,700 at end
array 1 = 1000,1500,4500,5000,5800,2000,1500 // discard 1000,1500 at start and 2000,1500 at end
total avg = (2100 + 4100 + 4500 + 5000 + 5800) / 5
Exactly what it says in the description. Random lists are generated, random indexes are called, and random methods are used on the lists. This isn't unusual for a kata. If need be, test it locally. :)
This comment is hidden because it contains spoiler information about the solution
I also found debugging was not easy during main tests. What you can do is, inside the body of each method, print messages that allow you to know first which method is called, and then whatever you're interested in (arguments received by the method, state of the list at the beginning, state of the list after applying the method...). This way you may find out which operation your code is not doing right.
Please use spoiler flag next time.
This comment is hidden because it contains spoiler information about the solution
So I generally agree with the sentiment (especially with geometry/physics katas) but the sum of the first n numbers is such an important formula in the study of algorithms that I think it deserves its place here.
Total average is the average of all valid values:
so true, after this kata i use filter with no math in
Exactly what it says in the description. Random lists are generated, random indexes are called, and random methods are used on the lists. This isn't unusual for a kata. If need be, test it locally. :)
I have no idea what is happening in random tests and how to debug them.
Man, this is a much clearer description
As I understood it [0, 4] are X coordinates and [0, 0] are corresponding Ys.
It's
(0,4)
not(4,0)
, order matters.Python
AFAIK Manhattan distance is calculated |x2-x1| + |y2-y1|.
So at (0,3) with supplys at (0,0) and (4,0) I got:
and
But the answer is 1. Did I misunderstand something? TIA.
AFAICT that is also a magic square. So why isn't it an acceptable answer?
I can't agree more on that mate!
Loading more items...