|P is for Practical|
Treat it less as a brute force challenge and think about your data. You have a sting
What parameters will increase the Tm? - C and G residues
For each residue, find if IUPAC can give you a C or a G for the max temperature at that residue, then a T or an A for the min temperature.
If you really need to calculate over large numbers of primers then divide the primers up into percentiles, eg 90% GC, 80% GC and so on. Its an approximation but good enough for what I think you are doing.
If you need more accuracy yet, look at your hash values - this shows you the residue pairs that give you most and least values, so see waht pairs of residues are likely for the extremes of these values and bias the calculations to those primers
Just out of curiosity where are you getting the enthalpy and entrophy values from? St. Lucia?
One other thought - if you want accurate temps, you're going to want to calculate on the monovalent and divalent ion concentrations. I suggest looking at Primer 3 for ways to calculate these values. Or simply call Primer3 rather than reinventing this in your app - it gives this information anyway.
In reply to Re: how to make this code more efficient? Need to Compute the Min and Max of a Temperature using an equation