7 kyu

Calculate mean and concatenate string

1,405 of 4,319user8476848
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • XoRMiAS Avatar

    JavaScript fork (author gone)

    • Fixes random tests (resolves this issue)
    • Updated to Node 18 and chai
  • LagomarsinoHS Avatar

    In javascript the float "1.0" will be printed as just 1, the last test case never will be achieved

    39 => 3.9

    9 => 0.9

    10 => 1 XXXX

  • rowcased Avatar

    TypeScript:

    • initial code set-up is blank
    • no sample tests
  • saudiGuy Avatar

    random tests are attackable.

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • rowcased Avatar

    This comment has been hidden.

  • FroggyNem Avatar

    Dear all, I am trying this Kata in Python. I may have missed something. But all the samples for testing have an average of "0.0". Is there something wrong? Thank you

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • lbvf50mobile Avatar

    PHP

    In PHP version Random test violates the descriptoin "There will always be 10 integers and 10 characters.".

    Some times there is an array comprises only numbers. And need to multiply mean value by two, or use hardcoded divident 10, not a real ammount of numbers in this array.

    Input 9,2,6,8,9,1,5,7,5,4,10,2,4,8,1,6,0,1,3,4
    Str: 
    Num: 9,2,6,8,9,1,5,7,5,4,10,2,4,8,1,6,0,1,3,4=>4.75
    Failed asserting that two arrays are equal.
    Expected: Array (
        0 => 9.5
        1 => ''
    )
    Actual  : Array (
        0 => 4.75
        1 => ''
    )
    
  • Lupwol Avatar

    For the PHP version, it looks to me like the main tests still test against 2 * the mean while the "sample" tests are still correct. Am I missing something?

  • Chrono79 Avatar

    Why didn't any of the php errors reported raise an issue? The random tests are wrong.

  • KristianT Avatar

    This comment has been hidden.

  • jeremiahbratton Avatar

    For PHP the random tests always expect the mean * 2, fixed tests do not. I see this was brought up a few months ago, it is still an issue.

  • tessa_ Avatar

    In TypeScript, best practice might return a tuple instead of an array.

  • mdfleury Avatar

    I'm unable to pass the testRandom with PHP. The average is always twice what I calculated, and the string is empty, since it's 20 numbers and no strings.

  • Doug Avatar

    Apparently the tests for Java have an issue. When I run them I get errors......


    Test Results: /KataTests.java:13: error: illegal start of type Log @Test ^ /KataTests.java:13: error: expected @Test ^ /KataTests.java:14: error: ';' expected public void mean_BasicTest2() { ^ /KataTests.java:14: error: invalid method declaration; return type required public void mean_BasicTest2() { ^ 4 errors

  • Kaiyou Avatar

    as a floating point number.

    C#: The description is imprecise. Not any floating point number will do, but only 'double'

    Expected: 3.6000000000000001d
    But was: 3.5999999f

  • craftman32 Avatar

    I think that always having 10 integers and 10 characters in the passed in array makes this exercise simplier, but it could be made more difficult and more realistic by passing in a random amount of integers and characters.

  • craftman32 Avatar

    I really liked this exercise, thank you for making it!

  • PranavRaina Avatar

    public static Object[] mean(char[] lst)

    this means that there an array called Object ? or can someone explain this object[] mean part

  • suic Avatar

    Haskell translation kumited. Please review and approve. Thanks, suic

  • dinglemouse Avatar

    FYI - (Java version)

    • The import java.util.* is not needed
    • Typo in method signature string[] instead of String[]
    • Consider if char[] is more appropriate than String[] given the kind of input
    • Decsription says mean should be 1dp but it doesn't seem to be tested
  • donaldsebleung Avatar

    PHP Translation Kumited - please accept :D

  • user5036852 Avatar

    C#-Translation kumited!

    https://www.codewars.com/kumite/57c3ea91e2ddc374620001fc

    Please check and approve it! :-)

  • anter69 Avatar
    • numbers are always integers? if yes, state it in the description; if no, test with floats too
    • rounding is not (properly) checked -- see my solution: it passed without rounding the result...
    • why 10 + 10 elements? why not a random number (e.g. between 0 and 10000)
    • update the kata title to be more precise, e.g. "Calculate mean and concatenate string"
    • description should be more clear, e.g:

    You will be given a list of strings which will include both numbers and characters. There will always be 10 numbers and 10 characters.

    Return a list where the first element is the mean of the numbers (rounded to one decimal place) and the second element is a single string of the characters in their original order.

    ###Example

    lst = ['H', '6', 'e', '1', 'l', 'l', '6', 'o', 'W', '4', 'o', '6', 'r', '1', '2', 'l', '8', 'd', '2', '0']
    
    # returns:
    [3.6, 'HelloWorld']