The Ising model is a simple widespread model in statistical
physics for simulating magnetic properties of matter.
In this model, we consider a rectangular grid, and we associate
each grid point with a value '+' or '-' (which physically
represents the spin of the element positioned at that grid point).
When we have such a spin configuration, the total energy of this
configuration is computed by adding the values contributed by
each pair of neighboring cells (only horizontal and vertical
direct neighbors are considered). If the pair consists
of two cells with the same spin (both '+' or both '-'), this pair
contributes a value of -1 to the total energy. Otherwise (one cell
is '+' and its neighbor is '-'), the pair contributes a value of +1
to the total energy.
See example 0 for a detailed computation of the energy value.
You are given a String spins representing the
spin configuration. You are to return the total energy of this