7 kyu

Sum of Odd Cubed Numbers

4,603 of 10,848elliottmck
Description
Loading description...
Fundamentals
Functional Programming
Arrays
  • Please sign in or sign up to leave a comment.
  • KevinTap Avatar

    Description Suggestion JavaScript
    If the input array contains anything other than integers, then return undefined.
    Iterate through the array cubing each element meaning e3 or e*e*e.
    Grab only the odd cubed elements and return the sum.

  • o2001 Avatar

    The returning undefined aspect of this Kata is a hindrance and it's problematic tbh

  • SS-Stefanov1 Avatar

    Why would this test suppose to return 0 ?

    Test.assertEquals(cubeOdd([-3,-2,2,3]), 0);

    3 * 3 * 3 = 27?

  • ShuryginDM Avatar

    Find the sum of the odd numbers within an array, after cubing the initial integers

    but

    The function should return undefined/None/nil/NULL if any of the values aren't numbers

    so, what if number is float (not equal to its integer part)? It is a number, but it is not an odd number (even or odd are defined only for integer) Seems like, text might be "The function should return undefined/None/nil/NULL if any of the values aren't integers" and there must be any test with float (at least there are none of those in python version)

  • pitcherZiba Avatar

    Fourth basic test failed while all random tests are passed in Python. Can anyone help?

  • LordPriyansh Avatar

    This comment has been hidden.

  • farhanaditya Avatar

    JS:

    The function should return undefined/None/nil/NULL if any of the values aren't numbers.

    JavaScript has both undefined and null.

  • Mohamed Sadiq Avatar

    This comment has been hidden.

  • cvile988 Avatar

    Great try - except example

  • this_is_qwi Avatar

    y, errors in test: assertEquals(0, FindOddCubes.cubeOdd(new int[] {-3, -2, 2, 3})); Must be -19(-3^3+2^2=-19, not 0); expected:<0> but was:<-19>

  • Alienpruts Avatar

    Just a quick feedback : perhaps make the description a bit more detailed :

    I had to look up what cubed numbers mean, and perhaps one example wouldn't hurt :)

  • user8801027 Avatar

    Maybe it's just me, but I found the wording "the odd numbers" confusing. I thought it meant the odd array entries (ie the 1st, 3rd, etc). It was even more confusing because the first test case gives the same answer. Maybe shuffle the the numbers in the first test case, or make it clear you mean the numbers that are odd.

  • Lerie Avatar

    This comment has been hidden.

  • keliope Avatar

    This comment has been hidden.

  • Kot-Kot Avatar

    Rather strange behavior of the checker. Below my Log and test error.

    Log

    int arr[] = [3, 23, 32, 43] Math.pow(el, 3) = 27.0 Math.pow(el, 3) = 32768.0 sum = 32795

    expected:32795 but was:91701


  • Bubbler Avatar

    This comment has been hidden.

  • dancrowley251 Avatar

    Also, it should be rewritten to be more consistent with numbers versus integers.

  • alexis Avatar

    I saw some of the "correct anwsers" and they should not be accepted. Please, someone write this test:

      Test.assertEquals(cubeOdd(["12","9"]), undefined);
    

    Edit:

    This chanllenge needs to be rewriten if you really want to return undefined if any of the values aren't numbers.

  • jamespatrickpage Avatar

    This comment has been hidden.

  • MacSmo Avatar

    Anyone managed to complete this in Java? I am not sure how to return 'undefined' from function which return int.

  • Unnamed Avatar

    In Python random tests:

    Testing for [-7, 0, -1, True, True, True, 3, True, True, -4] It should work for random inputs too: -312 should equal None

    That's interesting because bool is an int but at the same time may not be considered a number. Whatever the intended expected behavior is, I suggest that there should be a static test like this.

  • kizmoz Avatar

    Hi, sorry if this is a really basic question, I'm quite new to the site.

    I've tried making a code for this but I keep getting the error "729 should equal None"

    Does this mean that cubeodd([725]) should return None? If so, is this because for it to be a "sum" it should have at least two or more components?

    If that's the case I added a bit to the code to return None if the input only contains one element. But I still get this issue. I've tried it in a third party program and it returned None with the input of [729]

  • Souzooka Avatar

    Hi, I've created a C# translation here for this Kata.

  • tamimibrahim17 Avatar

    I dodn't get it , can anybody please explain me in a easy way?

    First, If there is any non integer in array than return None.

    Second, I will sort all odd number from array. Then I will sum up the array , than what?

  • leontank2006 Avatar

    Oops, looks like there is something wrong with your test case, my program went all tests wrong ...

  • GiacomoSorbi Avatar

    Python, Ruby and Crystal translations kumited :)

  • JorgeVS Avatar

    Haskell translation kumited. Please accept ;-)

  • donaldsebleung Avatar

    PHP Translation Kumited - please accept :D

  • hencethus Avatar

    Need to hard-code in a test case where the sum is 0. Some passing solutions would return undefined when 0 was expected.

  • user5036852 Avatar

    Nice first kata! Thanks!