Hello, guys, and welcome back to the calls.
In the last class, we learned about solar gold and we solved two problems by writing sort of code.
So in this class, really resolving two more problems to get a better understanding of sort of code.
So let's get started.
So problem number three.
Problem three.
So the problem with treatment is.
Read an.
And Brent falling Britain.
So vote.
And it goes t my baton is when.
When two, three.
One, two, three, four, five and four and equals five.
My then will be one.
Two, three, one, two, three, four, five.
One, two, three, four, five, six, seven, one, two, three, four, five, six, seven, eight,
nine.
OK, so how we can solve this problem?
So the problem statement is we have to read and and we have to print falling pattern.
So for any cost three, if you look carefully, I am printing Titos.
And similarly, foot end equals five.
I am printing Faithful's.
So one thing is very clear here that I need a loop and this loop will run and times.
Because we have to print Ando's if the value of amnesty this loop Willdan three times, if the value
of this five, this loop will run five times.
So how will this leupen and times?
So I equals when I listed not equals to N and I equals a plus one.
So with the help of these three, my loop Vildan and Bems.
So each time this loop is running, what will I do?
I will bring Daryl.
So how can I bring Daryl?
OK, so first of all, let's look at the pattern again.
First I am having spaces and then I am having numbers.
So these are the spaces.
So footprinting at all.
First I will print spaces and then I will print values.
Similarly, I am having spaces here.
OK, so for branding at all.
First I will print spaces and then I will print values.
OK, so how many spaces and how many values do I have to print?
Hear the value of AI is one here, the value of FI is two.
I used three.
AI is for AI is five.
So our logic is footprinting at all.
First, I will print space's.
Then I will print numbers.
OK, so how many spaces do I have to print?
If we look carefully, if the value of AI is when I am printing for spaces, if the value of AI is too.
I am printing two spaces and so on.
So basically I am printing and minus I use pieces.
OK, let's see the well, your friend is five.
And later, the radio fi is one.
So how many species I will print?
I will print four species.
You can see here.
The value of an S5 and the value of AI is one.
So I'm printing four spaces similarly led to the world of history.
And it's the value of FI is to.
How many spaces I will print.
I will print only one space.
And you can see you.
Here, the relief of is.
And and it's two, so I'm bringing just one space.
OK.
And how many numbers do I have to print?
So I have to think the way minus when numbers.
Starting from when?
Starting from when, for example, led to the value of I is three.
So how many numbers I will print?
I will print way minus one numbers.
That is.
Doing two, three, minus one.
That is five numbers.
You can see here, here the value of PI is three.
How many numbers I'm bringing?
I am bringing five numbers starting from one.
Similarly here, they really if I.
I am branding five numbers starting from three.
Let us take one more example.
Suppose the value of Pi is two.
So how many numbers I will print.
I will print the way minus one.
Numbers.
So two and two to minus one.
Now, this TNM was the if I used to.
I am printing clean and was starting from one assembly here.
The value of I used to I am printing clean and I was starting from one.
So our final logic is for printing at all.
What do I do?
First of all, I will print spaces.
How many spaces and minus I use spaces.
And for printing numbers, how many numbers I will print?
I will print way minus four numbers the way minus one.
Numbers.
Starting from when and then we have been and died.
What will I do?
I will go do next to do so.
Finally, I will print, backslash.
And so this statement will be used to go to next plane or next room.
Okay.
So.
So I have to print the spaces and minus eight times.
So how we can do that.
So what will I do.
I will take a variable space, which is initially when.
Space less than or close to end minus I.
And space equals space plus one.
So with the help of DST, my loop will run and minus eight times.
And each time this loop reasoning, what will I do?
I will bend space.
Bend space.
OK.
So how many numbers do I have to print?
So I have to print the way minus one numbers.
So I need a loop and this loop will run the way minus one Bane's.
So how are we letting this loop to where minus one dime, what will I do?
I will use a variable count.
Count quiz one.
Count less than or equal, Stateway, minus one count equals count plus one.
So with the help of these three.
My local children do I am minus one them, and each time this loop is ending, I will print a number.
And after printing that number, I will increase the number by one to number equals number plus one
print number.
So first, Brent, no.
Then increase the value of no by when.
OK.
And finally, when we have printed one our entire crew.
What will I do?
I will print backslash under this and go to next line.
OK, so Reid and.
And now I have to print Ando's, so I need a loop with children and times, so I equals one.
While I is less than articles to n do, what do I do?
I will print Adderall.
I equals I bless one.
And here I am having it done statement.
OK.
So this love will run and times.
And each time I will bend at all.
So footprinting at all.
We have decided that, first of all, Brent Space's.
So how many spaces I have to print?
I have to print and minus eight spaces and I will use a loop.
OK, so space's.
Equals one while.
Space's.
Is less than or equal to.
And minus a.
Wild species list anglers, twain minus I do.
What do I do?
I will print.
Space's.
Spaces, enclosed spaces, plus one, two spaces equals.
Spaces plus one.
OK, so this loop will run and minus eight times, and each time I will bend a space.
Now, the next thing is we have to print numbers the way minus four numbers.
So I will use a variable count.
And with the help of this variable, my loop will run the way times and each time I will print a number
and the available number will be incremented way.
OK.
So I have to bring numbers starting from one.
So initially.
My number is one and count equals one.
So I have to run this loop where minus one times.
So while.
Count is less than or equal to the way minus one.
Dawn.
And here I am having.
Count equals count of less than.
So what is the work that I have to do inside the loop?
So the work is very simple, bringing the number and increment the number by one.
So I will print.
No, and increase the live number by one.
So numb it goes numb.
Plus, when and when we have Brender, that battle, what will I do?
I will print Beck's legend to go to next line.
So print.
Backslash and because I have to go to next lane.
OK, so this is our computer pseudocode.
So let's take an example to understand how this is working.
OK, so let's see the value of and is to.
So what should be our output?
Our output should be one, two, three.
So this should be our output for an English to let's see, I was also called will generate the same
output or not.
So did and I equals one.
So I equals one.
So is one less than articles to do so, the condition is true.
You will come inside this loop.
OK, so spaces equals one, spaces equals one.
OK, while Spaces is less than I was two and minus I.
So what is the value of N minus eight and minus a net.
That is two minus one.
Notice when so is when less than Agosta went into the condition is true.
You will come inside the loop.
Spaces.
OK.
So I am writing my output here.
So print spaces and gives the radio space by one for the new radio spaces is to.
OK, then check the condition again is to list the Noriko's to one to the condition is false.
I will come out of this loop, so I will reach here.
No question.
OK, so Nam equals one.
County Kossmann.
OK.
Count equals one.
So while count is less done, it goes to play minus one.
OK, so first of all, the way minus one equals two into one, minus one net is.
So vital role is less than it was to end to.
The condition is true.
You welcome Inside the Loop.
Bring the number.
So I will print when I'm writing my output here.
So print one and give the real number one to the new Aliev number is to increase the value of Quine
by one to a new Aliev counties to.
Then check the condition again.
Is to list in order for us to win.
No.
The condition is false.
You will each year that is go to next line.
So I will go to next line and give the really if I buy one.
So then you really.
If I is to.
And then you will check the condition again.
So is to less than Noriko's to do so, the condition is true.
You will again come inside this loop.
Spaces equals one.
So, again, spaces equals one.
So whilst prison is less than was two and minus I.
So it is a relief and minus I know it is two minus two, which is zero.
So is the van less than or equal to zero, so the condition is false.
You will each year.
Equals one, okay?
Nam equals when counting goes on.
OK.
So count equals one.
Vial count is less than or equal, Shipway minus one.
So what is a really off to a minus one, two into two, minus one?
That is three.
OK.
So while one is less than oil goes to three for the condition is true.
You're welcome.
Inside the loop.
Brendan.
No.
So I will print one.
It gives the real number by one to the new really off number is to give them a laugh.
Can't buy one.
So value of counties do.
Then you will check the condition again is to list in articles two three.
Yes.
The condition is to come inside the loop.
Print the number.
Okay.
Print to give the rate of number by one to the new Aliev number is three.
And gives them relief card to buy went to a new Aliev Counties three.
Then check the condition again is to list then articles to three.
So the condition is again to come inside the loop, print the number.
OK, so I will print three and give them a dozen number by once when you really number is four.
And give their love, can't buy one, so anyway, live counties for.
Check the condition again is for less than oil, close to three.
So is for less than Noriko's to three?
No.
The condition is false.
You will reach here.
So go to the next line.
Okay.
I will reach you.
It gives them a little Firebag one, so a new vilify is three.
Check the condition again.
Still less than our course to do.
No.
Three is not a less than Noriko's to do so I will come out of this loop and I will reach here.
So written Redan means endure program.
So my output.
This and this.
Which is hundred percent correct for then and equals to.
OK, so let's revise what we have done.
So the Grono statement was, I have to read and and we have to print the falling pattern so far and
equals three.
I am printing three euros four and equals five.
I am printing five euros.
So one thing is very clear here that I need a loop and this loop will run and times.
And here's my loop, I equals when I left and I was doing and I was a plus one.
So with the help of these three.
This loop, Willdan and Times.
So the outer loop is running and times.
And then we have to print each rule that I told you for printing each rule first I have to print spaces
and then I have to print values.
So how many spaces do have to print?
So I have to print and minus eyes pieces.
OK.
And you can see an example for I equals two.
I am printing three spaces because and minus I is three.
That is five.
Minus two is three.
So I need a loop that will print spaces and is my loop, so this loop will print spaces.
How many spaces?
And minus eight spaces for this loop children and minus eight times.
So spaces equals one spaces less than I was trained minus I.
Which is my condition.
And spaces equals spaces plus one.
So this is initialise.
This is my condition.
And this is update.
Similarly, this was initialise, this was condition and this was a bleed, and then we have to print
numbers starting from one to starting from when I am printing numbers and a very low number is incremented
by one.
And how many numbers do I have to print?
So I have to print Douai minus one numbers.
So I need a loop there to learn the way minus one times.
So count to close one.
Garnered less than a ghostwrote away minus one and a count equals current plus one.
So with the help of these three, my loop will then do way minus one times and each time I am printing
a number.
And when we have been dead, when Ann died, do I have to go to next to.
So Brent Beck's lesson will help us to go to next.
And this is our computer record.
Okay, so how many loops we are using in discussion?
So we are using total three loops.
One outer loop.
And two loops inside this loop.
Loop one for printing space's loop two for printing numbers.
Banned vaccination.
And then.
OK, so in total, I'm using three loops.
One is outer loop and two loops inside out and loop.
OK, so let us all one more interesting problem.