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


with javascript_semantics
constant match_wp = false

function prc(integer n)
    constant t = {0,2,10,18,36,54,86,118,119}
    integer row = abs(binary_search(n,t,true))-1,
            col = n-t[row]
    if col>1+(row>1) then
        col = 18-(t[row+1]-n)
        if match_wp then
            if col<=2 then return {row+2,col+14} end if
        else -- matches above ascii:
            if col<=2+(row>5) then return {row+2,col+15} end if
        end if
    end if
    return {row,col}
end function

sequence pt = repeat(repeat("   ",19),10)
pt[1][2..$] = apply(true,sprintf,{{"%3d"},tagset(18)})  -- column headings
for i=1 to 9 do pt[i+1][1] = sprintf("%3d",i) end for -- row numbers
for i=1 to 118 do
    integer {r,c} = prc(i)
    pt[r+1][c+1] = sprintf("%3d",i)
end for
if not match_wp then -- (ascii only:)
    pt[7][4] = " L*"
    pt[8][4] = " A*"
    pt[9][2..4] = {"Lanthanide:"}
    pt[10][2..4] = {"  Actinide:"}
end if
printf(1,"%s\n",{join(apply(true,join,{pt,{"|"}}),"\n")})
