All language subtitles for 10. Print Pyramid Numbers Pattern - Solution

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

What is going on, guys?

And welcome back to the Solutions video, and here we are going to talk about a couple of interesting

things.

We are going to see how we can prevent the falling shape to the screen.

So basically, let's just make a quick summary of what we have to do.

We have to receive some value from the user, let's say, and equals to three.

And in this case, we should print the following triangle to the screen.

So we should be the first row with the value of one, then two and three and finally four, five and

six.

OK, so that's basically the shape we should print for the value and equals to three and these.

And it also should specify the number of.

So number of rows of our given triangle.

So that's, that's the triangle that we want to bring to the screen.

Okay.

One, two, three, four, five, six.

And the first question that we should be asking ourselves, OK, we know that to print a right angle

triangle is probably not a problem using just two loops.

We already solved it.

I think in the beginners exercisers, we know how to do it like this.

So one, two, three, four, five, six.

So we pretty much remember how these shape can be printed, but now the shape is a little bit different

and we want to print it like that.

So if we want to understand how it should be done, we should basically look at the shape, OK, and

start to try get some knowledge and try to get some insights out of these shape.

And the first things I should say that basically we know that An represents the number of rows.

So this will be our first insight.

The second insight should be like to understand that in these shape printing we have.

OK, so that's row number one.

That's room number two.

And finally, we have row number three.

And if we take a look at it, if we if we want to keep it in the same shape, we need, first of all,

to understand that in the last row, there is probably no need at all to add spaces before printing

the value itself.

But if we want to keep it this way on the second row, we will have just one space printed before and

on the first row will have two spaces, two spaces printed before.

So that's OK.

But what can we conclude for for ourselves?

Basically, if we take a look at and let's say equals two for let's say we have one, two, three,

four, five, six, seven, eight, nine and 10.

OK, so in this case, we can see that in the last row there is no need to add spaces before here.

We have to add just one space here.

We will have to add two spaces and here three spaces.

Right.

So if we want to like to conclude some conclusion or insight out of that, we can say that in the last

row there is no need at all.

But in the first row, we should add the spaces before pruning the value.

How many spaces we are adding here?

The number of rows, which is four minus one.

OK, so let's see if it's also applies here.

So here we have the number of roses three and then we print just three minus one rose.

OK, so three minus the row itself.

That's what we print in here.

And later on we print every time we just decrement the number of spaces we print before the first value.

OK, so this will be rule number two, OK, how to print the spaces before OK, print spaces.

So basically we also should consider how we print just not the same value like we've done it with using

these stars.

Right.

We know how to print that.

We should also take into account the printing of the value in incrementing it by one.

OK, so that will be the third option.

Like to increment increment station, let's call it this way.

OK.

So there will be instrumentation.

Awesome.

So for that, let's start solving this exercise and let's think about what should be the solution here.

And instead of writing everything from scratch, I will simply use this technique to show you guys how

it can be done and also talk about every one, every one of these lines.

So, OK, so let's start with the declaration phase.

We know that we have to create the variable m, OK?

Also, we know that probably we are going to use a couple of loops here, so I will create in advance

three variables I, J and K and I will explain you in a moment about each of these variables and where

it's going to be implemented in our code and in the loops that we are going to use.

So basically that we understand and also the blank spaces I will talk about in a moment, basically.

Let's just explain them right away.

So the blank spaces and that's actually the spaces that we want to the number of spaces that we want

to print before printing the value at each and every row.

OK, so we know that if we receive n OK, so that was that's what we do here.

We receive the value of and which specifies the number of throws in these final pyramid.

So we read this value and store it inside and that's we understand and the blank spaces for the first

time we are going to print will be equal to the number of rows minus one.

OK, we talked about it.

So if we have three rows and we are going to set the blank spaces, which is the number of blank spaces

printed before this value will be three minus one, which will be a total of two.

OK, and then we will simply update this value.

I will show you show you how it can be done for every row.

Just a couple of moments.

OK, guys.

So for now, let's simply set this value to be equal to rows minus one for our first row, where we

have to know the number of spaces printed for the screen.

Awesome.

So that's no.

And the current value, what will be these current value here?

The current value is just the value that we have to print at this moment.

