7 kyu

sum_eq_n?

257 of 256jastuccio
Description
Loading description...
Arrays
Fundamentals
  • Please sign in or sign up to leave a comment.
  • FArekkusu Avatar

    This is a duplicate.

  • Unnamed Avatar

    @cliffstamp So you've just confirmed the issue and closed it? The random tests can generate it, but they don't do normally.

  • mcmillanator Avatar

    None of the tests check for a number plus itself for example Test.assert_equals([1,2,3,4], 2), false 1 + 1 = 2 is true, but the number 1 only appears once, and should not be added to itself

  • twasden Avatar

    too few test cases allows answers that would fail the requirements with certain arguments.

  • tuckyeah Avatar

    It's not clear what to do when given an empty array with a sum greater than 0 vs a sum of 0

  • jastuccio Avatar

    I thought it would be fun to create a kata and I appreciate all the feedback. My current career path has unfortunately taken me far away from Ruby :( Is there a way to let someone take over this kata so the issues can be resolved?

  • vadviktor Avatar

    This comment has been hidden.

  • ksliu25 Avatar

    The last case was very annoying but made sense, it was just unclear. I'd really prefer if this was elaborated a bit more.

  • spurnaye Avatar

    There are contrasting errors on this Kata Passed [], 0 an empty array should be equal to zero for this method - Expected: true, instead got: false Passed [], 0 an empty array should be equal to zero for this method - Expected: false, instead got: true

  • tickoftheclock Avatar

    This comment has been hidden.

  • taw Avatar

    The "empty array sums to 0" condition is really weird. Do other things sum to zero ever? It feels totally arbitrary as stated.

    Can you count same element multiple times? Does it mean 2 elements (except that weird [] 0 thing), or "up to" 2 elements (and then [] 0 makes some kind of sense)

  • missbassethorn Avatar

    Would be good to have more information returned when a test fails (took me a while to figure out that I hadn't catered for the last option)

  • mlabrum Avatar
    • How should an array with a single number be handled? I assumed it should evaluate to the number. If this is correct, the description should be updated to say "...returns true if any two or fewer elements...".
    • The following test cases (or similar), possibly along with some random cases, should be added; the included answers are based on my assumptions for handling these cases:
      • sum_eq_n?([], 1) => false
      • sum_eq_n?([1], 1) => true
      • sum_eq_n?([2], 1) => false
      • sum_eq_n?([1,4,-1], 3) => true
  • mortonfox Avatar

    The part about the empty array doesn't seem logical to me. It doesn't have two elements to pick.

    That quibble aside, I noticed the kata doesn't test sum_eq_n?([], 1). I messed up on that in my solution and still passed.