Ad
  • Custom User Avatar

    I guess i do. Maybe after I¨ll actually programm something real it might get better.. Still thank you and have nice day. :)

  • Custom User Avatar

    The description doesn't say it.

    What will happen if someone has a two part name, like von Braun? Or it will include some tags, processed afterwards, that should be not capitalized?

    You're overthinging it :)

  • Custom User Avatar

    I guess. Still better behaviour would be to capitalize every words inside the answer, don't you thing?

  • Custom User Avatar

    How exactly it matters? say_hello('john') => "Hello, john" would be an expected behavior.

  • Custom User Avatar

    Maybe I missed it but what about the case when name elements can be lowercase?

  • Custom User Avatar

    Love me some f-strings

  • Custom User Avatar

    This, but i did it gross.

  • Custom User Avatar

    For Python, this Kata is a nice opportunity to learn why the trivial instruction one may want to use shouln't be. Perhaps this could be precised in the details ?

  • Custom User Avatar

    @rowcased Maybe my original code was not indented right. Thank you for your clarification. It happened to me twice that i debugged a code because one of the variable names was the same as function's.

  • Custom User Avatar

    a function's scope can contain a variable matching its name, so your final code doesn't actually throw any error, but yes, it is a bad practice

  • Custom User Avatar

    It is strange I had almost the same code as this one. The only difference is I use "factorial" instead of "j".
    Then it gave me the error. Is this because my variable name is the same as function name? Is it a bad coding habit?

  • Custom User Avatar

    The kata is still not novel at all.

  • Custom User Avatar

    It's not a duplicate if there isn't a 101% identical kata

    That's not how it works.

  • Custom User Avatar

    no, you didn't get the idea. Currently, you have most of the tests that are predictable: the first random will be the most probable answer, and the following ones will always give the same result. That's way too much predictable.

    What you need is something like that:

    for _ in range(100):
        strategy = random.randint(0,3)
        if strategy==0: # pick one number randomly
        elif strategy==1: # build a square
        elif strategy==2: # build a palindrome
        else:             # build both at the same time.
    

    Note that the way you currently build the squares, there are a lot of chances that then can be identified just by checking the value: if it's > 1000, the user will know it's a square. So you actually need something like int(randint(1,...)**.5)**2, and you should use an upper value that is higher than 1000. For the square palindromes, just store a long list of those numbers and pick randomly inside it when you need one of them.

    Final note: you shouldn't resolve the issues unless you're absolutely sure that you actually resolved the problem. You already did that twice in a row without actually solveing the problem... ;/

  • Custom User Avatar

    I've updated the random tests so that there are always some squares, palindromes and palindromic squares.

    I suppose there's still a small chance that in a given attempt all the randomly generated squares happen to be palindromes, and all the randomly generated palindromes happen to be squares. I could put a while to make sure each strategy is randomly tested at least once, but I think that is stretching the point.

  • Loading more items...