Ad
  • Custom User Avatar

    That´s exactly my case here... I just cannot give up yet, but I keep on staring at the code and wondering if it´s the serve´s fault

  • Custom User Avatar

    You can't rearrange the words and they have to be consecutive in the array.

  • Custom User Avatar

    Sorry, but I had the same question, and I do not see why your question is wrong. '3452' is shorter than 'wkppv'. Why is the former included and not the latter?

  • Custom User Avatar

    Sorry, I noticed I had sorted the array before printing final result.
    However, I still hope for the instruction to be clearer for people like me, who thought of sorting array based on its length or alphabet order, which would still be applied for the "abigailtheta" example.
    I had also spent a long time fixing error because I thought for multiply cases with the same length, the choosen element would be in alphabet order.

    Edit: I have to expand this question with another issue:

    Failed asserting that two strings are equal.
    Expected: 'ixoyx3452zzzzzzzzzzzz'
    Actual  : ' index 0 with value it index 1 with value wkppv index 2 with value ixoyx index 3 with value 3452 index 4 with value zzzzzzzzzzzz and 3'
    

    This time, I did print out the first $strarr. My assumption is the test array would be $strarr = ['it', 'wkppv', 'ixoyx', '3452', 'zzzzzzzzzzzz'].
    Why wouldn't 'wkppv' be chosen, even though it had the same length as 'ixoyx', stayed first in index order and was longer than '3452'?

    Edit2: Okay, problem fixed. I realize the problem was not the code, but me being a dum-dum who couldn't understand english word. Sorry.

  • Custom User Avatar

    You're wrong, print the input to see it, you shouldn't change the order of the strings.

    Array
    (
        [0] => wlwsasphmxx
        [1] => owiaxujylentrklctozmymu
        [2] => wpgozvxxiu
    )
    

    'wlwsasphmxx' + 'owiaxujylentrklctozmymu' = 'wlwsasphmxxowiaxujylentrklctozmymu'

  • Custom User Avatar

    Working with PHP 7 here.
    After multiple failure, I had tried to see exactly which array was being tested, and here is the result:

    Failed asserting that two strings are equal.
    Expected: 'wlwsasphmxxowiaxujylentrklctozmymu'
    Actual  : ' index 0 with value owiaxujylentrklctozmymu index 1 with value wlwsasphmxx index 2 with value wpgozvxxiu and 2'
    

    So apparently the tested array is $strarr = ['owiaxujylentrklctozmymu', 'wlwsasphmxx', 'wpgozvxxiu'] and $k = 2.

    You would think the result would be "owiaxujylentrklctozmymuwlwsasphmxx", but no, it's "wlwsasphmxxowiaxujylentrklctozmymu".
    Be it an index order or alphabet order, that's plainly wrong. By the way, this is in the basic test.

  • Custom User Avatar

    I don't think without "return" you can send any output with this method.

  • Custom User Avatar

    To any future PHP fella who got the "Execution Timed Out" error: It's not because of the server, or the question. Think of all possibilities and try your best (even if it took you 2 hours just staring at the code and wondering why you didn't just spam "unlock solutions" button already)

  • Custom User Avatar

    I have no idea the test in testBasics is different from sample test, thus the misunderstanding. Thanks for the clarification.

  • Custom User Avatar

    OK, thanks.
    You are not failing this test:
    $this->revTest(bouncingBall(30.0, 0.66, 1.5), 15); but this one (not in "RUN SAMPLE TESTS" but in fixed tests of "SUBMIT":
    $this->revTest(bouncingBall(30, 0.75, 1.5), 21);.
    If you had printed the input and your output you could easily have seen that...
    In the description you have read:

    The ball bounces (for example), to two-thirds of its height (a bounce of 0.66).

    But it is only un example (it is written for example).

    Below you should have read:

    Float parameter "bounce" must be greater than 0 and less than 1

    From that you see that bounce is a parameter, not a constant.

    Is that clearer now?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I didn't notice that you were using a custom function for sample and fixed tests, but the "built-in" one for the random ones. Everything's alright then.

  • Custom User Avatar

    I know I could be sometimes wrong (more often than I would...)
    Can you see below?
    I notice that lots of guys passed the PHP translation. It would be weird if nobody had seen that:-)

  • Custom User Avatar

    There is something I don't understand. PHPUnit test definition is: assertEquals(mixed $expected, mixed $actual[, string $message = '']) and when you "RUN SAMPLE TESTS" the function "$this->revTest(bouncingBall(30.0, 0.66, 1.5), 15);" gives (look the definition of revTest) $this->assertEquals(15, bouncingBall(30.0, 0.66, 1.5));. Hence "expected" is 15.
    I would have understood you got "Failed asserting that 21 matches expected 15." No offense but did you exactly copy what PHP Unit returns?
    Could you post your code with three backticks at the beginning and three others at the end so that your code is correctly indented? Moreover mark your code as spoiler. Thanks.

  • Custom User Avatar

    Not enough information. If you're still having this issue, you can easily investigate it yourself, by limitting the number of loop iterations and logging the changes in your variables.

  • Loading more items...