#[cfg(test)]
mod tests;
pub fn num_to_sxg(n: u128) -> String {
static DIGITS: &[u8; 60] = b"0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz";
if n == 0 {
return "0".to_string();
}
let mut n = n;
let mut s = String::new();
while n > 0 {
let d = n % 60;
let ch = DIGITS[d as usize] as char;
s.push(ch);
n = (n - d) / 60;
}
s.chars().rev().collect()
}
pub fn sxg_to_num(s: &str) -> Option<u128> {
let mut n: u128 = 0;
for c in s.chars() {
let digit = match c {
'0'..='9' => c as u8 - b'0',
'A'..='H' => c as u8 - b'A' + 10,
'J'..='N' => c as u8 - b'J' + 18,
'P'..='Z' => c as u8 - b'P' + 23,
'_' => 34,
'a'..='k' => c as u8 - b'a' + 35,
'm'..='z' => c as u8 - b'm' + 46,
'I' | 'l' => 1, 'O' => 0, _ => continue, };
n = n.checked_mul(60)?.checked_add(digit as u128)?;
}
Some(n)
}