Skip to content

Instantly share code, notes, and snippets.

@k0d3d
Last active December 31, 2015 01:59
Show Gist options
  • Save k0d3d/a9280dedddde80ef9375 to your computer and use it in GitHub Desktop.
Save k0d3d/a9280dedddde80ef9375 to your computer and use it in GitHub Desktop.
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
function solution(A, B) {
var startA = 0;
var startB = 0;
var a_move = 0;
while (startA <= A && startB <= B) {
//add our steps
startA += Math.round(getRandomArbitrary(1,2));
startB += Math.round(getRandomArbitrary(1,2));
a_move++
if (startA > 100000 || startB > 100000) {
a_move = false;
break;
}
}
//then within that posibility, we continue to check for legal
//possibilities to destination_point, agreegating each possibility
//till conditions are met.
if (a_move === false) {
return -1;
}
if (a_move > 100,000,000) {
return -2
}
else {
return 3
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment