Monday, November 10, 2008

Just two ideas...

I just had two ideas, that would be great to implement...

_ Change the code to the n-resolution (i.e. the macro will work with 4*4 and 16*16 Sudokus). This would be pretty easy, with a 'find/replace' of 9 per n, 8 per (n-1), plus adding a symbol decoder (i.e "A=10", "B=11" etc.).

_Change the code to use Strings insteads of Arrays(). This would be much longer to implement (but not much harder) as the core will have to be updated. However this change could boost greatly the efficiency, and thus decrease drastically the resolution/generation times. Let's explain why below...

Indeed, and for those who can access code, the MacroSudoku is creating/sending Arrays of Integers (which is called Solution(8,8,9) or MyArray(8,8,9) to its subfunctions. As Visual Basic cannot send Arrays by value (and only as a reference/pointer), the recursive functions (such as Solve(), CreateGrid etc.) always have to make a copy of their Arrays before calling themselves. This, for sure, increase the memory needed and the number of operation required (notably to duplicate/copy Arrays. Switching to String (such as '123406789' for a case where 5 cannot be) could thus avoid all these issues and boost the performance...but it will need to change most of the core code!

No comments: