The collection is empty, so, there are no pages and no items, pageIndex should return -1 because there were no pages and pageItemCount from page 0 should also return -1 because it's an invalid page.
Your code also have problems with the previous tests, it fails to return 0 for item 3 with pageIndex method. Not a kata issue.
This kata helps force people to reevaluate how many passes their code does on the list in question. If you have nested loops, you'll likely hit timeouts for the lists with 10,000,000 elements, since even the fastest computers can't parse 10 million ^ 2 elements in a reasonable timeframe.
Because 0 is the item index, not the item itself.
When collection is 1...24, why in one of the test case (doTest(helper, 'pageIndex', 0, 0);).
Position of 0 is on 0th page? when 0 is not even there!
Your code is failing these sample tests:
The collection is empty, so, there are no pages and no items, pageIndex should return -1 because there were no pages and pageItemCount from page 0 should also return -1 because it's an invalid page.
Your code also have problems with the previous tests, it fails to return 0 for item 3 with pageIndex method. Not a kata issue.
ok, i understand there can be empty array in collection. but just clear out, when it should be 0 and when it should be -1
I don't think it's an issue:
It means it can be anything. Read the post below yours.
In JS: Why collections are empty and trying to find number in test?
What is the format of Error.getting this:
"alloc should return pointer: expected undefined to be a number or a date"
Read this: https://www.codewars.com/kata/529bf0e9bdf7657179000008/discuss#5e5d7cd837738b00289583e9 That's not the input of the test your code fails.
Test/Attempt is not working:
Expected 'true' on input of
: expected false to equal trueOP solved the task, closing
This kata helps force people to reevaluate how many passes their code does on the list in question. If you have nested loops, you'll likely hit timeouts for the lists with 10,000,000 elements, since even the fastest computers can't parse 10 million ^ 2 elements in a reasonable timeframe.
I suggest looking up "memoization" :)
no throwing: Execution Timed Out (12000 ms)
i working amiwith for loop. Is this wrong for this kata should i use map or for each
no i am not printing alot. The error happened, thats why i printed.
you are possibly printing a lot. if so, silence the print statements and try again
Program is throwing error:
Max Buffer Size Reached (1.5 MiB)
Last attempt of array ([13,3,1,1,1,1,1,1,1,1,1,1,1,1...] , 13) does not complete;
Loading more items...