This challenge is inspired by this Oliver Sacks quote:
“At 11, I could say ‘I am sodium’ (Element 11), and now at 79, I am gold.” ― Oliver Sacks
I want you you find numbers in a string and replace them with their corresponding elements' symbols. (1 is H, 2 is He, 3 is Li, etc.) There are a few rules to follow:
- Single and double digits get replaced with their corresponding
elements as normal. Ignore 0s at the start of numbers. If there are just 0s in a number, ignore it. E.g.
1 01 10 0 00becomes
H H Ne 0 00
- More than 2 digits together get divided into groups of 2. An odd
number of digits should have the extra single digit at the end. E.g.
0153 5301 153would become
HI IH PLiBecause of this rule, you will only need to know the elements from 1 to 99
- Numbers shall be treated the same no matter what characters surround
them and commas and decimal points are not parts of numbers.
P90X 42,800 3.14159would become
PThX Mo,Hg0 Li.SiPF
Example Inputs/Outputs (I/O):
I: 32289216 O: GeNiUS I: J08017 5811 O: JOHN CeNa I: M18227 0592tt10r O: MArTiN BUttNer I: De072816 O: DeNNiS I: D088r1907085 O: DOOrKNOB I: 13ex A. O: Alex A.
Input will be in the closest format to a string that your language has.
A periodic table for reference:
This is code-golf, so your program will be scored in bytes.