@@ -0,0 +1,1705 @@
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0A%0A//Project Euler Problem 39%0A//Solved on 1/3/2016%0Apublic class Problem039%0A%7B%0A%09public static void main(String%5B%5D args)%0A%09%7B%0A%09%09int p = 3;%09%09//index variable to loop through all possible p values%0A%09%09int%5B%5D max = %7Bp, 0%7D;%09%09//max%5B0%5D stores p with most solutions, max%5B1%5D stores max number of solutions%0A%09%09while(p %3C= 1000)%09%09//loop through p values%0A%09%09%7B%0A%09%09%09ArrayList%3Cint%5B%5D%3E triples = new ArrayList%3Cint%5B%5D%3E();%09%09//holds 3-element arrays containing side lengths for solutions%0A%09%09%09int solutions = 0;%09%09//number of solutions for this current p value%0A%09%09%09for(int a = 1; a %3C p; a++)%09%09//loop through possible a values%0A%09%09%09%7B%0A%09%09%09%09for(int b = 1; b %3C p; b++)%09%09//loop through possible b values%0A%09%09%09%09%7B%0A%09%09%09%09%09int c = (int)Math.sqrt(a*a + b*b);%09%09//finds c%0A%09%09%09%09%09if(a+b+c == p && a*a + b*b == c*c)%09%09//checks if c is a valid value for right triangle%0A%09%09%09%09%09%7B%0A%09%09%09%09%09%09int%5B%5D triple = %7B1, 2, 3%7D;%09%09//creates the triple for this specific solution%0A%09%09%09%09%09%09Arrays.sort(triple);%0A%09%09%09%09%09%09if(triples.size() != 0)%09%09//if there are already solutions for this p...%0A%09%09%09%09%09%09%7B%0A%09%09%09%09%09%09%09for(int i = 0; i %3C triples.size(); i++)%09%09//checks if this triple has already been created%0A%09%09%09%09%09%09%09%7B%0A%09%09%09%09%09%09%09%09if(!triples.get(i).equals(triple))%09%09//if not, add triples to collection and increment solutions for this p%0A%09%09%09%09%09%09%09%09%7B%0A%09%09%09%09%09%09%09%09%09triples.add(triple);%0A%09%09%09%09%09%09%09%09%09solutions++;%0A%09%09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09else%09%09//if there are no current solutions for this p...%0A%09%09%09%09%09%09%7B%0A%09%09%09%09%09%09%09triples.add(triple);%0A%09%09%09%09%09%09%09solutions++;%0A%09%09%09%09%09%09%7D%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09if(solutions %3E max%5B1%5D)%09%09//if this p has more solutions than the previous max, update max%0A%09%09%09%7B%0A%09%09%09%09max%5B0%5D = p;%0A%09%09%09%09max%5B1%5D = solutions;%0A%09%09%09%7D%0A%09%09%09p++;%0A%09%09%7D%0A%09%09%0A%09%09System.out.println(max%5B0%5D);%0A%09%7D%0A%7D%0A

Add problem 39 solution