Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
It doesn't seem right to me to run the code just to understand the task :)
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!
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
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.
There is something wrong with the description:
should probably be
In addition to aesthetic aspects, description like this contains a little spoiler.
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
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.
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 importsrandom.random
asrandom
, then tries to use it instead of random module in your code, thus we have anAttributeError: 'builtin function or method' object has no attribute 'x'
(because there is norandom.random.randrange
orrandom.random.shuffle
in Python). Relative imports solve the problem.@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 :)
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?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.
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.
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!) asmax_width
."). Thank you for your patience in explanations! I finally solved it:)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 :)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:
length of the first line is 80, expected result is first + second line, without
\n
.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.
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...