Int i, j, step_count, x_move, y_move, cnt, k Looking at the other variables, we can reduce the following to 8 bit numbers: In the UNO version the array can now defined as: But we don't need this, by defining the array using int8_t, it will half the size of the array and be able to store numbers between -128 and 127. This means it will hold a number between -3277. Integers defined using the int type are 16 bits or 2 bytes. Secondly, each array element will hold a number between -1 and 64. So the 8x8 array is now 9x9 and thus 17 elements in the array are not used. While it is usually easier to think in a range of 1 to N than 0 to N-1, defining the array as 0 to N means that element 0 is never used in this case. In C and C++, arrays are zero based, that is the first element in an array is 0 and the last element in an array should be N-1. In the MEGA version, the array that holds the moves is defined as: Make sure variables only use the minimum size they require: Knight's Tour Puzzle solved on a Arduino UNOġ.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |