A microstate is a list which shows which energy state each molecule in a system is in. A configuration, on the other hand, is a list of how many molecules are in each energy state (treating each molecule as identical to each other). The weight of the configuration is the number of ways the molecules can be arranged across the energy states to produce the given configuration.
We used Lagrange multipliers in order to maximize the weight function while also putting constraints on each energy state in order to conserve certain values. Using alpha and beta*epsilon for each energy state, we introduced constraints on the total number of particles (change for each energy adds up to 0) and the total energy of the system (change for each energy state also adds up to 0), respectively. This is to prevent particles and energy from being added or taken away from the system in the equation (subsequently allowing values to drop to zero or go to infinity, which makes it difficult to find the maximum or minimum).
Each separate configuration that is listed is a different microstate (repeats in configuration indicates a different arrangement of molecules with the same configuration), so I introduced the variable called "microstates" and added 1 after each iteration within the outer iteration. I then printed out the value.