Ad
  • Default User Avatar

    JohanWiltink's suggestion is a good improvement since it corrects the confusion around the second and third parameter.

    And my confusion came from the examples where a third parameter isn't included AND one array is shorter than the other one, in which case the padding is done using 0s. I can see how that was a misinterpretation on my behalf.

  • Default User Avatar

    Bit of criticism: it wasn't made clear (to me, at least) that when a third parameter is supplied, then the padding of whichever array/list is shorted should be done using that third parameter. I assumed it had to be used once, and then (if necessary) pad with 0s.

  • Default User Avatar

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

  • Default User Avatar

    Not sure I understand the final testcase...
    test.assert_equals(alphabet_war(["aaaaa","bbbbb", "ccccc", "ddddd"], ["*", " *", " "]),'ccbaa');
    My code returns 'cccaa', but the test expects 'ccbaa'.
    Step by step:

    1. Field = "aaaaa"
    2. First strike -> "__aaa"
    3. First reinforcement -> "bbaaa"
    4. Second strike -> "___aa"
    5. Second reinforcement -> "cccaa"
    6. Third strike -> "cccaa"
    7. Final field -> "cccaa"
  • Default User Avatar

    If you cast as double precision, the code still passes through.