Created
          March 3, 2017 23:26 
        
      - 
      
- 
        Save Underdoge/2842a8d920e549fe22f3621538230b13 to your computer and use it in GitHub Desktop. 
    avoidObstacles
  
        
  
    
      This file contains hidden or 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 avoidObstacles(inputArray) { | |
| var min=2; | |
| var test=false; | |
| var max=inputArray.reduce(function(a, b) { | |
| return Math.max(a, b); | |
| }); | |
| while(min<=max+1&&!test){ | |
| test=true; | |
| for(var i=0;i<inputArray.length&&test;i++){ | |
| console.log(inputArray[i]+" "+min); | |
| if(inputArray[i]%min==0){ | |
| test=false; | |
| } | |
| } | |
| min++; | |
| } | |
| min--; | |
| return min; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment