generate all known magic square for size N

This is one of the task he have to solve using Erlang, but I'm having my problems with it. It's not actually that we have to find a solution for all possible square sizes - only 3x3 is really necessary, 4x4 is a plus - but since we got the task I start fighting with myself about how ridiculous it'd be to only creating a variant for size 3. I'm a programmer who's alsways seeking for awesome solution to brute-forcey problems. It's not about finding only one square, it's about finding all squares! You can't take the typical Wikipedia approaches for that. So I sad and thought. It's a few days since and I somehow managed to find a solution that'd seem to work for any square size by using a (possibly dynamically filled) database of combinable, valid lines you just render onto the square cells. And damnit, it could work so well as a program if there weren't that annoying Erlang limitation! I'll create a C program first and they try to convert to Erlang, step-by-step. I'm not good at Erlang and I hope this lecturer doesn't turn nuts if I'm using not his beloved one-short-for-all solutions.

I mean really, Erlang is so stupid. No variables but value passing. What a waste of processing time.

No comments: