Ad
  • Custom User Avatar
  • Custom User Avatar

    You must cut this log in pieces of length [3, 6, 26] (35) and value [8, 17, 80] (105). Hope this helps! ;)
    From what you said it seems the misunderstanding is that you think you can cut the log only once. Of course you can cut it any time you want, that's what makes the difficulty of this kata (avoiding the O(n²) complexity)

  • Custom User Avatar

    Sure hope this isn't a stupid question. I'm passing all the sample tests except for the last one that was commented out. It says it should be 105, but I'm getting 104.

    Can someone please explain to me why cutLog(p, 35) is supposed to return 105 and not 104? Even going through it manually, I can't find any pair that adds up to 105.

    Here's p:

    // indxs:  0    1    2    3    4    5    6    7    8    9  ... and so on
    ------------------------------------------------------------------
    var p = [  0,   1,   5,   8,   9,  10,  17,  17,  20,  24, // 0X's
              30,  32,  35,  39,  43,  43,  45,  49,  50,  54, // 1X's
              57,  60,  65,  68,  70,  74,  80,  81,  84,  85, // 2X's
              87,  91,  95,  99, 101, 104, 107, 112, 115, 116, // 3X's
             119] // 40th element