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.
a
Spoiler flag plz.
hint: don't use max(list), it's O(n) time complexity, and total will be
$O(n^2)$
, time out.and list.index(item) is
$O(n)$
, too.This comment is hidden because it contains spoiler information about the solution
Okay, can we real quick agree that this is a javascript specific kata?
Nobody else thinks
[] == 0
All other translations here are shitposts IF it is important to the kata that there be mixed types in the input.
However, they are there. So I then claim it clearly is not important, and further does not add anything to the non-js languages. (I'm including coffeescript with js)
Python is mistranslated. In python,
False
is defined to have the value zero. The python translation claims it's not zero. The python translation is wrong. It further allows changing type between int and float which is nonsense.The C# translation already doesn't care.
So then, to fix this:
Option 1: Remove all non-js languages.
Option 2: Remove
False
from python translationOption 3: Pretend the kata doesn't exist and leave it broken.
Option 4: Remove the mixed types.
1: can't.
2: is a band-aid and doesn't change the fact that the javascript translation is a completely different problem
3: really?
4: only option that leaves things in a sane state, ignoring that it is misranked by 2 ranks but that's already the case.
4 further allows accepting translations currently in limbo
I'm making the first step here, with python, and if I get this through, I will continue pushing for the other languages to follow suit (either by painstakingly figuring out how to write them myself or by getting others to do it)
python update: 3.8, new test framework, no more mixed types - list of int only
False
truly has the value0
in python. the kata treats it like a special case (not zero) which I would claim is a translation errorthe
is
operator is not really appropriate here. this isn't about object identity.This comment is hidden because it contains spoiler information about the solution
Teshan_ss, please mark your posts as having spoiler content when posting code like that.
This comment is hidden because it contains spoiler information about the solution
In binary,
0 = False/OFF
and1 = True/ON
. In your code, this line to be exact,if item is 0:
, will also countFalse
in.Using your code, an array of
[False, 0]
willreturn
an array of[0, 0]
. Hence, the extra zero.yes I know. I'm asking why..? Why when it comes to False ..in line 3 - if item is 0 or if 0 is item become True ..?
Any help.. or suggestions..
Your result returned an extra
0
at the end of the array.This comment is hidden because it contains spoiler information about the solution