Ad
  • Default User Avatar

    looks like u solved it~~

  • Custom User Avatar
  • Default User Avatar

    i could have helped but this looks too frightening to me and im not good with recursions. but u can do basic iteration and solve it:))

  • Custom User Avatar

    All \n should be preserved. You should only remove from the marker until before the new line or if it is the last line, until the end of it.

  • Custom User Avatar

    because there is a branch of the inner loop wher you don't decrement it? ;p

    EDIT: note that this algo will be way too slow for this version of the problem.

  • Custom User Avatar

    Hi, are you sure the test cases work fine? Maybe your problem is from an infinite loop but I think your logic is not quite right anyway.

    Matt

  • Custom User Avatar

    No, when using recursion, calling the function as you did (in the last line) is not enough, you need to also return the call, otherwise the returned value is lost.

  • Custom User Avatar

    Because you're not returning the call to the function.

  • Custom User Avatar

    don't use that. Ever. That breaks the program, not the loops.

  • Custom User Avatar

    returns true if a portion of str1 characters can be rearranged to match str2

    Where are the x of ldcxkfyrlcbdxsekl in ferzdffpubobgmilcnk ?

    B1ts, what you said doesn't matter, you can have more letters in s1.

    scramble('rkqodlw', 'world') ==> True
    
  • Custom User Avatar

    s1: ferzdffpubobgmilcnk

    s2: ldcxkfyrlcbdxsekl

    I don't see z (4th char) included in the 2nd string.

    Edit: oops, I didn't read the task correctly, it's the other way around. So, x is in s2, but not in s1, so it can't be true.

  • Custom User Avatar

    Checking up to a midway point is a very good idea, you just need to find a good midpoint. However, num/2 is not in the middle of things you need to check, actual midpoint is much, much smaller than num/2. Hint: you are doing division. What's the 'middle' when dividing a number?

  • Custom User Avatar

    I only need to check against prime numbers and not every natural number.

    That's not so simple to tell to a computer :P It's not about which numbers to check, but where you should stop checking :> ( hint #2 :D )

  • Custom User Avatar

    Hint: You're not meant to calculate the factorial. Find another way to find the number of zeros.

    It's written in the kata description that solutions like that won't work.

  • Custom User Avatar

    Your solution is simply too slow for huge numbers. You're almost there... As a little hint: do you have to check every number?

  • Loading more items...