What difficulty is there to understand in: Each number in the triangle is the two numbers above it added together (except for the edges, which are all "1").
I assume you can add to numbers, don't you?
If you still find that difficult please tell us.

You need to work out how you would explain doing it to someone who had no idea what you were talking about. For example:

You're going to output lines of numbers
The first line will be just the number 1.
The second line will have two numbers in it.
The third line will have three numbers in it.
The fourth line will have four numbers in it.
And so on.

On each line apart from the first line, the FIRST number you write out will be the same as the FIRST number on the previous line.
On each line apart from the first line, the LAST number you write out will be the same as the LAST number on the previous line.
On each line apart from the first line, all other number will be the sum of the previous line's corresponding number and the number before that (i.e. for any line, the second number will be the sum of the previous line's first and second number; for any line, the third number will be the sum of the previous line's second and third number, and so on).

This is programming. Thinking about the problem in a way that the solution lends itself to a programmatic solution. Examining the problem and breaking it down into simple, small steps. This is programming. All the rest is learning tools and syntax.

I want to implement undo logic which deletes the last drawn shape. To test this logic i had cleared shapes list and redrawn all shapes but still last ...