Make “word images” from atomic symbols of the table of elements, as in Periodle

tikz-pgf

One of the harder offshoots of Wordle is a game called Periodle. In this version you make words from the atomic symbols of the periodic table of elements. As in

enter image description here

Here the request is to make it possible for a chemistry teacher to print one word or a table of such word images.
The teacher supplies the word or the list of words, how it spells via the atomic symbols, and its meaning.
So, the list consists of entries such as:

P-H-Y-Si-Cs : Physics is a branch of science

Your program outputs a table consisting of word images. With the addition of the optional definition underneath or above the image. (The above picture comes from (Source), you choose your style).

The general input to the program is a list of each atomic symbol with its atomic number, the name of the element, and some color scheme number.
As in

Ac, 89, Actinium, 6

or it could be just a question mark, in case the teacher wants to leave out some symbols and then ask students to guess it.

Other teachers can also make use of the Periodle game for class activity. A restriction in the Periodle is that all words are 5 symbols long (and 6-10 letters). For helping kids to play this rather hard game the teacher might want to present some words in a table with C columns (probably C=3 or 4 is a good choice). This will be a nice feature as it allows kids to scan many words at once.

The following is an alphabetic list of the elements (I am not a chemist and hopefully I have not made a mistake in making the list). The color scheme is according to the traditional “chemical group block'', but a teacher might consider another basis for coloring the elements. The color designation of blocks here are

1=Nonmetal, 2=Alkali Metal, 3=Alkaline Earth Metal, 4=Transition Metal, 5=Lanthanide, 6=Actinide, 7=Metalloid, 8=Post-Transition Metal, 9=Halogen, 10=Noble Gas

(Edit: The entries for Krypton and Tennessine were corrected.)

Ac, 89, Actinium, 6

Ag, 47, Silver, 4

Al, 13, Aluminum, 4

Am, 95, Americium, 6

Ar, 18, Argon, 10

As, 33, Arsenic, 7

At, 85, Astatine, 9

Au, 79, Gold, 4

B, 5, Boron, 7

Ba, 56, Barium, 3

Be, 4, Beryllium, 4

Bh, 107, Bohrium, 4

Bi, 83, Bismuth, 8

Bk, 97, Berkelium, 6

Br, 35, Bromine, 9

C, 6, Carbon, 1

Ca, 20, Calcium, 3

Cd, 48, Cadmium, 4

Ce, 58, Cerium, 5

Cf, 98, Californium, 6

Cl, 17, Chlorine, 9

Cm, 96, Curium, 6

Cn, 112, Copernicium, 4

Co, 27, Cobalt, 4

Cr, 24, Chromium, 4

Cs, 55, Cesium, 2

Cu, 29, Copper, 4

Db, 105, Dubnium, 4

Ds, 110, Darmstadtium, 4

Dy, 66, Dysprosium, 5

Er, 68, Erbium, 5

Es, 99, Einsteinium, 6

Eu, 63, Europium, 5

F, 9, Fluorine, 9

Fe, 26, Iron, 3

Fl, 114, Flerovium, 8

Fm, 100, Fermium, 6

Fr, 87, Francium, 2

Ga, 31, Gallium, 8

Gd, 64, Gadolinium, 5

Ge, 32, Germanium, 7

H, 1 , Hydrogen, 1

He, 2, Helium, 10

Hf, 72, Hafnium, 4

Hg, 80, Mercury, 4

Ho, 67, Holmium, 5

Hs, 108, Hassium, 4

I, 53, Iodine, 9

In, 49, Indium, 8

Ir, 77, Iridium, 4

K, 19, Potassium, 2

Kr, 36, Krypton, 10

La, 57, Lanthanum, 5

Li, 3, Lithium, 2

Lr, 103, Lawrencium, 6

Lu, 71, Lutetium, 5

Lv, 116, Livermorium, 8

Md, 101, Mendelevium, 6

Mg, 12, Magnesium, 3

Mn, 25, Manganese, 4

Mo, 42, Molybdenum, 4

Ms, 115, Moscovium, 8

Mt, 109, Meitnerium, 4

N, 7, Nitrogen, 1

Na, 11, Sodium, 2

Nb, 41, Niobium, 4

Nd, 60, Neodymium, 5

Ne, 10, Neon, 10

Nh, 113, Nihonium, 8

Ni, 28, Nickel, 4

No, 102, Nobelium, 6

Np, 93, Neptunium, 6

O, 8, Oxygen, 1

Og, 118, Oganesson, 10

Os, 76, Osmium, 4

P, 15, Phosphorus, 1

Pa, 91, Protactinium, 6

Pb, 82, Lead, 8

Pd, 46, Palladium, 4

Pm, 61, Promethium, 5

