Ad
  • Custom User Avatar

    Good job

  • Custom User Avatar

    I think whoever wrote that was intending to pass a copy of the list, instead of allowing manipulation on the list itself. I'm not sure it was really necessary here, though.

  • Custom User Avatar

    Have you tested it? It would definitely be faster in a compiled language but in scripting languages built-ins are usually preferable.

  • Custom User Avatar

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

  • Custom User Avatar

    You have a typo in your alphabet.

    It is a good practice to import constants to avoid bugs like this with typos. Consider using from string import ascii_lowercase.

  • Custom User Avatar

    Yes. The single pass will perform faster. You won't notice this with the small tests in this kata, but let's assume that the list is actually a file on your hard drive, and it's 2 GBs big. If you read every value once, you only have to read 2GBs only once, too. With a second pass, you would have to read the complete file a second time.

    If you have a sequence that's generated by a generator, you would have to keep the whole sequence in memory (which might not be possible), or generate it a second time (which might take too much time).

    So even though their asymptotic complexity is the same (O(n) = O(2n)), their real performance varies tremendously (and we haven't even looked at caching effects).

    HTH.