Skip to content

Instantly share code, notes, and snippets.

@tmshv
Last active December 14, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tmshv/5013726 to your computer and use it in GitHub Desktop.
Save tmshv/5013726 to your computer and use it in GitHub Desktop.
import math
def cell_index(index, length):
r = math.floor(index / length)
c = index - (r * length)
return {'column':int(c), 'row':int(r)}
/**
* Возвращает индекс ячейки
* @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};
}
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