public class BruteForceSolutions { public static void main(String[] args) { //Problem # 1 - TwoDigitNumber System.out.println("\n\n##### Problem # 1 #####"); for(int num = 10; num<100; num++) { int tens = num/10; int ones = num%10; if((tens+ones)* 9 == num) System.out.println(num); } //Problem # 2 - PattyAndTerry System.out.println("\n\n##### Problem # 2 #####"); for(int patty = 1; patty< 100; patty++) { for(int terry = 1; terry < 100; terry++) { if(patty == terry * 3 && (patty + 10) + (terry + 10)==36) System.out.println("Patty is " + patty + " and Terry is " + terry); } } //Problem # 3 - ThreeDigitNumber System.out.println("\n\n##### Problem # 3 #####"); for(int num = 100; num<1000; num++) { int hundreds = num / 100; int tens = num / 10 % 10; int ones = num % 10; if(tens == ones + 5 && hundreds == tens - 8) System.out.println(num); } //Problem # 4 - NumberProduct System.out.println("\n\n##### Problem # 4 #####"); int product = 1; for(int num = 1; num<=12; num++) product *= num; System.out.println(product); //Problem # 5 - Grandpa System.out.println("\n\n##### Problem # 5 #####"); for(int youngest = 0; youngest <= 100; youngest++) { if (youngest + (youngest +2) + (youngest + 4) + (youngest + 6) + (youngest+ 8) == 100) System.out.println("Youngest got " + youngest); } //Problem # 6 - ThreeSons System.out.println("\n\n##### Problem # 6 #####"); for(int son1 = 1; son1<=36; son1++) for(int son2 = 1; son2=2 && son1-son2 <=8 && son1-son3>=2 && son1-son3<=8 &&son2-son3>=2 && son2-son3<=8 && son1*son2*son3==36) System.out.println("Son 1 is " + son1 + " and son2 is " + son2 + " and son3 is " + son3); } //Problem # 7 - TeacherBoat System.out.println("\n\n##### Problem # 7 #####"); for(int t1 = 1; t1<=60;t1++) for(int t2 = 1; t2<=60;t2++) for(int t3 = 1; t3<=60;t3++) for(int t4 = 1; t4<=60;t4++) { if(t1==(t2+t3+t4)/2 && t2==(t1+t3+t4)/ 3 && t3 == (t1 +t2+t4)/4 && t1+t2+t3+t4==60) System.out.println("Teacher4 paid " + t4); } //Problem # 8 - AnimalPurchase System.out.println("\n\n##### Problem # 8 #####"); for(int cows = 1; cows<=100; cows++) for(int pigs = 1; pigs<=100; pigs++) for(int chickens = 1; chickens<=100; chickens++) { double amount = cows*10 + pigs*3+chickens *.5; if(amount==100 && cows+pigs+chickens ==100) System.out.println("cows = " + cows + " and pigs = " + pigs + " and chickens = " + chickens); } //Problem # 9 - IdenticalSix System.out.println("\n\n##### Problem # 9 #####"); int num =100000; int num2 = 2; boolean passesTest = false; while(passesTest == false) { num--; for( num2 = 2; num2<=9; num2++) { if((num * num2) % 111111 == 0 ) { passesTest = true; break; } } } System.out.println(num + " * " + num2 + " = " + num*num2 + " and is the largest 5 digit"); //Problem # 10 - DaycareCenter System.out.println("\n\n##### Problem # 10 #####"); for(int children = 1; children < 1000; children++) { int puppies = children - 20; int ants = children * 10; int legs = children*2 + puppies*4 + ants*6 + 2; if(legs==1440) { System.out.println("There are " + children +" children and " + puppies + " puppies and " + ants + " ants"); System.out.println("making " + children * 2 + " + " + puppies * 4 + " + " + ants * 6 + " = " + legs + " legs."); } } } }