Po, 84, Polonium, 7

Pr, 59, Praseodymium, 5

Pt, 78, Platinum, 4

Pu, 94, Plutonium, 6

Ra, 88, Radium, 2

Rb, 37, Rubidium, 2

Re, 75, Rhenium, 4

Rf, 104, Rutherfordium, 4

Rg, 111, Roentgenium, 4

Rh, 45, Rhodium, 4

Rn, 86, Radon, 10

Ru, 44, Ruthenium, 4

S, 16, Sulfur, 1

Sb, 51, Antimony, 7

Sc, 21, Scandium, 4

Se, 34, Selenium, 1

Sg, 106, Seaborgium, 4

Si, 14, Silicon, 7

Sm, 62, Samarium, 5

Sn, 50, Tin, 8

Sr, 38, Strontium, 3

Ta, 73, Tantalum, 4

Tb, 65, Terbium, 5

Tc, 43, Technetium, 4

Te, 52, Tellurium, 7

Th, 90, Thorium, 6

Ti, 22, Titanium, 4

Tl, 81, Thallium, 8

Tm, 69, Thulium, 5

Ts, 117, Tennessine, 9

U, 92, Uranium, 6

V, 23, Vanadium, 4

W, 74, Tungsten, 4

Xe, 54, Xenon, 10

Y, 39, Yttrium, 4

Yb, 70, Ytterbium, 5

Zn, 30, Zinc, 4

Zr, 40, Zirconium, 4

Best Answer

Updated Solution:

The whole thing is now wrapped into a macro \periodle that takes a comma-separated list of element symbols. So

\periodle{P,H,Y,Si,Cs}

\periodle{La,Te,Xe,Rf,O,Re,V,Er}

Produces

enter image description here

If you include a symbol that is not the symbol of an element, a gray ? tile will appear. The color is controled with \definecolor{unk}{rgb}{.3,.3,.3}

\periodle{La,Te,Xe,Rf,O,Re,V,Er,?}

enter image description here

You can add elements to \elementlist using the syntax <symbol>/<number>/<name>/<color>. For example, Lx/314/Latex/pink.

The color values are approximated from the Periodle website:

enter image description here

Here is the code including the lengthy \elementlist. Note there were a few errors I fixed (uncapitalized Kr, misspelled Tennessine). There may be others.

\documentclass{article}

\usepackage{tikz,ifthen}
\usetikzlibrary{chains}

\newcommand{\elementlist}{Ac/89/Actinium/6,Ag/47/Silver/4,Al/13/Aluminum/4,Am/95/Americium/6,Ar/18/Argon/10,As/33/Arsenic/7,At/85/Astatine/9,Au/79/Gold/4,B/5/Boron/7,Ba/56/Barium/3,Be/4/Beryllium/4,Bh/107/Bohrium/4,Bi/83/Bismuth/8,Bk/97/Berkelium/6,Br/35/Bromine/9,C/6/Carbon/1,Ca/20/Calcium/3,Cd/48/Cadmium/4,Ce/58/Cerium/5,Cf/98/Californium/6,Cl/17/Chlorine/9,Cm/96/Curium/6,Cn/112/Copernicium/4,Co/27/Cobalt/4,Cr/24/Chromium/4,Cs/55/Cesium/2,Cu/29/Copper/4,Db/105/Dubnium/4,Ds/110/Darmstadtium/4,Dy/66/Dysprosium/5,Er/68/Erbium/5,Es/99/Einsteinium/6,Eu/63/Europium/5,F/9/Fluorine/9,Fe/26/Iron/3,Fl/114/Flerovium/8,Fm/100/Fermium/6,Fr/87/Francium/2,Ga/31/Gallium/8,Gd/64/Gadolinium/5,Ge/32/Germanium/7,H/1/Hydrogen/1,He/2/Helium/10,Hf/72/Hafnium/4,Hg/80/Mercury/4,Ho/67/Holmium/5,Hs/108/Hassium/4,I/53/Iodine/9,In/49/Indium/8,Ir/77/Iridium/4,K/19/Potassium/2,Kr/36/Krypton/10,La/57/Lanthanum/5,Li/3/Lithium/2,Lr/103/Lawrencium/6,Lu/71/Lutetium/5,Lv/116/Livermorium/8,Md/101/Mendelevium/6,Mg/12/Magnesium/3,Mn/25/Manganese/4,Mo/42/Molybdenum/4,Ms/115/Moscovium/8,Mt/109/Meitnerium/4,N/7/Nitrogen/1,Na/11/Sodium/2,Nb/41/Niobium/4,Nd/60/Neodymium/5,Ne/10/Neon/10,Nh/113/Nihonium/8,Ni/28/Nickel/4,No/102/Nobelium/6,Np/93/Neptunium/6,O/8/Oxygen/1,Og/118/Oganesson/10,Os/76/Osmium/4,P/15/Phosphorus/1,Pa/91/Protactinium/6,Pb/82/Lead/8,Pd/46/Palladium/4,Pm/61/Promethium/5,Po/84/Polonium/7,Pr/59/Praseodymium/5,Pt/78/Platinum/4,Pu/94/Plutonium/6,Ra/88/Radium/2,Rb/37/Rubidium/2,Re/75/Rhenium/4,Rf/104/Rutherfordium/4,Rg/111/Roentgenium/4,Rh/45/Rhodium/4,Rn/86/Radon/10,Ru/44/Ruthenium/4,S/16/Sulfur/1,Sb/51/Antimony/7,Sc/21/Scandium/4,Se/34/Selenium/1,Sg/106/Seaborgium/4,Si/14/Silicon/7,Sm/62/Samarium/5,Sn/50/Tin/8,Sr/38/Strontium/3,Ta/73/Tantalum/4,Tb/65/Terbium/5,Tc/43/Technetium/4,Te/52/Tellurium/7,Th/90/Thorium/6,Ti/22/Titanium/4,Tl/81/Thallium/8,Tm/69/Thulium/5,Ts/117/Tennessine/9,U/92/Uranium/6,V/23/Vanadium/4,W/74/Tungsten/4,Xe/54/Xenon/10,Y/39/Yttrium/4,Yb/70/Ytterbium/5,Zn/30/Zinc/4,Zr/40/Zirconium/4}