So it start we have to print one, then we have to print two, then we have to bring three and so on.

We are not printing just some common character at each of the lines.

We we have to keep some value, the current value that should be printed in each command.

OK, so if we know that we printed the value of one, that the current value was initialized to one,

then if we printed one, then we should increment this value by one because we know that we want to

like to print.

The next value is to and then to print.

The next value is three and so on and so forth.

Awesome.

So now that it's clear, let's go for our first loop.

OK.

So for I equals to one as long as I is less than or equal to m i plus plus.

So that basically says let's go.

OK.

And that says let's go over all the rows starting from row one and up to the final row.

So read E to read over all of the rows.

OK, awesome.

And while iterating over all of the rows, ok, let's say that this will be the section that we executed.

We know that I equals to one right.

I equals to one.

And we will say that four K equals two blank spaces.

OK, the number of blank spaces that should be printed as long as K is greater or equal to one K minus

minus and simply print a blank space.

OK, so for equals to zero we know that blank spaces equals to two.

Right.

It's, it will be.

For example, if we got in equals to three then it will be two.

So we will print spaces like the first space, the second space and that's it.

OK, so K equals two two.

And as long as K is greater or equal to one, we will print it so close to two, then close to one.

And then when key goes to zero, we are out of it.

So basically we printed two blank spaces to the screen and once we are done printing that, let's simply

understand what we are doing in the following line.

So what's going on here?

Um, let's first of all, just fix that.

I think that, well, everything is removed.

No, everything is OK.

So, yeah, let's just fix that.

So there you go.

So it will be like G plus and that's it.

OK.

So there was some mistake probably.

And yeah.

OK, now we are set.

So let's come back to our drawing process and also let's now talk about this one.

OK, this loop.

So all of that.

Both of these loops happen inside of the outer loop, so we printed all the bases, so this loop is

actually two ways.

It's so big.

Wait a sec and wait a second.

Wait a second.

Wait a second, guys.

I'm sorry for that.

So is this OK?

Yeah.

Awesome.

So.

Basically, we said that this loop is simply in charge, in charge of what?

In charge of printing the blank spaces before.

So printing blank spaces.

Right, blank spaces.

So that's the task of these for loop printing of a blank spaces before printing the values of each of

these given row.

And later on, we are in these for a loop and these for a loop simply prints the current value.

So the current value is now one and we simply print the value of one to the screen.

And we do that as long as J is less than or equal to I.

So we are doing that.

We know that equals to one.

Then we know that only one value should be printed to the screen.

And if I equals to two, then in this case we should print two values to the screen and so on and so

forth.

OK, and at the end of every duration we increment the current value by one because we know that we

want to like to keep it up and to print every every, every time another value.

Awesome.

So now let's also see how it can be done in the second loop where I equals to two in the second iteration.

So we print just one space, OK, we print just one space and then we print two values.

So it will be two space and three.

OK, just like that.

And finally it equals to three.

We will not print any spaces at all.

It will be just something like this.

So it will be four.

Space five, space six.

OK, so that's basically how it looks like every time at the end of the outer iteration we simply use

these print off-line, OK, to print a new line and blank spaces minus minus, just to say that in the

next iteration you have to print one blank space last before printing the values themselves.

OK, so awesome.

I think that we cover it up everything.

So these for a loop basically let's say even like that.

So this should be here.

It should be here.

That should be here.

So we said that once again the blank spaces is OK, the return of zero is OK.

Oh it's just like OK, awesome.

So yeah, I think this is it for this video.

Let's just build and run in to see that everything works correctly.

And as we expected, let's go to three.

So one, two, three, four, five, six.

And also let's go with four, for example, one, two, three, four, five, six, seven, eight,

nine, 10 Hossam guys.

So that's the solution for these video.

If you still have any questions, feel free to ask them.

And basically, just to summarize, all that we've done here is simply splitting up the full solution

to parts of the solution, like using the for loops and using the inner for loops and the other for

loops and explaining exactly what each of these parts mean and what it will be used for.

And yeah.

So let me know if you like this video.

Please leave some review and some feedback and of course, keep on practicing and we will meet up in

the next exercise.

So until then, have a great day.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.