Last active
December 14, 2015 02:29
-
-
Save tmshv/5013726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def cell_index(index, length): | |
r = math.floor(index / length) | |
c = index - (r * length) | |
return {'column':int(c), 'row':int(r)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Возвращает индекс ячейки | |
* @param index порядковый индекс | |
* @param length длина строки | |
* @return | |
* | |
*/ | |
public function cellIndex(index:uint, length:uint):Object { | |
var r:uint = Math.floor(index / length); | |
var c:uint = index - (r * length); | |
return {column:c, row:r}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int[] cellIndex(int index, int length){ | |
int r = floor(index / length); | |
int c = index - (r * length); | |
return new int[]{c, r}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment