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.
This comment is hidden because it contains spoiler information about the solution
Problem solved!
Thank you very much for your help.
A little similar to Difference of 2.
What will be your log if
m=''
?Try
print(repr(s), repr(m))
.Thank you for your reply.
However, this is the log I retrieved:
Log
['Mars', 'Earth', 'Neptune', 'Asteroid', 'Venus']
The second parameter ("") does not seem to have been entered.
The problem is with your solution. It fails following test case:
test.assert_equals(is_planet_mnemonic_correct(["Mars", "Earth", "Neptune", "Asteroid", "Venus"], ""), False)
One of the tests omits the second parameter, which causes an error to be thrown. Can this be corrected, please?
Added input assertion messages on failure.
No inputs in assertion messages
Thank you!
As the input is a string, it won't modify the input, that only happens with lists.
This comment is hidden because it contains spoiler information about the solution
It makes more sense when you consider that the return value is an array which represents the relative size of each planet compared to the one on its left. So for a list like
["Asteroid", "Mercury"]
, the resulting array[">"]
means "Mercury is greater than the item on the left", which is why the greater than symbol is used. In the end, though, I don't think one way is less confusing than the other. Your list of pairs to compare could easily be reversed:Asteroid and Mars, Venus and Asteroid, Jupiter and Venus, Asteroid and Jupiter, Earth and Asteroid, Pluto and Earth.
-- they are the exact same comparisons, but now the greater/less than signs are reversed. I think it only makes more sense to you in the way that you described because your list of comparisons exactly follows the order of the items in the original array.In my humble opinion, the condition for comparison the result is reversed.
The correct order of planets is: Asteroid < Pluto < Mercury < Mars < Venus < Earth < Neptune < Uranus < Saturn < Jupiter.
Based on this, if we have a list of planets like:
["Mars", "Asteroid", "Venus", "Jupiter", "Asteroid", "Earth", "Pluto"]
We would compare the following pairs:
Mars and Asteroid, Asteroid and Venus, Venus and Jupiter, Jupiter and Asteroid, Asteroid and Earth, Earth and Pluto.
When we compare each entry, such as Mars and Asteroid, we expect the result to be '>' because Mars is bigger than Asteroid.
Similarly, Venus and Jupiter should result in '<', because Venus is smaller than Jupiter.
However, the question demands the reverse—meaning we should return '<' when the left planet is bigger, and '>' when it's smaller. This inversion of logic is what makes the current condition incorrect, and due to this we need to write the opposite condition in comaparison like -
return orderOne == orderTwo ? EQUAL : (orderOne > orderTwo ? SMALLER : GREATER);
when it actually should be -
return orderOne == orderTwo ? EQUAL : (orderOne < orderTwo ? SMALLER : GREATER);
Approved at 7 kyu
Loading more items...