Text this: Quadratic equations over p-adic fields and their applications in statistical mechanics