Task

Display the row and column in the periodic table of the given atomic number.

The periodic table

Let us consider the following periodic table representation.

     __________________________________________________________________________ 
    |   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18 |
    |                                                                          |
    |1  H                                                                   He |
    |                                                                          |
    |2  Li  Be                                          B   C   N   O   F   Ne |
    |                                                                          |
    |3  Na  Mg                                          Al  Si  P   S   Cl  Ar |
    |                                                                          |
    |4  K   Ca  Sc  Ti  V   Cr  Mn  Fe  Co  Ni  Cu  Zn  Ga  Ge  As  Se  Br  Kr |
    |                                                                          |
    |5  Rb  Sr  Y   Zr  Nb  Mo  Tc  Ru  Rh  Pd  Ag  Cd  In  Sn  Sb  Te  I   Xe |
    |                                                                          |
    |6  Cs  Ba  *   Hf  Ta  W   Re  Os  Ir  Pt  Au  Hg  Tl  Pb  Bi  Po  At  Rn |
    |                                                                          |
    |7  Fr  Ra  °   Rf  Db  Sg  Bh  Hs  Mt  Ds  Rg  Cn  Nh  Fl  Mc  Lv  Ts  Og |
    |__________________________________________________________________________|
    |                                                                          |
    |                                                                          |
    |8  Lantanoidi* La  Ce  Pr  Nd  Pm  Sm  Eu  Gd  Tb  Dy  Ho  Er  Tm  Yb  Lu |
    |                                                                          |
    |9   Aktinoidi° Ak  Th  Pa  U   Np  Pu  Am  Cm  Bk  Cf  Es  Fm  Md  No  Lr |
    |__________________________________________________________________________|

Example test cases;
   1 -> 1 1
   2 -> 1 18
   29 -> 4 11
   42 -> 5 6
   57 -> 8 4
   58 -> 8 5
   72 -> 6 4
   89 -> 9 4
Details;
The representation of the periodic table may be represented in various way. The one presented in this challenge does have the following property : Lantanides and Aktinoides are all in a dedicated row, hence there is no element that is placed at 6, 3 nor 7, 3.

You may take a look at the atomic number repartitions here.

The atomic number is at least 1, at most 118.



See also
 
   the periodic table
   This task was an idea from CompSciFact
   The periodic table in ascii that was used as template


const limits = [3:10, 11:18, 19:36, 37:54, 55:86, 87:118]
 
function periodic_table(n)
    (n < 1 || n > 118) && error("Atomic number is out of range.")
    n == 1 && return [1, 1]
    n == 2 && return [1, 18]
    57 <= n <= 71 && return [8, n - 53]
    89 <= n <= 103 && return [9, n - 85]
    row, limitstart, limitstop = 0, 0, 0
    for i in eachindex(limits)
        if limits[i].start <= n <= limits[i].stop
            row, limitstart, limitstop = i + 1, limits[i].start, limits[i].stop
            break
        end
    end
    return (n < limitstart + 2 || row == 4 || row == 5) ?
        [row, n - limitstart + 1] : [row, n - limitstop + 18]
end
 
for n in [1, 2, 29, 42, 57, 58, 59, 71, 72, 89, 90, 103, 113]
    rc = periodic_table(n)
    println("Atomic number ", lpad(n, 3), " -> ($(rc[1]), $(rc[2]))")
end
 