|
| 1 | +# [The Solar System - Jumbled Planets](https://www.codewars.com/kata/the-solar-system-jumbled-planets "https://www.codewars.com/kata/678e32f27625ec1b6a0e5976") |
| 2 | + |
| 3 | +Oh, no! The celestial bodies orbiting the sun are all jumbled up! |
| 4 | +<h2>TASK</h2> |
| 5 | +Given the entire Solar System in the form of a list. Return a new list which has either <code>'<'</code>, <code>'>'</code> |
| 6 | +or <code>'='</code> depending on whether the planet is smaller than the planet on its left or not. You have to start comparing from the |
| 7 | +second item, because the first has nothing on its left. |
| 8 | + |
| 9 | +However, there are also asteroids in the Solar System. All asteroids are smaller than all the planets. If two asteroids are found beside |
| 10 | +each other, the leftmost one will depend on the celestial being on the left of it. The one on the right will have `'='`. |
| 11 | + |
| 12 | +The Solar System might be empty. |
| 13 | + |
| 14 | +The celestial bodies stand in the order (size ascending): |
| 15 | + |
| 16 | +```Asteroid < Pluto < Mercury < Mars < Venus < Earth < Neptune < Uranus < Saturn < Jupiter``` |
| 17 | + |
| 18 | +<b>Important: the dwarf planet Pluto is also included in the Solar System</b> |
| 19 | + |
| 20 | +<h2>EXAMPLES<h2/> |
| 21 | + |
| 22 | +``` |
| 23 | +["Mars", "Asteroid", "Venus", "Jupiter", "Asteroid", "Earth", "Pluto"] -> ['<', '>', '>', '<', '>', '<'] |
| 24 | +# Asteriod is '<' Mars |
| 25 | +# Venus is '>' any Asteroid |
| 26 | +# Jupiter is '>' Venus |
| 27 | +# Any Asteroid is '<' Jupiter |
| 28 | +# Earth is '>' the Asteroid |
| 29 | +# Finally, Pluto, being a dwarf planet, is '<' Earth |
| 30 | +
|
| 31 | +["Asteroid", "Asteroid", "Asteroid", "Earth", "Jupiter"] -> ['=', '=', '>', '>'] |
| 32 | +# Here, the Asteroid is '=' to the Asteroid on its left |
| 33 | +# Again, it is '=' because there is another Asteroid on its left |
| 34 | +# Earth is '>' than the Asteroid |
| 35 | +# Finally, Jupiter, being the king of the planets, is '>' than Earth |
| 36 | +
|
| 37 | +["Mercury", "Venus", "Earth", "Mars", "Asteroid", "Jupiter", "Saturn", "Uranus", "Neptune", "Asteroid", "Pluto"] -> ['>', '>', '<', '<', '>', '<', '<', '<', '<', '>'] |
| 38 | +# Atleast here the Solar System is how it's supposed to be! |
| 39 | +``` |
| 40 | + |
| 41 | +<h2>NOTES</h2> |
| 42 | +· There will never be more than one of anything except asteroids |
| 43 | + |
| 44 | +· The Solar System will never contain anything outside: |
| 45 | + |
| 46 | +``` |
| 47 | +["Asteroid", "Pluto", "Mercury", "Mars", "Venus", "Earth", "Neptune", "Uranus", "Saturn", "Jupiter"] |
| 48 | +``` |
0 commit comments