Ad
  • Default User Avatar

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

  • Default User Avatar

    I cant see enough test case answers to debug my solution

  • Default User Avatar

    Hey RnNn, your advice really helped me. Thanks for that!

  • Default User Avatar

    Try to think of the easiest way to go from the first index of the output(answer) array which is equal to the total of all of the elements of the input array together => to the next index of the output(answer) array which is the total of all the elements of the input array except for the first element of the input array => to the next index ... also try to avoid moving more than one element during each iteration of a loop such as unshift. If you'd like to try something besides a traditional for loop, there are a couple of array methods that can be used for this problem.
    I want to add a little more info but I don't want to go from just helpful(hopefully) to spoiling. Let me know if this wasn't quite enough and I'll try to add more.

  • Default User Avatar

    So as it turns out floating points go to 18 decimal places which is more than enough for the problem - my problem was python was slightly underestimating the length of each interval which was adding extra step onto my loop! I hope this helps someone!

  • Default User Avatar

    I have the right fomula but I'm struggling to get my answer precise enough. I've tried to use float a lot. My question is - how many decimal places do calculations with floating point values preserve by default?

  • Default User Avatar

    Hi @amirymax , thanks for attempting this kata.

    The numbers in the 2 lists are referring to the widths of the N individual columns and the heights of the N individual rows.

    If you focus on a specific column (say it has WIDTH = 5) and a specific row (say it has HEIGHT = 8) then the "intersection" of that column and that row will define a region on the board that has an AREA 5 * 8 = 40.

    It's much clearer if you refer to the N = 5 example on the kata, with the nice picture:

    1. Use the picture to see if you can match my calculations of the areas. For example, moving from left to right on the top row of the example, there are 5 different regions: 1st one is is WHITE and has area = 1x3, 2nd one is BLACK and has area 1x1, 3rd one is WHITE and has area 1x2, 4th one is BLACK and has area 1x7, 5th one is WHITE and has area 1x1.

    2. Repeat this for the entire N = 5 board, on a piece of paper (it's quick), and see if you can find the values: total white area = 146, total black area = 134.

  • Default User Avatar

    Approved, thanks on behalf of the COBOL fans out there!

  • Custom User Avatar
  • Default User Avatar

    Hi there.
    Im really confused about this test [3, 1, 2, 7, 1, 11, 12, 3, 8, 1], [1, 8, 4, 5, 2, 21, 5, 2, 2, 17] where answer = (1583,1700). I dont really get it. Shouldnt we multiply and add the even indeces for white and odd indeces for black? Cause after adding up the i get (89, 297), separately. Please help, author or anyone else.

  • Default User Avatar

    Thanks for the info!! I'll have another go!

  • Default User Avatar

    Hi @conconTheCoder - Yes this is the expected behavior for the tests; your solution with 2 for loops will pass the BASIC test cases since the maximum size in the basic tests is N = 10.

    In the FULL tests, i.e. when you click "Attempt" in the kata, your algorithm will be tested on values of N = 41,000. This is designed to time out brute force solutions with 2 for loops. The timeout limit is = 12 seconds on Codewars Python katas.

    You can generate a random 41000 x 41000 board on your computer/IDE and see how long your current solution takes with an input of this size! (don't actually do this, it will take hours and/or crash your computer - test your algorithm on boards of size N=100, 200, 300... and notice how much time it is taking to find the solution)

  • Default User Avatar

    @Insisted - done; my original idea with separating the min and max N was to emphasize that N=1 is an important test case, but this is now included in the preloaded Example Test Cases so user will be tested against this N=1 case early on.

    Thanks!

  • Default User Avatar

    I have two for loops in my solution, and despite passing all the cases it says that I timed out

  • Custom User Avatar

    @benjaminzwhite I think it is better to put the input constrain like this N ranges in 1 < N < 40000 (inclusive <= or exclusive <)

  • Loading more items...