Skip to content

Instantly share code, notes, and snippets.

Created June 21, 2014 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b349b2a4cbbb615ab7f2 to your computer and use it in GitHub Desktop.
Save anonymous/b349b2a4cbbb615ab7f2 to your computer and use it in GitHub Desktop.
var comboLock = function(n, x, y, z) {
ans = (3*n) + x;
if (y < x) {
ans = ans + (n - x) + y;
}
else {
ans = ans + (y - x);
}
if (z < y) {
ans = ans + (y - z);
}
else {
ans = ans + (n - z) + y;
}
return ans
};
console.log(comboLock(5, 1, 2, 3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment