public class Pyramid{
	public static void main(String[] args){
		Turtle hank = new Turtle();

		hank.delay(5);
		pyramid(hank, 200, 5);

		hank.penup();
		hank.forward(400);
		hank.pendown();
		pyramid(hank, 200, 10);

		hank.penup();
		hank.forward(400);
		hank.pendown();
		pyramid(hank, 300, 10);
	}

	// levels 5=9square
	// levels 10=19square
	// the amount of squares at first layer should be 2*levels-1
	// -1, -2, -4, -6, -8
	public static void pyramid(Turtle t, double base, int levels){
		// base/(2*levels-1) = length of each square
		// 2*levels-1 = amount of squares in the first layer
		double lengthOfSquare = base/(2*levels-1);

		for(int l=0; l<levels; l++){
			// l*2= the amount each leayer is reducing, set l=1 and limit+1
			// looping for the squares of each level
			for(int i=0; i<2*levels-1-l*2; i++){

				// looping for each square
				for(int s=0; s<4; s++){
					t.forward(lengthOfSquare);
					t.left(90);
				}
				t.forward(lengthOfSquare); // move to next square
			}
			t.backward((2*levels-1-l*2)*lengthOfSquare); // turtle back to the origin of that layer, amount of square * length of square
			t.left(90);
			t.forward(lengthOfSquare);
			t.right(90);
			t.forward(lengthOfSquare);
			// turtle at the beginning of the next layer
		}
		// bring back turtle
		t.left(90);
		t.backward(levels*lengthOfSquare); // turtle back to bottom layer
		t.right(90);
		t.backward(levels*lengthOfSquare); // levels = amount of squares to the origin
	}
}
@@ -301,137 +301,8 @@
 %09%7D%0A%0A
-%09// levels 5=9square%0A%09// levels 10=19square%0A%09// the amount of squares at first layer should be 2*levels-1%0A%09// -1, -2, -4, -6, -8%0A
 %09pub
@@ -361,16 +361,16 @@
 evels)%7B%0A
+
 %09%09// bas
@@ -544,75 +544,8 @@
 +)%7B%0A
-%09%09%09// l*2= the amount each leayer is reducing, set l=1 and limit+1%0A
 %09%09%09/
@@ -624,16 +624,239 @@
 ; i++)%7B%0A
+%09%09%09// levels 5 = 9square%0A%09%09%09// levels 10 = 19square%0A%09%09%09// Each level of squares are 2*levels -1, -3, -5, -7 and -9%0A%09%09%09// Using the trait that after first level, -2, we know that the squares in each levels are 2*levels-1-l*2
 %0A%09%09%09%09// 

add comment in pyramid