Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nahidakbar/98919296a3ddd568d2ae to your computer and use it in GitHub Desktop.
Save nahidakbar/98919296a3ddd568d2ae to your computer and use it in GitHub Desktop.
var dx = 10;
var dy = 10;
var dz = 3;
var decode = function(v)
{
var z = v % dz;
var xy = (v - z) / dz;
var y = xy % dy;
var x = (xy - y) / dy;
console.log('out', x, y, z);
}
var encode = function(x, y, z)
{
console.log('in', x, y, z);
return (x * dy + y) * dz + z;
}
for (var x = 0; x < dx; x++)
{
for (var y = 0; y < dy; y++)
{
for (var z = 0; z < dz; z++)
{
decode(encode(x, y, z));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment