pub struct ElementData {
    pub symbol: &'static str,
    pub atomic_number: usize,
    pub mass: f64,
}

pub static ELEMENTS: &[ElementData] = &[
    ElementData { symbol: "H", atomic_number: 1, mass: 1.008 },
    ElementData { symbol: "HE", atomic_number: 2, mass: 4.0026 },
    ElementData { symbol: "LI", atomic_number: 3, mass: 6.94 },
    ElementData { symbol: "BE", atomic_number: 4, mass: 9.0122 },
    ElementData { symbol: "B", atomic_number: 5, mass: 10.81 },
    ElementData { symbol: "C", atomic_number: 6, mass: 12.011 },
    ElementData { symbol: "N", atomic_number: 7, mass: 14.007 },
    ElementData { symbol: "O", atomic_number: 8, mass: 15.999 },
    ElementData { symbol: "F", atomic_number: 9, mass: 18.998 },
    ElementData { symbol: "NE", atomic_number: 10, mass: 20.180 },
    ElementData { symbol: "NA", atomic_number: 11, mass: 22.990 },
    ElementData { symbol: "MG", atomic_number: 12, mass: 24.305 },
    ElementData { symbol: "AL", atomic_number: 13, mass: 26.982 },
    ElementData { symbol: "SI", atomic_number: 14, mass: 28.085 },
    ElementData { symbol: "P", atomic_number: 15, mass: 30.974 },
    ElementData { symbol: "S", atomic_number: 16, mass: 32.06 },
    ElementData { symbol: "CL", atomic_number: 17, mass: 35.45 },
    ElementData { symbol: "AR", atomic_number: 18, mass: 39.948 },
    ElementData { symbol: "K", atomic_number: 19, mass: 39.098 },
    ElementData { symbol: "CA", atomic_number: 20, mass: 40.078 },
    ElementData { symbol: "SC", atomic_number: 21, mass: 44.956 },
    ElementData { symbol: "TI", atomic_number: 22, mass: 47.867 },
    ElementData { symbol: "V", atomic_number: 23, mass: 50.942 },
    ElementData { symbol: "CR", atomic_number: 24, mass: 51.996 },
    ElementData { symbol: "MN", atomic_number: 25, mass: 54.938 },
    ElementData { symbol: "FE", atomic_number: 26, mass: 55.845 },
    ElementData { symbol: "CO", atomic_number: 27, mass: 58.933 },
    ElementData { symbol: "NI", atomic_number: 28, mass: 58.693 },
    ElementData { symbol: "CU", atomic_number: 29, mass: 63.546 },
    ElementData { symbol: "ZN", atomic_number: 30, mass: 65.38 },
    ElementData { symbol: "GA", atomic_number: 31, mass: 69.723 },
    ElementData { symbol: "GE", atomic_number: 32, mass: 72.630 },
    ElementData { symbol: "AS", atomic_number: 33, mass: 74.922 },
    ElementData { symbol: "SE", atomic_number: 34, mass: 78.971 },
    ElementData { symbol: "BR", atomic_number: 35, mass: 79.904 },
    ElementData { symbol: "KR", atomic_number: 36, mass: 83.798 },
    ElementData { symbol: "RB", atomic_number: 37, mass: 85.468 },
    ElementData { symbol: "SR", atomic_number: 38, mass: 87.62 },
    ElementData { symbol: "Y", atomic_number: 39, mass: 88.906 },
    ElementData { symbol: "ZR", atomic_number: 40, mass: 91.224 },
    ElementData { symbol: "NB", atomic_number: 41, mass: 92.906 },
    ElementData { symbol: "MO", atomic_number: 42, mass: 95.95 },
    ElementData { symbol: "TC", atomic_number: 43, mass: 98.0 },
    ElementData { symbol: "RU", atomic_number: 44, mass: 101.07 },
    ElementData { symbol: "RH", atomic_number: 45, mass: 102.91 },
    ElementData { symbol: "PD", atomic_number: 46, mass: 106.42 },
    ElementData { symbol: "AG", atomic_number: 47, mass: 107.87 },
    ElementData { symbol: "CD", atomic_number: 48, mass: 112.41 },
    ElementData { symbol: "IN", atomic_number: 49, mass: 114.82 },
    ElementData { symbol: "SN", atomic_number: 50, mass: 118.71 },
    ElementData { symbol: "SB", atomic_number: 51, mass: 121.76 },
    ElementData { symbol: "TE", atomic_number: 52, mass: 127.60 },
    ElementData { symbol: "I", atomic_number: 53, mass: 126.90 },
    ElementData { symbol: "XE", atomic_number: 54, mass: 131.29 },
    ElementData { symbol: "CS", atomic_number: 55, mass: 132.91 },
    ElementData { symbol: "BA", atomic_number: 56, mass: 137.33 },
    ElementData { symbol: "LA", atomic_number: 57, mass: 138.91 },
    ElementData { symbol: "CE", atomic_number: 58, mass: 140.12 },
    ElementData { symbol: "PR", atomic_number: 59, mass: 140.91 },
    ElementData { symbol: "ND", atomic_number: 60, mass: 144.24 },
    ElementData { symbol: "PM", atomic_number: 61, mass: 145.0 },
    ElementData { symbol: "SM", atomic_number: 62, mass: 150.36 },
    ElementData { symbol: "EU", atomic_number: 63, mass: 151.96 },
    ElementData { symbol: "GD", atomic_number: 64, mass: 157.25 },
    ElementData { symbol: "TB", atomic_number: 65, mass: 158.93 },
    ElementData { symbol: "DY", atomic_number: 66, mass: 162.50 },
    ElementData { symbol: "HO", atomic_number: 67, mass: 164.93 },
    ElementData { symbol: "ER", atomic_number: 68, mass: 167.26 },
    ElementData { symbol: "TM", atomic_number: 69, mass: 168.93 },
    ElementData { symbol: "YB", atomic_number: 70, mass: 173.05 },
    ElementData { symbol: "LU", atomic_number: 71, mass: 174.97 },
    ElementData { symbol: "HF", atomic_number: 72, mass: 178.49 },
    ElementData { symbol: "TA", atomic_number: 73, mass: 180.95 },
    ElementData { symbol: "W", atomic_number: 74, mass: 183.84 },
    ElementData { symbol: "RE", atomic_number: 75, mass: 186.21 },
    ElementData { symbol: "OS", atomic_number: 76, mass: 190.23 },
    ElementData { symbol: "IR", atomic_number: 77, mass: 192.22 },
    ElementData { symbol: "PT", atomic_number: 78, mass: 195.08 },
    ElementData { symbol: "AU", atomic_number: 79, mass: 196.97 },
    ElementData { symbol: "HG", atomic_number: 80, mass: 200.59 },
    ElementData { symbol: "TL", atomic_number: 81, mass: 204.38 },
    ElementData { symbol: "PB", atomic_number: 82, mass: 207.2 },
    ElementData { symbol: "BI", atomic_number: 83, mass: 208.98 },
    ElementData { symbol: "PO", atomic_number: 84, mass: 209.0 },
    ElementData { symbol: "AT", atomic_number: 85, mass: 210.0 },
    ElementData { symbol: "RN", atomic_number: 86, mass: 222.0 },
    ElementData { symbol: "FR", atomic_number: 87, mass: 223.0 },
    ElementData { symbol: "RA", atomic_number: 88, mass: 226.0 },
    ElementData { symbol: "AC", atomic_number: 89, mass: 227.0 },
    ElementData { symbol: "TH", atomic_number: 90, mass: 232.04 },
    ElementData { symbol: "PA", atomic_number: 91, mass: 231.04 },
    ElementData { symbol: "U", atomic_number: 92, mass: 238.03 },
    ElementData { symbol: "NP", atomic_number: 93, mass: 237.0 },
    ElementData { symbol: "PU", atomic_number: 94, mass: 244.0 },
    ElementData { symbol: "AM", atomic_number: 95, mass: 243.0 },
    ElementData { symbol: "CM", atomic_number: 96, mass: 247.0 },
    ElementData { symbol: "BK", atomic_number: 97, mass: 247.0 },
    ElementData { symbol: "CF", atomic_number: 98, mass: 251.0 },
    ElementData { symbol: "ES", atomic_number: 99, mass: 252.0 },
    ElementData { symbol: "FM", atomic_number: 100, mass: 257.0 },
    ElementData { symbol: "MD", atomic_number: 101, mass: 258.0 },
    ElementData { symbol: "NO", atomic_number: 102, mass: 259.0 },
    ElementData { symbol: "LR", atomic_number: 103, mass: 262.0 },
];

pub fn get_atomic_number(symbol: &str) -> usize {
    let s = symbol.to_uppercase();
    ELEMENTS.iter().find(|e| e.symbol == s).map(|e| e.atomic_number).unwrap_or(0)
}

pub fn get_atomic_mass(symbol: &str) -> f64 {
    let s = symbol.to_uppercase();
    ELEMENTS.iter().find(|e| e.symbol == s).map(|e| e.mass).unwrap_or(0.0)
}

pub fn get_atomic_mass_by_number(z: usize) -> f64 {
    ELEMENTS.iter().find(|e| e.atomic_number == z).map(|e| e.mass).unwrap_or(0.0)
}
