Created
September 18, 2014 07:10
-
-
Save nahidakbar/98919296a3ddd568d2ae 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
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