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.
I didn't know that this kind of equality worked, so that changes everything. When I was talking about sorting, I was talking about input, for example in ascending or descending order.
But if it's true that order doesn't matter in a dictionary, my error was linked to the extra character.
Thanks for the explanations, at least I understand why my solution works now!
how would you sort a dictionary ? a dictionary / hash is a data structure that associates keys to values. two dictionaries are equal if they associate the same values to the same keys, that's it.
{1: None, 2: None} == {2: None, 1: None}
, the==
operator will not check the "order" of the keys.I'm confused here, dictionaries can be sorted, but what I don't understand is why in the tests we consider that 3 2 5 6 1 4 is sorted in descending order.
I think OP is confused by the " a hash sorted by the highest number of occurrences." sentence. Usual dictionary data structures cannot be sorted, so the sentence is misleading.
This comment is hidden because it contains spoiler information about the solution
You're asked to sort by the greatest number of occurrences, but it's clear that on the test this isn't the case: 3 2 5 6 4. Or maybe there's a subtlety I don't understand.
Edit: I've removed the character that wasn't supposed to be taken into account and now everything works, someone must have modified the tests as they're now ordered in the right way.
As a reminder, this is a test that is given and is clearly not ordered:
{3: [‘3’, ‘7’, ‘9’, ‘b’, ‘g’, ‘p’, ‘v’], 2: [‘2’, ‘d’, ‘i’, ‘j’, ‘k’, ‘y’], 5: [‘8’, ‘f’, ‘n’, ‘r’, ‘t’, ‘x’],
6: [‘q’], 1: [‘0’, ‘c’, ‘h’, ‘l’, ‘m’], 4: [‘6’, ‘a’, ‘o’, ‘s’, ‘z’]}
3 2 5 6 1 4 is not ordered by the largest.
Tests are not broken
Approved
Python is missing explicit
import
s ofcodewars_test
andsolution
; and also missing decorators in the sample tests.fixed here
It's difficult to tell what you did wrong without knowing your code. But one thing I see is that your answer contains the character
'-'
, while the description says to ignore spaces and special characters.I think a lot of python tests are totally broken because here is what I produce :
{6: [‘q’], 5: [‘8’, ‘f’, ‘n’, ‘r’, ‘t’, ‘x’], 4: [‘6’, ‘a’, ‘o’, ‘s’, ‘z’], 3: [‘3’, ‘7’, ‘9’, ‘b’, ‘g’, ‘p’, ‘v’], 2: [‘-’, ‘2’, ‘d’, ‘i’, ‘j’, ‘k’, ‘y’], 1: [‘0’, ‘c’, ‘h’, ‘l’, ‘m’]}
and this is what the test tells me is the correct way :
{3: [‘3’, ‘7’, ‘9’, ‘b’, ‘g’, ‘p’, ‘v’], 2: [‘2’, ‘d’, ‘i’, ‘j’, ‘k’, ‘y’], 5: [‘8’, ‘f’, ‘n’, ‘r’, ‘t’, ‘x’], 6: [‘q’], 1: [‘0’, ‘c’, ‘h’, ‘l’, ‘m’], 4: [‘6’, ‘a’, ‘o’, ‘s’, ‘z’]}
Haskell translation
Enabled in this fork
I hope to see more challenges like this on CodeWars! Thanks for your effort in creating such engaging problems!
Done, note that your inRange method is wrong and now it doesn't pass some added tests.
Loading more items...