Ad
  • Default User Avatar

    The problem comes from your code. You are casting a negative number to usize, which results in a really big unsigned number. And then you use this number as the bound in a loop in which you allocate memory, hence the allocation failure.

    Return null/nil/None/... if the input is an even number or negative, as it is not possible to print a diamond of even or negative size.

  • Custom User Avatar

    I tried to reproduce, but of all the clues, none of them equal all zeroes. So I'm not sure what the issue was you encountered.