Ad
  • Custom User Avatar

    He calls the replace(). Replace accepts something called a regex (which tells your replace method to expect a certain type of string pattern -- in this case the regex is a '.' which ensures your input is any character but a line terminator). The second parameter replace accepts is a callback function. The callback function contains a dictionary of matching DNA values. This function runs on each individual character from the original dna string and 'replaces' it with the matching DNA value from the dictionary.

  • Custom User Avatar
  • Custom User Avatar

    OK! Sorry:-( I forgot that I modified the TS solution; at first my result was like yours.
    Anyway as soon as I can I will modify the testing function so that different solutions could occur. I will let you know when done.
    Thanks for your post.

  • Custom User Avatar

    In expected 105 is greater than your 104. You should try to return at each step the greatest number.
    The description says:

    decompose(11) must return [1,2,4,10]. Note that there are actually two ways to decompose 11², 11² = 121 = 1 + 4 + 16 + 100 = 1² + 2² + 4² + 10² but don't return [2,6,9], since 9 is smaller than 10.