5 kyu

Simple Fun #220: Simplified Array

127 of 237myjinxin2015
Description
Loading description...
Fundamentals
View
AllIssues1Questions1Suggestions2Show Resolved
  • Please sign in or sign up to leave a comment.
  • LS2008 Avatar

    Nice kata!

  • Quark Fox Avatar

    Nice kata! Thanks myjinxin2015

  • Nero4761 Avatar

    Kata unsolvable, impossible test assigned - [-3, 4, 5, 2, 0, -10] --> [(-3 + 4), (5 + 2), (0 + -10)] --> [1, 7, -10]

    Given as we're meant to sum intervals of prime or non-prime numbers, this test is wrong. This test claims that -3 and 4 are an interval of a prime or non-prime numbers. -3 is prime while 4 isn't - meaning they shouldn't be sum'd.

    Either this question is impossible or I read the instructions wrong. Would appreciate a reply to help affirm my claim or corret me if I am wrong.

    • Chrono79 Avatar

      That depends on your definition of prime numbers, if they're numbers greater than 1, then -3, isn't one.

    • Nero4761 Avatar

      Ya'know, this was a google search away but I still let my pride win and be so sure of what a prime number is. Gonna delete this to undo the shame. If there is any hope for me. Thanks Chrono79.

  • HerrWert Avatar

    Earlier wthit56 raised a valid question about the description of the ending condition. I see that question was closed, but this is still confusing. The description reads as if you would have to keep repeating the process until the original input array is obtained. But that's not true. I think if this confusion were resolved, maybe more people would try this kata. I would suggest an edit like this: "Repeat the process until there are no intervals of prime or non-prime numbers with a length greater than one." When I assumed this to be the ending condition, I was able to solve the kata.

  • Mongrell Avatar

    This comment has been hidden.

  • FArekkusu Avatar

    Python translation. Please, review and approve (the author is inactive).

  • Boutsen Avatar

    This comment has been hidden.

    • myjinxin2015 Avatar

      Added two testcase:

      Test.assertDeepEquals(simplifiedArray([-3,4,5,2,0,3]),[1,7,0,3])
      Test.assertDeepEquals(simplifiedArray([-3,4,5,2,0,0,0,3]),[1,7,0,3])
      

      Thank you for your advice ;-)

  • Voile Avatar

    Approved

  • wthit56 Avatar

    In the description: if the resulting array is different from the initial one, repeat the process; otherwise return the resulting array. So you keep applying the algorithm until you get the original array you got in the first place? Sounds like you could just return that original array and skip the algorithm altogether! @.@"