Ad
  • Custom User Avatar

    Yes, I understand - but why it no passed in attempt ??
    see log report - I print out all arrays and do not understand why expected false at first case (only one "true" and it realy true) and in second case, where no one "true", but it say equal "true"

    ps. it is in golang

  • Default User Avatar

    the test button is just example tests, the attempt button is the full test suite.
    there's nothing weird about passing some tests but not others. that's not an issue.

  • Custom User Avatar

    GO:
    tests passed, attempt - no

    why??

    Click to expand
    should handle basic cases
    Log
    array1: [121 144 19 161 19 144 19 11]
    array2: [121 14641 20736 361 25921 361 20736 361]
    array1 sorted: [11 19 19 19 121 144 144 161]
    array2 sorted: [121 361 361 361 14641 20736 20736 25921]
    true
    array1: [121 144 19 161 19 144 19 11]
    array2: [231 14641 20736 361 25921 361 20736 361]
    array1 sorted: [11 19 19 19 121 144 144 161]
    array2 sorted: [231 361 361 361 14641 20736 20736 25921]
    false
    array1: [121 144 19 161 19 144 19 11]
    array2: [121 14641 20736 36100 25921 361 20736 361]
    array1 sorted: [11 19 19 19 121 144 144 161]
    array2 sorted: [121 361 361 14641 20736 20736 25921 36100]
    false
    array1: []
    array2: []
    false
    Expected
        <bool>: false
    to equal
        <bool>: true
    
    Click to expand
    array1: [80 -13 -57 -17 -47 66 30 58 -17 -25 34 80 10 -15 -43 -21]
    array2: [-34 100 169 225 289 289 441 625 900 1849 2209 3249 3364 4356 6400 6400]
    array1 sorted: [-57 -47 -43 -25 -21 -17 -17 -15 -13 10 30 34 58 66 80 80]
    array2 sorted: [-34 100 169 225 289 289 441 625 900 1849 2209 3249 3364 4356 6400 6400]
    false
    array1: [-97 44 -79 74 78 -55 -63 22 -27 -43 96 62 36 -91 -27 -61]
    array2: [-44 -22 729 729 1296 1849 3025 3721 3844 3969 5476 6084 6241 8281 9216 9409]
    array1 sorted: [-97 -91 -79 -63 -61 -55 -43 -27 -27 22 36 44 62 74 78 96]
    array2 sorted: [-44 -22 729 729 1296 1849 3025 3721 3844 3969 5476 6084 6241 8281 9216 9409]
    false
    array1: [-23 88 -19 42 -59 22 -93 62 20 62]
    array2: [-88 -20 93 361 484 529 1764 3481 3844 3844]
    array1 sorted: [-93 -59 -23 -19 20 22 42 62 62 88]
    array2 sorted: [-88 -20 93 361 484 529 1764 3481 3844 3844]
    false
    array1: [-41 24 34 80 16 48 60 76 66 -11 -43 18 -77 10 80 82 -3 66]
    array2: [9 11 100 256 324 576 1156 1681 1849 2304 3600 4356 4356 5776 5929 6400 6400 6724]
    array1 sorted: [-77 -43 -41 -11 -3 10 16 18 24 34 48 60 66 66 76 80 80 82]
    array2 sorted: [9 11 100 256 324 576 1156 1681 1849 2304 3600 4356 4356 5776 5929 6400 6400 6724]
    false
    array1: [4 -67 48 88 -57 32 -99 -37 -65 -39 94 -29 46 -17 82 -83]
    array2: [16 39 57 289 841 1024 1369 2116 2304 4225 4489 6724 6889 7744 8836 9801]
    array1 sorted: [-99 -83 -67 -65 -57 -39 -37 -29 -17 4 32 46 48 82 88 94]
    array2 sorted: [16 39 57 289 841 1024 1369 2116 2304 4225 4489 6724 6889 7744 8836 9801]
    false
    array1: [82 -29 -75 72 58 8 74 84 40 -15 44 34 38 94 28]
    array2: [-84 29 64 225 784 1156 1444 1600 1936 3364 5184 5476 5625 6724 8836]
    array1 sorted: [-75 -29 -15 8 28 34 38 40 44 58 72 74 82 84 94]
    array2 sorted: [-84 29 64 225 784 1156 1444 1600 1936 3364 5184 5476 5625 6724 8836]
    false
    array1: [-77 -27 -95 28 -87 -61 -71 42 6 -51 14 34]
    array2: [-42 36 61 196 729 784 1156 2601 5041 5929 7569 9025]
    array1 sorted: [-95 -87 -77 -71 -61 -51 -27 6 14 28 34 42]
    array2 sorted: [-42 36 61 196 729 784 1156 2601 5041 5929 7569 9025]
    false
    array1: [-29 -19 -25 -53 -99 -35 2 -17 -31 14 52 16 -17 18 42 -65]
    array2: [-42 4 65 196 256 289 289 324 361 625 841 961 1225 2704 2809 9801]
    array1 sorted: [-99 -65 -53 -35 -31 -29 -25 -19 -17 -17 2 14 16 18 42 52]
    array2 sorted: [-42 4 65 196 256 289 289 324 361 625 841 961 1225 2704 2809 9801]
    false
    array1: [12 -31 -77 -37 80 88 -95 -5 -59 -43 66]
    array2: [-88 25 144 961 1369 1849 3481 4356 5929 6400 9025]
    array1 sorted: [-95 -77 -59 -43 -37 -31 -5 12 66 80 88]
    array2 sorted: [-88 25 144 961 1369 1849 3481 4356 5929 6400 9025]
    false
    array1: [52 36 8 -21 -9 -35 -7 -3 78 26 -51 -61]
    array2: [-78 -52 -36 9 21 49 61 64 81 676 1225 2601]
    array1 sorted: [-61 -51 -35 -21 -9 -7 -3 8 26 36 52 78]
    array2 sorted: [-78 -52 -36 9 21 49 61 64 81 676 1225 2601]
    false
    array1: [-39 -23 -39 -87 -49 -47 -91 2 -7 46 64]
    array2: [4 49 529 1521 1521 2116 2209 2401 4096 7569 8281]
    array1 sorted: [-91 -87 -49 -47 -39 -39 -23 -7 2 46 64]
    array2 sorted: [4 49 529 1521 1521 2116 2209 2401 4096 7569 8281]
    false
    Expected
        <bool>: false
    to equal
        <bool>: true
    
  • Default User Avatar

    @rowcased Thanks, I solved it using try-catch block.

    @natan Thanks for suggestions.

  • Default User Avatar

    @natan I'm not sure how it would be, other that my comment was a bit vauge. Getting that exception means null is present and the user has attempted an action on null that's not allowed. So, they have to track that down. Knowing that the parameter is an array narrows the search... well, it's tuens out it's the input, hence the unexpected exception. I already knew the 4th test had null. In any case, the OP has solved it, possibly from my hinting, I suppose. (FYI the exception did not provide a line number)

  • Default User Avatar

    your nested conditions are difficult to track and will hurt any reasoning you do about the rest of the code. you can write those conditions as early exits instead, without nesting the rest - thereby keeping it sequential:

    if bad:
        return False
    next thing
    

    you've done some printing which is good but maybe you're not printing the relevant pieces of information. if you write out step by step what the program is doing then you can tell from the output where it's going wrong.

    looks like you've since found the bug - you would see through printing that you had very small differences between the values that you compared, this is because floats are typically approximations, and it's incorrect to test wether two approximations are exactly equal

    another thing is to avoid the word "wrong" and instead describe the problem in terms of what happened differently from the desired outcome.

  • Default User Avatar

    try it and find out

  • Default User Avatar

    @rowcased I feel like that's a bit misleading considering the arguments involved here. not sure if you've looked at test4 for C# but I know I'd be confused by what you wrote

    @BrandoL keep in mind that you can print from within your solution. also consider carefully the error message and maybe you have a line number/location for it as well which might tell you a lot about what's happening. reading the instructions may also help since this situation is mentioned there.

  • Custom User Avatar

    Hi, Ema! I don't know if it's actual for you. But try to read the description more carefully. Parameters of function can be null and not only array.
    So, first of all you need to check if any of given parameter is null.

  • Default User Avatar

    the error message is telling you something.

    • a null exception has occured.
    • the value cannot be null.
    • the parameter is an array

    ergo

    • an array cannot be null
  • Default User Avatar

    I can't pass 4. test.
    System.ArgumentNullException : Value cannot be null. (Parameter 'array')

    May you tell numbers for 4. test?