If there's only one way to do it, and anyone faced with the same problem would have to do it the same way, it's a discovery. Otherwise, it's an invention.
Inventions are patentable. Discoveries aren't. Or shouldn't be, according to the intent of the system.