Skip to main content

Posts

Showing posts from August, 2016

Project Euler Problem 11,12,13,14,15 in Java

11) Problem 11- Project Euler Solution in Java What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? So, I basically went through every possible way we could do the multiplication in the 20X20 grid. However, the greatest product can be found found easily if I had done multiplication diagonally rather than attempt all the trials.  But, anyway it was a good practice with 2-D arrays. public static void main(String[] args) throws IOException {         FileReader ff = new FileReader("Grid File (20X20).txt");         Scanner in = new Scanner(ff);         int[][] num = new int[20][20];         ArrayList<Integer> list = new ArrayList();         //reading the numbers into 2D array         for(int i=0;i<20;i++){             for(int j=0;j<20;j++){                 num[i][j] = in.nextInt();             }           }         // Multiplying numbers vertically in downward direction         for