\definecolor{1}{rgb}{0.01, 0.28, 1.00}
\definecolor{2}{rgb}{1.00, 0.03, 0.00}
\definecolor{3}{rgb}{1.00, 0.49, 0.00}
\definecolor{4}{rgb}{0.99, 0.93, 0.00}
\definecolor{5}{rgb}{0.80, 0.00, 0.80}
\definecolor{6}{rgb}{1.00, 0.08, 0.58}
\definecolor{7}{rgb}{0.00, 0.75, 1.00}
\definecolor{8}{rgb}{0.20, 0.80, 0.20}
\definecolor{9}{rgb}{0.62, 0.00, 1.00}
\definecolor{10}{rgb}{0.41, 0.00, 0.66}
\definecolor{unk}{rgb}{.3,.3,.3}

\newcommand{\periodle}[1]{\tikz[start chain, node distance=0mm]{\foreach \elem in {#1}{\xdef\ll{?}\xdef\nn{}\xdef\mm{}\xdef\cc{unk}
    \foreach \l/\n/\m/\c in \elementlist{\ifthenelse{\equal{\l}{\elem}}{\xdef\ll{\l}\xdef\nn{\n}\xdef\mm{\m}\xdef\cc{\c}}{}}
    \node[on chain, line width=.5mm, draw=gray, shade, left color=\cc, right color=white, shading angle=210, minimum size=1cm, font=\sffamily\bfseries](B){\ll};
    \node[font=\sffamily\bfseries, transform shape,scale=.4] at ([yshift=-3mm]B){\nn};
    \node[font=\sffamily\bfseries, transform shape,scale=.4] at ([yshift=3mm]B){\mm};
}}}


\begin{document}

\periodle{P,H,Y,Si,Cs}

\periodle{La,Te,Xe,Rf,O,Re,V,Er,?}

\end{document}

Old Solution:

OK. This is a bit silly, but here is a macro \periodle that takes a comma-separated list as input. Each entry should have the form <symbol>/<name>/<number>/<color>.

enter image description here

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{chains}

\definecolor{c1}{rgb}{0.68, 0.87, 0.68}
\definecolor{c2}{rgb}{0.99, 0.99, 0.59}
\definecolor{c3}{rgb}{0.74, 0.83, 0.99}
\definecolor{c4}{rgb}{0.81, 0.59, 0.86}

\newcommand{\periodle}[1]{\tikz[start chain, node distance=0mm]{\foreach \l/\n/\m/\c in {#1}{
    \node[on chain, line width=.5mm, draw=gray, shade, left color=\c, right color=white, shading angle=210, minimum size=1cm, font=\sffamily\bfseries](B){\l};
    \node[font=\sffamily\bfseries, transform shape,scale=.4] at ([yshift=-3mm]B){\n};
    \node[font=\sffamily\bfseries, transform shape,scale=.5] at ([yshift=3mm]B){\m};
}}}

\begin{document}

\periodle{Lx/Latexium/201/c1,Xt/Xetexium/202/c2,Mp/Metapostium/203/c3,L/Luanium/204/c4}

\end{document}
Related Question