Ad
  • Default User Avatar

    It's hard to imagine a situation when one producer (because products should be grouped by a producer) sells different products with exactly the same name :) So DISTINCT is superfluous here I guess.

  • Default User Avatar

    No, just running the default code, you see the column names.

    It doesn't seem right to me to run the code just to understand the task :)

    Changing that now would render all SQL solutions invalid.

    Indeed, it didn't occur to me. In this case adding a comment about names or correcting examples block (change "time" to "hours" for SQL) would be useful I think. Thank you!

  • Default User Avatar

    In SQL we have to guess column name in the original table. In description and examples we see "time", but this name can not be used in query because of

    ERROR: column "time" does not exist.

    Instead of that we have to use "hours" not only for result (as it is said in the description for SQL), but for original column as well. It's confusing. It would be better to keep the original name ("time"), as in Python for example.

  • Default User Avatar

    There is something wrong with the description:

    to hexYou have access to a table of monsters as follows

    should probably be

    You have access to a table of monsters as follows.

    In addition to aesthetic aspects, description like this contains a little spoiler.

  • Default User Avatar

    From PostgreSQL 14 documentation, 7.2.5:
    Currently, window functions always require presorted data, and so the query output will be ordered according to one or another of the window functions' PARTITION BY/ORDER BY clauses. It is not recommended to rely on this, however. Use an explicit top-level ORDER BY clause if you want to be sure the results are sorted in a particular way.
    https://www.postgresql.org/docs/14/queries-table-expressions.html

  • Default User Avatar

    This solution is wrong when the number of the ending weekday is equal or greater than the number of the starting weekday (e.g. period from 2022-01-13 (Thursday, 4) to 2022-01-21 (Friday, 5): this solution gives 5 instead of 7). Now it doesn't pass the tests.

  • Default User Avatar

    I suppose that you import the module random using absolute import, as I did at first. I would venture to suggest that the case in order of imports. Giacomo's random tests use relative import: from random import randint, random. So Giakomo's test code imports random.random as random, then tries to use it instead of random module in your code, thus we have an AttributeError: 'builtin function or method' object has no attribute 'x' (because there is no random.random.randrange or random.random.shuffle in Python). Relative imports solve the problem.

  • Default User Avatar

    @Joz, probably, meant, that there is an inconsistency in kata description:

    optional methods list that defines what methods new class should have - i.e., methods should be in list,

    and

    >>> FooClass = create_class('Foo', methods=(return_name)) - here methods are in tuple.

    As far as I understood, your test cases give lists.

    Nice kata, I remembered rarely used syntax :)

  • Default User Avatar

    How could this solution pass the tests? When I tried to check it, I had TypeError: unhashable type: 'list'. And if it even works, it can't handle cases such as 'aaabaaa' correctly. Have I missed something?

  • Default User Avatar

    Regarding the splitlines solution, you're right, I found a small bug. But regexp solution in the case described by you should work correctly, just checked! However, the tests are never too much:) Tag 'Parsing' will be useful anyway.

  • Default User Avatar

    Thank you, sensei:) Now it became really clear! By the way, with tag "Regular Expressions" I (and I think not only I) would have found your kata before. Codewars does not have enough regexp challenges, and your kata is very helpful in regexp training.

  • Default User Avatar

    I'm afraid that I have confused in wording. I thought that max_width is always 80("if it is above the default 80 characters, take this(i.e.80!) as max_width."). Thank you for your patience in explanations! I finally solved it:)

  • Default User Avatar

    I've read it many times :). The fact is that both lines, that I quoted in my question, are not above 80. Although the first one is quoted as an example of 'broken lines' in kata description. I can't catch, why should the first one be treated as 'broken line', and the second should not? Or when you say 'line' do you mean 'everything in quotation marks'? I mean 'everything before \n', as splitlines does :)

  • Default User Avatar

    I guess that I have bothered you, but I have another question. How should I determine the 'broken line'? For example, in this two cases, as they come to me:

    1. from long lines test, "'x'*80":
    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
     x'
    

    length of the first line is 80, expected result is first + second line, without \n.

    1. from full session test, 'help(os.walk)' result:
        ...
        subdirectories whose names remain in dirnames; this can be used to prune the
        search, or to impose a specific order of visiting. Modifying dirnames when
        ...
    

    length of the first line is 80, expected result is first + \n + second line.

    Is the whole thing in quotes? Does everything work as you expected?

    By the way, the 'full session' test results are fully seen now, thanks.

  • Default User Avatar

    It seemed to me, an issue is a kind of complaint. The desire of the author to test the code on a real example does not deserve complaints, just a suggestion.

    Alas, I did not find out, what was my mistake in the invisible part of the test - perhaps you have cut off something useful. Now everything works fine, thanks! I'll try to complete regexp solution and submit them both.

  • Loading more items...