by John on (#5PPF2)
Suppose you’re asked to write a function that takes a number and returns a planet. We’ll number the planets in order from the sun, starting at 1, and for our purposes Pluto is the 9th planet. Here’s an obvious solution: def planet(n): planets = [ "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" ] […]The post Planetary code golf first appeared on John D. Cook.