Ad
  • Default User Avatar

    good kata for learning things about chains

  • Default User Avatar

    When your result looks like the expected one, but still fails, it is helpful to print your string between delimiters and escape whitespace characters.

    For your situation:

    String s = sb.toString();
    System.out.print('"');
    for (int i = 0; i < s.length(); i++) {
        char ch = s.charAt(i);
        System.out.print(ch == '\n' ? "\\n" : Character.toString(ch));
    }
    System.out.print('"');
    

    for n = 1, this prints:

    "*\n \n"

    while the expected answer is:

    "*\n"

  • 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

    My Rust solution should work, but adding the appropriately placed newline characters gives this result. This only pops up when the answer is correct - if I add a newline character at the start of the string, the test fails and no error occurs.

    memory allocation of 9223372036854775806 bytes failed

    Caused by:
    process didn't exit successfully: /workspace/target/debug/deps/challenge-07bd72047d917620 --show-output -Z unstable-options --format json (signal: 6, SIGABRT: process abort signal)

  • Custom User Avatar

    This one really took a toll on me! TvT

  • Custom User Avatar

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

  • Custom User Avatar

    Thank you so much for your sugestion! I rewrote the code with an empty array concating other arrays and it worked:)

  • Default User Avatar

    try your code with a string that has no 'a', but that has other vowels

    Also:

    • you can print the input to debug your code (e.g. console.log(str);)
    • use markdown formatting when you post code
  • Custom User Avatar

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

  • Custom User Avatar

    Language?

  • Custom User Avatar

    The registers to use r unclear: idek where the string is located

  • Default User Avatar

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

  • Custom User Avatar

    I'm kindof sad that regexp_count is not available in postgres 13.

  • Custom User Avatar

    Approved

  • Custom User Avatar

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

  • Loading more items...