Ad
  • Custom User Avatar
  • Default User Avatar

    Why are programmers so like "Oh it was so easy, I did it in 10 minutes..."

    I'm a 1Kyu, so not stupid but I've spent a couple of hours on this and can't solve it. It's obviously a math problem, not a coding one.

    A formula or pattern or what have you can be elusive. I'd say it's harder then a 6kyu.

  • Default User Avatar

    Because this has a complexity of O(n²) which is awful

  • Default User Avatar

    It's a very simple thing to program given you know the pattern. In fact, that's true for almost any codewars problem. If you know or understand the problem, it should be quite easy. This problem is just particularly easy because it's only one to two lines.

  • Custom User Avatar

    Arguing "intent" outside of kata description and tests is a fool's errand. Maybe the kata author believed one of the problems with the code was that it needlessly concatenated two constant strings? We have just as much evidence for that as anything else, which is to say: none.

    I solved the kata in this way to avoid concatenating constant strings. It's a waste of CPU, there's no compelling reason to accept that waste, no requirement asking me to, and no test that fails if I do things my way. So I did things my way.

    Anyone who says this code is "cheating" or "wrong" is barking up the wrong tree. An accepted solution is never wrong or cheating; it is the tests that are wrong. It is up to them to work with the kata author to improve the kata, or fork it and do it themselves. It is not a coder's responsibility to intuit beyond the requirements what the author "intented", and further, doing so is a fool's errand, more likely to be wrong than not.

    Finally, in general finding unintended solutions is a huge benefit to the Codewars community. It illustrates non-conventional thinking (which often results in better solutions, especially in the higher kyus) and forces kata authors to improve their katas and tests.

    While I understand if someone's cheating to get to their rank, that can feel like it diminishes the "value" of your rank, but:

    1. Finding non-conventional solutions is usually more work than finding conventional solutions.
    2. Finding non-conventional solutions provides a valuable service to the community.
    3. The actual cheaters have alt accounts that they use to view solutions and copy+paste the solutions into their "prime" account. They aren't finding edgecases and alt solutions.
    4. Like the points on Whose Line Is It Anyway? your rank already doesn't matter. Yes, your rank is like hair products in Colin Mochrie's apartment.
  • Custom User Avatar

    I'm curious as a beginner if your approach, which seems to ignore the intent (as the given code includes concatenation), is based on industry best practices, or simply to stick it to kata creators who write ambiguous instructions (or are these one in the same?)? Either way, it's fun to see solutions that think outside the box.

  • Default User Avatar

    thanks! yes, I really only wrote it to demo this vulnerability

  • Custom User Avatar

    Note: Pyhthon 3.8 and above

  • Default User Avatar

    That is one of the differences between python 2 and 3. I used python 2 back then.

  • Default User Avatar

    Yours is just as good.

  • Custom User Avatar

    issueS confirmed:

    • tests are completely BAD and do not filter anything (my solution passed with 2 3 errors!)
    • description is bad too: the example in the description might make think about using the index (1 indexed value rather than "the position in the alphabet" => should not use "b" for the secong character)
    • edges cases needed effectively
    • the last one suggested doesn't effectively make sense.

    (as a matter of fact, my solution passed while I:

    • used the index instead tof the position in the alphabet
    • used a 0-indexing for that!!
    • used the wrong condition, for the even/odd indexes.

    that's ESPECIALLY BAD! x/ )

  • Custom User Avatar

    I assume those are Python tests, I could check javascript later. Test.assert_equals(cake(0,""), "Fire!") doesn't make sense because there were no candles to start with, so something is wrong with that test. Test.assert_equals(cake(0, "jpipe"), "That was close!") this one too, because you can't drop candles that don't exist. In fact the candles dropped should be less than or equal to the total number of candles.

  • Custom User Avatar

    It would help if you present some of those cases.

  • Default User Avatar

    That's because f-strings are a new feature of Python version 3.6.0.
    Check out this blog post for more info and considerations on f-strings.

  • Custom User Avatar

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

  • Loading more items...