code: def char2hex(a: str):
      
      if "0" <= a <= "9":
          return ord(a) - 48
      elif "A" <= a <= "F":
          return ord(a) - 55
      elif "a" <= a <= "f":  # a-f
          return ord(a) - 87
      return -1
docs: Convert a hex character to its integer value.
  
      '0' becomes 0, '9' becomes 9
      'A' becomes 10, 'F' becomes 15
      'a' becomes 10, 'f' becomes 15
  
      Returns -1 on error.