Ad
  • Custom User Avatar

    If you mean the alphabetical order of stock names, they are irrelevant here.

    The task asks only to compute the final buy and sell values, and mark any badly formatted stocks.

  • Custom User Avatar

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

  • Custom User Avatar

    Initial sequence:
    1,2,3,4,5,6,7,8,9,10,11...infinity
    Delete every second number:
    1,3,5,7,9,11...infinity.

    From this new sequence, where 3 is no longer the third number, then delete each 3erd number (5, 11, etc.)

  • Custom User Avatar

    I am not shure ho pythonic the solution is.
    It is readable and performant.
    Your solution includes an additional variable. That can make it more readable, but since the function does exactly one thing (calculating a grade), I dont think this adds to the readability.

    The multiple return statements...hmm yes I dont like them that much but since python does not offer a clean switch case out of the box...well.

    Multiple return statements are not forbidden, but I guess PEP8 somewhat discourages you to use them.
    But at the same time, some examples in the style guide also contain multiple return statements.
    So maybe (and I mean maybe) it is fine in this case...

  • Custom User Avatar

    I'm not sure whether or not it's pythonic, but it seems that from efficiency point of view:

    • we want to return as soon as the result is ready (e.g., it allows not to use additional breaks in loops and so on)
    • variables can be omitted if they are not needed later in the code (after if-else block)
  • Custom User Avatar

    From a readability standpoint I like this solution.

    I thought I read that multiple return statements weren't pythonic. Is this not the case? See my solution as an example.
    I think this solution is actually easier to read. Although, I can see where multiple return's might get complicated quickly.

    Thoughts?

  • Custom User Avatar

    The restrictins in Python are ridiculous and don't allow for much variety in or elegant solutions.

  • Custom User Avatar

    The Python translation is getting warnings, too:

    /workspace/default/preloaded.py:34: FutureWarning: Possible nested set at position 1
    parse(re.finditer(f'[[\]]|[^[\]]+',solution))

    Looks like f-strings aren't needed here, and re.finditer(r'\\|[^\\]+'), solution) will do what the above code seems to be trying to do.

  • Custom User Avatar

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

  • Custom User Avatar

    did not want to type "return" each time but now I realise, that typing "return" is a lot more convenient that typing "="-symbols...

  • Custom User Avatar

    I had a very similar error. I submitted again without changing any of my code and it accepted. It seems like the tests are not consistent

  • Custom User Avatar
  • Custom User Avatar

    This solution is wrong, it does not cover all edge cases.
    it just got lucky with the random test cases.

  • Custom User Avatar

    Replace f' formatting with .format()

  • Custom User Avatar

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

  • Loading more items...