Ad
  • Default User Avatar

    I think tests could be improve to, it also accepts solutions with extra \n (first line for example)

  • Custom User Avatar

    Just a tiny suggestion for the descriptions:

    For the stack instruction described as "Duplicate the nth value from the top of the stack and push onto the stack", define "nth", so it's clear that it is zero-based.

    The (apparently) official wording isn't clear either -- it says "Copy the nth item on the stack (given by the argument) onto the top of the stack" (https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php). If one uses standard English ordinal numerals (https://en.wikipedia.org/wiki/Ordinal_numeral), "first" would mean the item on the top. And some programming languages are one-based.

    This would save us a rewriting session, after we flip a coin to choose how to interpret "nth", and get it wrong. :D :D :D

    (I'm new here, and not familiar with the updating process -- I should go look for that in the docs. I see that fork symbol, so I'm guessing one does a pull request.)

  • Custom User Avatar

    This may need some more test cases for Python. Some solutions shown, which must have passed tests, don't strip trailing whitespace if there are no markers, for instance. And some do not support backslash as a comment character -- it's not ruled out in the problem statement. The latter might be a bit obscure, but the former is very clearly implied by the problem statement.

    So...should this have a test added for Python with trailing whitespace and no markers? Here's an example:

    test.assert_equals(solution("apples, pears # and bananas \ngrapes\nbananas !apples ", []), "apples, pears # and bananas\ngrapes\nbananas !apples")

    For a test with backslash as a comment character (also includes a character that must be quoted inside a Python re character set):

    test.assert_equals(solution("x \n\n x \nblah blah ! comment\nstuff\\n", ["!", "\", "]"]), "x\n\n x\nblah blah\nstuff")

  • Custom User Avatar

    The fact that the edge case, where a bounce comes exactly up to the window height, doesn't cause these solutions to fail, implies there is no test for that case. (I had the edge case among my own tests.) That seems like an issue that should be reported. The example you have would be an appropriate test to add. (I'm new here, and haven't yet looked at how to report issues or suggest tests.)

    Edit: There is a test for the edge case now, so perhaps it was added after the solutions lacking the fixup were submitted.

  • Custom User Avatar

    Yep, we were reading each other's replies in between edits...

    Ok, so there are later problems that do require optimal time complexity. In that case, I won't comment on that. And I was wondering if anyone would see this. Also wondering if someone else had brought this up, but not sure how to search just the posts on this one problem.

  • Custom User Avatar

    yes, I removed the flag I put there, after I read the text.

    It might be better to read the post before making changes... ;-)

    "Caution, mother of virtues". Better to flag then unflag if it was unnecesseray than leaving a potential solution in the wild, imo.

    Are you saying that it is always appropriate to mark the first post in a discussion as having spoiler content

    definitely not.

    What I would like to know is what are the best practices for discussing issues that require referring to solutions.

    I'm not entirely sure what you're exactly talking about there.

    • if you plan on raising issues on kata that allow bad time complexity to pass, just don't. Easy kata are there for this (sort of...)
    • you can leave posts like you did in the discourse, but keep in mind they will finally be drowned by other messages.
    • you can also leave comments directly under solutions. They'll get drowned there too, but much slower. On the other hand, there aren't that many people who are reading them, and they are "per language", which reduces even more the audience.
      • you definitely can post on the solutions...
      • ...but please don't do that in all languages and on all O(n²) solutions... ;)
      • You can for example post under the top rated solution (which is generally already overcrowded with messages about performances)

    cheers

  • Custom User Avatar

    Hi, Blind4Basics!

    Thanks very much for pointing to the dashboard -- I was wondering how to see my profile, and get back to previous katas, to try them in other languages.

    Heh. I missed your line that started "edit:" until after I posted. Hmm...I wonder if I read your post first before the edit, and the page got refreshed at some point...

    Just to be clear: There is no spoiler code in the first post. The code there is timing test code. It's included partly so people can verify how the output I'm showing was produced, and in case folks want to run timing tests on their own code, and aren't familiar with Python timing tools. Even if people do not read my replies where the code is, it is important that people know that the popular solution is effectively incorrect, because it is far from the optimal complexity, which is linear. (As mentioned, in the Princeton algorithms courses, one doesn't get credit on homework unless it hits the optimal time and space complexity. :D )

    What I would like to know is what are the best practices for discussing issues that require referring to solutions. Ideally, the Codewars platform would separate the forum into posts visible before solving, and posts visible after. Are you saying that it is always appropriate to mark the first post in a discussion as having spoiler content, if any post in the discussion does? I was assuming that only the specific posts with spoiler code should be so marked.

    Edit: Ooookay, I was going to add a bit more clarification that the code in the first post was just test code, but I guess I can't edit the first post any more -- the Edit button has vanished. I don't know if that is because there's a time limit for edits, or if no edits are allowed once there is a reply, or...?

  • Custom User Avatar

    Hi,

    I didn't read the wall of text yet, but...

    First, thanx for sharing.
    Second... don't share solutions in the discourse unless you use the spoiler flag! ;) All messages can be read by anyone here, meaning you just dropped the solution for everyone to see... (I flagged your first message already)
    edit: ok, now that I read the wall of text, I see there is nothing problematic in your first message and you already used the flag on the others. Well done. :+1:

    (Note for later use: comments under solutions are visible from the dashboard too, so there too, you'd have to use the spoiler flag)

    cheers

  • Custom User Avatar

    So, what's wrong with O(n^2)?? Isn't that polynomial time? Yes, and I was surprised to find out (while taking the courses I'll list below) that polynomial isn't good enough any more. Way back, when I was a computer science undergrad, polynomial time was fine. But Things Have Changed. That's because of increasing amounts of data, which means much MUCH larger problem sizes. And, critically, it means that the data very likely will not fit in memory.

    So look at what happens if our array is so large that it has to be stored out on disk, or in the cloud, and only some fixed-length piece of the array can be brought into memory at once. Consider the solution that repeatedly calls sum on each end of the array. On each pass, it touches all but one element of the array. That means it has to re-read the array in from wherever it's stored on each pass.

    Now, about those algorithms resources... I can recommend several things:

    First is Udi Manber's book Introduction to Algorithms: A Creative Approach. It attempts to teach how to design or invent algorithms, not just teach algorithms that someone else came up with. (In grad school, I overheard one algorithms prof say they did not like Manber's book, for the same reason that I did like it. The prof thought students should be weeded out based on whether they could come up with algorithms with no training. I didn't and don't agree.)

    Second are the two Princeton algorithms courses available though Coursera. These were a lot of fun (IMO), not just because of the interesting problems, but also because the course's forums were very active. Students were friendly and helpful -- careful not to give away answers, but cheering each other on. One interesting and relevant feature was that programming problems were tested to determine their runtime and space complexity. One didn't get full credit until one had an optimal solution. The courses are free. One caveat -- I took the courses some while back, and they were run in sessions so that a large batch of students went through the course together. That's one reason there were lots of students chatting in the forums. Coursera has made some changes, and I don't know if these courses are still run in sessions. That may not matter if there are enough students in the course at any one time.

    https://online.princeton.edu/node/201
    https://www.coursera.org/learn/algorithms-part1

    https://online.princeton.edu/node/166
    https://www.coursera.org/learn/algorithms-part2

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

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