The kata test solutions are wrong, no? Shouldn't this Kata also include distance if j is 0 and i is len(data)?
e.g: Expect(LargestDifference([]int{78, 88, 64, 94, 17, 91, 57, 69, 38, 62, 13, 17, 35, 15, 20})).To(Equal(10))
This should equal 15 as there is a pair of numbers, data[0] and data[14] which are equal to 78 and 20 respectively, so the distance should be len(data).
Please correct me if I'm wrong
I have solved the Kata using recursion, but for some reason it doesn't pass the test even though it passes the test on Go playground and local development, could you check if it works properly?
data[0] = 78 > 20 = data[14]
If
i = 0
andj = 14
thendata[i] <= data[j]
is false, asdata[i] = 78
. Thusj - i
is not to be considered.If conversely
i = 14
andj = 0
thendata[i] <= data[j]
is true. Howeverj-i = 0-14 = -14 < 0
, which means it is not the maximum.(We are supposed to find the maximum
j-i
withdata[i] <= data[j]
, not the maximumabs(j-i)
)The kata test solutions are wrong, no? Shouldn't this Kata also include distance if j is 0 and i is len(data)?
e.g: Expect(LargestDifference([]int{78, 88, 64, 94, 17, 91, 57, 69, 38, 62, 13, 17, 35, 15, 20})).To(Equal(10))
This should equal 15 as there is a pair of numbers, data[0] and data[14] which are equal to 78 and 20 respectively, so the distance should be len(data).
Please correct me if I'm wrong
What do you want to be checked? I saw that you passed the kata... Furthermore asking for something is not an issue, sorry!
Hello,
I have solved the Kata using recursion, but for some reason it doesn't pass the test even though it passes the test on Go playground and local development, could you check if it works properly?