Apart from having a unique name, chemical elements are also identified by a unique symbolic representation. Chemical symbols are one or two letters from the Latin alphabet, but can be three letters when the element has a provisional name. Chemical symbols are written with an uppercase first letter, followed by zero ore more lowercase letters.

symbols used by alchemists
Symbols used by alchemists to indicate the chemical elements. 1=tin, 2=lead, 3=gold, 4=sulfur, 5=mercury, 6=silver, 7=iron.

Earlier chemical symbols stem from classical Latin and Greek vocabulary. For some elements, this is because the material was known in ancient times, while for others, the name is a more recent invention. For example, He is the symbol for helium (New Latin name; not known in ancient Roman times), Pb for lead (plumbum in Latin), and Hg for mercury (hydrargyrum in Greek). Some symbols come from other sources, like W for tungsten (Wolfram in German; not known in Roman times).

Provisional symbols assigned to newly or not-yet synthesized elements use 3-letter symbols based on their atomic numbers. For example, Uno was the temporary symbol for hassium (element 108) which had the temporary name of unniloctium.

In Chinese, each chemical element has a dedicated character1, usually created for the purpose. However, Latin symbols are also used, especially in formulas.

Assignment

To get rid of the fact that there isn't always a direct connection between the name of a chemical element and its symbolic representation, we have decided to use a systematic way to assign a new symbol to each chemical element. These are the selection criteria we have already agreed upon:

  1. each symbol must start with an uppercase letter, followed by zero or more lowercase letters

  2. symbols should be formed by discarding letters from the name of the chemical element (without making a distinction between uppercase and lowercase letters, but taking into account the order of the letters as they occur in the name of the chemical element)

This still opens the possibility to derive many candidate symbols from the name of a chemical element. The following additional selection criteria are still under discussion:

  1. all chemical elements should have fixed-length symbols (for example two-letter symbols)

  2. of all candidate symbols, preference is given to the one that comes first/last alphabetically

In order to help selecting new symbols for the chemical elements, you are asked to:

Example

>>> isvalid('Zer', 'Zeddemorium')
True
>>> isvalid('Zer', 'Zeddemorium', 2)
False
>>> isvalid('di', 'Zeddemorium')
False

>>> symbols('Iron')
{'Ir', 'Io', 'In', 'Ro', 'Rn', 'On'}
>>> symbols('Neon')
{'Eo', 'Nn', 'No', 'En', 'Ne', 'On'}

>>> preference('Iron')
'In'
>>> preference('Iron', last=True)
'Ro'
>>> preference('Neon')
'En'
>>> preference('Neon', True)
'On'

Epilogue

When Hitler's army marched into Copenhagen, Niels Bohr2 had to decide how to safeguard the Nobel medals of James Franck3 and Max von Laue4, which they had entrusted to him. Sending gold out of the country was almost a capital offense, and the physicists' names were engraved on the medals, making such an attempt doubly risky. Burying the medals seemed uncertain as well. Finally his friend — the Hungarian radiochemist George de Hevesy5 — invented a novel solution: he dissolved the medals in a jar of aqua regia6, which Bohr left on a shelf in his laboratory while he fled to Sweden.

When he returned in 1945, the jar was still there. Bohr had the gold recovered, and the Nobel Foundation recast it into two medals.

Nobel Prize winners
Three winners of the Nobel Prize in Physics: Niels Bohr, Max Von Laue and James Franck.

Chemist Hermann Francis Mark7 also found a clever way to escape Germany with his money: he used it to buy platinum wire, which he fashioned into coat hangers. Once he had brought these successfully through customs, he sold them to recover the money.