1

I’m super close. But I cannot figure out right formula. It doesn’t count amount of the similar substrings correctly. I mean the output is wrong.

https://pastebin.com/gEvxAS1X

enter image description here

2

You have some substrings that are shorter than the others because there are no n characters left at index i.

How many substrings of length n can you have in a string of length len(a)? n is part of the formula that goes into the range call.

3
  • when I do for i in range ( len(a)- n-1) I get the same result as without n. Oct 1 '18 at 15:34
  • -n looks fine, but imagine len(a) and n were the same, how many possible substrings would you expect? -1?
    – Blauelf
    Oct 1 '18 at 16:17
  • I rearranged the code and it worked. I put everything in return and some magic happened. Oct 2 '18 at 4:13
2

Look at your asub and bsub right before returning an answer. (you can use print to see what they are). Looks like they're getting re-defined for each i rather than accumulating a list of all possible options.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .