Ad
  • Custom User Avatar

    Got it! Thanks for the clarification.

  • Custom User Avatar

    Note: a digit can belong to two adjacent digit-pairs. For example, in string 1???9??1, 1???9 is a digit-pair, 9??1 is also a digit-pair.

    Could someone explain this to me.
    How does the above represent two valid digit-pairs?
    Or is it a typo?

    Because there are 3 ??? between the 1 and 9
    However there is not three ??? which follow the 9.
    So how can the answer be valid?

    Also looking at the sample tests shows
    Test.assertEquals(sum10("1???x9??1"), false)

    That is what I would expect.

    So is the description meant to read:
    "***Note: a digit can belong to two adjacent digit-pairs.
    For example, in string 1???9???1, 1???9 is a digit-pair, 9???1 is also a digit-pair."

    Thank you

  • Custom User Avatar

    Aha! I understand now. Thank you

  • Custom User Avatar

    Thank you, akar-0

    But as you can see I posted exactly the input so that you can
    see what I am using!
    All I did was change the 'test.assert...' string to 'console.log'
    That's it!
    And ran both programs which displayed the answers straightaway
    As you can see

    I would gladly send you the source code of my solution so that you can see what I mean, if that helps!

  • Custom User Avatar

    Greetings

    I have written two different solutions which both use a loop. No recursion.
    Both run fine in Visual Studio but both crash with memory problems in Codewars

    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

    I have tried both 'resetting' and changing the Node versions.
    I get the same errors

    How do I proceed?

    This is my output from Visual Code:

    console.log(splitWithoutLoss("hello world!", " |"), ["hello ", "world!"]);
    console.log(splitWithoutLoss("hello world!", "o|rl"), ["hello wo", "rld!"]);
    console.log(splitWithoutLoss("hello world!", "ello| "), ["hello", " world!"]);
    console.log(splitWithoutLoss("hello world!", "hello wo|rld!"), [
    "hello wo",
    "rld!",
    ]);
    console.log(splitWithoutLoss("hello world!", "h|ello world!"), [
    "h",
    "ello world!",
    ]);

    console.log(splitWithoutLoss("hello world! hello world!", " |"), [
    "hello ",
    "world! ",
    "hello ",
    "world!",
    ]);

    console.log(splitWithoutLoss("hello world! hello world!", "o|rl"), [
    "hello wo",
    "rld! hello wo",
    "rld!",
    ]);

    console.log(splitWithoutLoss("hello world! hello world!", "ello| "), [
    "hello",
    " world! hello",
    " world!",
    ]);

    console.log(splitWithoutLoss("hello world! hello world!", "hello wo|rld!"), [
    "hello wo",
    "rld! hello wo",
    "rld!",
    ]);

    console.log(splitWithoutLoss("hello hello hello", " | "), [
    "hello ",
    " hello ",
    " hello",
    ]);

    Which Produced:

    [ 'hello ', 'world!' ] [ 'hello ', 'world!' ]
    [ 'hello wo', 'rld!' ] [ 'hello wo', 'rld!' ]
    [ 'hello', ' world!' ] [ 'hello', ' world!' ]
    [ 'hello wo', 'rld!' ] [ 'hello wo', 'rld!' ]
    [ 'h', 'ello world!' ] [ 'h', 'ello world!' ]

    [ 'hello ', 'world! ', 'hello ', 'world!' ] [ 'hello ', 'world! ', 'hello ', 'world!' ]

    [ 'hello wo', 'rld! hello wo', 'rld!' ] [ 'hello wo', 'rld! hello wo', 'rld!' ]

    [ 'hello', ' world! hello', ' world!' ] [ 'hello', ' world! hello', ' world!' ]

    [ 'hello wo', 'rld! hello wo', 'rld!' ] [ 'hello wo', 'rld! hello wo', 'rld!' ]

    [ 'hello ', ' hello ', ' hello' ] [ 'hello ', ' hello ', ' hello' ]

  • Custom User Avatar

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

  • Custom User Avatar