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.
Duplicate.
I was baffled by this signature of the
translate
method until I realized "Python" here means Python 2.Most readable of the one-liner solutions I see here.
Fair enough. I love Python, my career revolves around it, but sometimes I just want a little more rigor in the type system! Props to Python 3 for disallowing ordinal comparisons to
None
.That's because of Python's duck typing –
bool
is a subclass ofint
.And since the description asks to return
0
when the numbers are equal andFalse
is equivalent to0
, this is acceptable.well, that'd be pretty anti-pythonic, tho... ;)
I'm guessing by "false extending 0" you mean to point out that
False == 0
? Sure, but take note also thatFalse is not 0
.My point was just that the description (i.e. acceptance criteria) states "when a is close to b, return 0" (type
int
) while this returnsFalse
(typebool
). Python's weak typing in this area makes it easy to be casual. But if you added type annotation to this function and enforced it (say, with mypy or enforce), returningFalse
would be an error.but false extending
0
, if the expected answer is 0, that's still correct.proof: this passes this fixed test:
test.assert_equals(close_compare(5, 5), 0)
This returns
False
ifa
andb
are equal. (I posted a comment in discourse also, since this suggests the tests need tightening.)This comment is hidden because it contains spoiler information about the solution
That's not the problem though; the main problem is that it's not even half-finished (just look at the tests and import statements). Fixing it would require pretty much writing up the whole test.
It's on the list: https://github.com/Codewars/codewars.com/wiki/List-of-Affected-Kata The question is whether the packages will be installed or not.
Clojure: it's unfinished and should be revoked/removed.
Tests require result to have a specific ordering but it's not mentioned anywhere. Either it should be specified, or the test should sort the user result before comparison, or the function should return a
set
instead.@pbx
,Instead of just showing it in the description (and then forcing everyone to write their own), it might be a good idea to add the digits dictionary to
Preloaded
since every solution has the same dictionary. That way people could choose whether to use a preloaded dict of digit/letter pairs or to write their own (I'm guessing many people would use the preloaded dict).If you do add that to
Preloaded
, just make sure to tell people about the name of it in the description too. You could use separate markdown code sections for each language (so the Python dict only shows up in the description for Python not Clojure and vice versa).Thanks!
Loading more items...