Encoding is completely straightforward. The 5-bit integer is being converted to a two digit base-6 number, with the metals representing exactly the numbers you would expect: Lead=0, Tin=1, Iron=2, Copper=3, Silver=4, and Gold=5.