Ad
  • Custom User Avatar

    You have a misunderstanding of something. n is a number. str(n) turns it into a string. strip just removes the leading and trailing characters. All of this 'launches' in both cases. The int throws an error if it receives an empty string, which is the case if input is only zeros, since you strip them.

  • Custom User Avatar

    It doesn't skip anything. Python's or statement returns the left side if it is true and with strings that is whenever the string is not empty. Only when the left side is false does it proceed to evaluate the right side and it returns it regardless of is it true or false.

  • Custom User Avatar

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

  • Custom User Avatar

    Add a fixed test with bill = 50/1.15.
    I had a student wrongly solve the task but all the tests passed.

  • Custom User Avatar

    I hadn't actually checked for the problem at hand but about the general concept of using sum() vs len(list()) a while back.

    My argument about the early exit was malformed. It's not about memory but rather performance. And it's not an argument for my approach but against using 'sum'. So the best thing would be to have a 'for' loop over 'PATTERN.finditer' and a 'continue'.

    Anyway, thanks for the reply. Apologies for not using backticks, don't have them on the phone keyboard.

    Cheers

  • Custom User Avatar

    Honestly, after giving it a little thought, the memory allocation is not a bad idea in this case or rather in any cases I worked with regexes. While streams are more efficient in memory they underperform in speed (in python at least). And the memory we'd be allocating is rather unsignificant. And I'd argue the len approach is more readable or rather closer to the spoken language.

    On the side note, if you care about memory wouldn't you stop counting matches after you reach 5 in the first line of the haiku, that is 7 in the second line?

  • Custom User Avatar

    Why finditer? :)
    EDIT: didn't see you can put description, thanks, got my answer!

  • Custom User Avatar

    Yeah, I guess you're right. Great kata btw, really had fun with it :D

  • Custom User Avatar

    uf, when I saw other solutions I was kinda bummed out.
    Wish this caught my eye when reading the description:

    Your task will be to implement basic operators on booleans (using only lambdas and function application)

    Anyway, the suggestion is to emphasize it a bit ^^

  • Custom User Avatar

    I understand that, as I have described in your other issue, no use to open a million issues with the same title, that adds no value, continue the discussion in the first thread.

  • Custom User Avatar

    If I make a user account that only I have access to and never solve a single kata on it and keep it running for the purposes of having a fixed test on this kata no magical entity will ever do a kata on it.

    Same things go for the banned users if it is the case that once you're banned you can't use your account. Otherwise, if there is no such thing as banned/locked user accounts I'd create an alternative as I stated because having fixed tests in the test sample suite shows you directly what's the format of the expected output without having to re-read the task a milion times.

  • Custom User Avatar

    So tell me, if one mistakenly writes a non capitalized username in a username that is capitalized and the function returns 0% you'd be satisfied with that?
    At this point you're providing no value to this discussion, you've been nothing but prejudiced and ignorant.

  • Custom User Avatar

    Thanks for the input, though rarely does one care about decimal places in percentages meant to be used as a quick overview.

  • Custom User Avatar

    Input validation? There is no input validation. You get a username string. No need to validate it.

    If a user writes his own tests or if the scraping on the leaderboard returns an account that happens to get invalidated by the time the tests get run the function should not explode or what have you. This isn't an edge case, it's something you would actually do in a real world environment.

  • Custom User Avatar

    That's the point. They are not needed, you're not gonna get fixed tests in a real world scenario either.

    And even if you could guarantee a user will not return (having an account just for that or a banned user account) it would still be useless for non '0%' solutions since the current date keeps changing...
    But hey, I did include those cases when creating this kata just in case someone had an issue with it.

  • Loading more items...