public class ComplexShapes { public static void main(String[] args) { //dotsNums(); mystery(); } /* Mapping complex patterns to loop counters ....1 ...2 ..3 .4 5 line dots line * -1 line * -1 + 5 1 4 -1 4 2 3 -2 3 3 2 -3 4 1 5 0 */ public static void dotsNums() { for (int line = 1; line <= 5; line++) { for (int i = 1; i <= line * -1 + 5; i++) { System.out.print("."); } System.out.println(line); } } /* What is printed by the following code? */ public static void mystery() { for (int line = 1; line <= 5; line++) { for (int j = 1; j <= (-1 * line + 5); j++) { System.out.print("."); } for (int j = 1; j <= line; j++) { System.out.print(line); } System.out.println(); } } }