Smokes your problems, coughs fresh air.

# Tag: math

Soon, I wish to document some statistical issues I’ve been running into lately due to the lack of understanding maintained by my recipe-level statistics training. Also, I’d like to document some of the things I did learn over the years, and, hopefully, the things I find out while working myself out of the modelling mountain that I currently find so difficult to mount. For this I will need to use some mathematical language, which is why I just installed the MathJaX-LaTeX WordPress plugin. MathJax-LaTeX uses the MathJax JavaScript library to support LaTeX and MathML math equations in WordPress without requiring the browser to have MathML support.

As for testing it, my knowledge ($$K()$$) of MathML ($$M$$) is pretty much nonexistant, while I’m quite comfortable with LaTeX ($$L$$) math exations, which is why I’m typing the LaTeX code “K(M) \ll K(L)” to generate the following simple equation:

$$K(M) \ll K(L)$$

Last februari/march, I’ve been working again on an old obsession from ten years ago (when I was eighteen): to write a Minesweeper program that could solve very big maps as well or better than the best human player. At the time I did this because I thought that this was actually a million dollar challenge from the Clay Mathematics Institute. Now, I understand that the problem I solved at the time was not actually what was required, but still, once upon a time (such as early this year), I like to revisit the old problem and try to redo my old segfault generator as something that benefits from the fact that I’m now working with 10 years of programming experience instead of 1.

Minesweeper is grid-based, and I wanted to be able to express a coordinate in something more natural than two numbers. My Coords class has a toString() method which I wanted to output a Spreadsheet-like coordinate comprised of a letter (for the column index) and a number (for the row index). It took me some time to find a nice method to convert an integer to hexavigesimal. (Hexavigesimal is base 26 and 26 happens to be the number of letters in the English alphabet.)

This is what I ended up with:

std::string
Coords::toString()
{
Coord x = getCol()+1, y = getRow()+1;
int dividend = x;
int modulo;
std::string base26column = "";

while (dividend > 0)
{
modulo = (dividend - 1) % 26;
base26column = (char)(65 + modulo) + base26column;
dividend = (int)((dividend - modulo) / 26);
}

char row[(y / 10) + 1];
sprintf(row, "%d", (int)y);

return base26column + row;
}

I used the following sources:

Maybe I’ll soon start fooling with this again. Finishing this draft of eleven months old actually makes my fingers ache to play with a real close-to-the-metal programming language again. An over-engineered minesweeper clone in C++ might be fun to play with some more.