Planetary code golf

1 · John Cook · Sept. 18, 2021, 11:06 a.m.
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....