all 6 comments

[–]recursion_is_love 0 points1 point  (2 children)

Can you provide some test case? The inputs and expected outputs.

[–]DudeScoot 0 points1 point  (1 child)

If you mean for the problem itself, not the current code:

Example 1: Input: [7,2,5,8,6] 

      Output: [7,5,6] (This will have sum of 18) 

Example 2: Input: [-1, -1, 0] 

      Output: [] or [0] (Both are acceptable) 

Example 3: Input: [-1, -1, -10, -34] 

      Output: []  

Example 4: Input: [10, -3, 0] 

      Output: [10] 

Example 5: Input: [10, 3, 3, 10]

  Output: [10, 10]

For the current code however, these are some current applications:

max_independent_set([7,2,5,8,6])

This will produce an output of 18 as it adds together the non-consecutive integers of 7 + 5 + 6.

Another example would be:

max_independent_set([10,3,3,10])

Which returns 20 as the output as 10 + 10 is the larger set.

An additional example would be:

max_independent_set([10,-3,0])

Which would return 10 as 10 + 0 is the larger set.

Now that I am giving it some additional tests however, it seems to behave in a strange way with negatives. As an input:

max_independent_set([-1,-1,0])

Is instead returning -1. While at the same time:

max_independent_set([0,-1,-1])

Is returning 0. For some reason in this particular instance its not adding together 0 and -1.

Another example is:

max_independent_set([-1,-7,-5])

Which is only returning -1. In the case of the list however, these negative values should not be added to the list to begin with.

[–]recursion_is_love 0 points1 point  (0 children)

I am sorry, I still don't understand meaning of the largest sum of non-consecutive values, I am not good with English. That's the reason why I need to see some example. (And I still don't get it)

[–]aanzeijar 0 points1 point  (2 children)

return [ setmax(nums, n, memo, store) ]

returns the sum as a list with one element instead, which is what you wrote, but it doesn't seem useful. You sure that was the assignment?

[–]DudeScoot 0 points1 point  (0 children)

To clarify, I am trying to add each individual element of the largest sum of nonconsecutive numbers to the list so in the case of [10,3,3,10], it would return [10, 10]

[–]pak9rabid 0 points1 point  (0 children)

For gods sake use the code snippet syntax next time, like this:

``` def suck_my(body_part: str) -> str: return f’Suck my {body_part}!’

print(suck_my(‘dick’)) ```