Skip to content

Instantly share code, notes, and snippets.

@freddiefujiwara
Created December 8, 2011 23:38
Show Gist options
  • Save freddiefujiwara/1449270 to your computer and use it in GitHub Desktop.
Save freddiefujiwara/1449270 to your computer and use it in GitHub Desktop.
ant problem
var solve= function (L,ants){
var times = [];
var minTimes = []
for(var i = 0 ; i < ants.length ; i++){
times.push(ants[i]);
times.push(L-ants[i]);
minTimes.push(ants[i] > L-ants[i] ? L-ants[i] : ants[i]);
}
console.log("MAX:"+Math.max.apply(null,times));
console.log("MIN:"+Math.max.apply(null,minTimes));
};
solve(10,[2,6,7]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment