Last active
December 31, 2015 01:59
-
-
Save k0d3d/a9280dedddde80ef9375 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
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