Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,810 --> 00:00:08,730
OK, so in the previous video, we talked about a function that receives a number, OK, which represents
2
00:00:08,790 --> 00:00:16,340
the length of a sequence and then the function should calculate OK and return a sequence of nine.
3
00:00:16,450 --> 00:00:25,290
OK, some new number, which will be compromised only of nines in a given length of that will represent
4
00:00:25,290 --> 00:00:26,070
the sequence.
5
00:00:27,150 --> 00:00:30,030
So, for example, we had like something like this.
6
00:00:30,030 --> 00:00:31,800
So length equals to three.
7
00:00:31,830 --> 00:00:36,090
If the function receives a number three, then it returns nine nine nine.
8
00:00:36,540 --> 00:00:43,020
If it receives length equals to five, then it returns five times nine and so on and so forth.
9
00:00:43,380 --> 00:00:50,010
We also discussed some of the things that should be taken into account, like using a long type and
10
00:00:50,010 --> 00:00:51,150
so on and so forth.
11
00:00:52,050 --> 00:00:58,520
But regarding the logic, it really doesn't matter how we calculate the number itself.
12
00:00:59,070 --> 00:01:07,050
And basically we've seen that the result is just to take and use some for a loop started from equals
13
00:01:07,050 --> 00:01:14,370
to zero up until Islands' the length and then on every duration to take the previous number multiplied
14
00:01:14,370 --> 00:01:16,470
by 10 and add a nine to it.
15
00:01:16,500 --> 00:01:22,560
OK, so we've seen all of these examples in all of these explanations and know what I want us to do
16
00:01:22,560 --> 00:01:30,000
is simply a little bit to take this exercise into kind of upgraded and do modified and to give you some
17
00:01:30,000 --> 00:01:37,290
time to think about some additional variation of this solution, of the logic being that is going on
18
00:01:37,290 --> 00:01:45,240
behind the scenes in this exercise so that it will get you all again to your next level.
19
00:01:45,270 --> 00:01:46,330
So let's start.
20
00:01:47,430 --> 00:01:52,720
And first of all, we have to do is just to modify the excess, this exercise.
21
00:01:53,070 --> 00:01:58,160
So once again, the function is going to receive some number, which is length, OK?
22
00:01:58,710 --> 00:02:03,550
And basically this length should be of two to two options.
23
00:02:03,570 --> 00:02:03,910
OK.
24
00:02:03,930 --> 00:02:11,020
The first option is basically if length is less than or equal to nine.
25
00:02:11,160 --> 00:02:18,720
OK, then in this case of the number that should be calculated and returned should look like this.
26
00:02:18,720 --> 00:02:21,270
One, two, three, four, five, six.
27
00:02:21,540 --> 00:02:23,490
Up until a given length.
28
00:02:23,500 --> 00:02:26,570
OK, up until length length.
29
00:02:26,790 --> 00:02:30,280
OK, so that's the new number that should be returned.
30
00:02:30,300 --> 00:02:35,070
So that's option number one and else.
31
00:02:35,370 --> 00:02:35,910
All right.
32
00:02:36,030 --> 00:02:46,890
Else if length is, if length is greater than ten, which means it can be two digits or more, then
33
00:02:46,890 --> 00:02:50,180
what should be returned is once again the nines.
34
00:02:50,220 --> 00:02:51,660
OK, nines.
35
00:02:51,810 --> 00:02:54,870
How many times until you reach this length.
36
00:02:54,870 --> 00:02:56,220
OK, length times.
37
00:02:57,180 --> 00:03:01,560
So for example, let's make some example.
38
00:03:01,560 --> 00:03:07,710
If we get the length of three then the number that should be returned is just one, two or three, which
39
00:03:07,710 --> 00:03:09,390
is one hundred and twenty three.
40
00:03:09,720 --> 00:03:13,670
If length is five, then the number that should be recurring is like this.
41
00:03:14,100 --> 00:03:22,290
But if we receive the length that looks like this, I don't know, like 12, then in this case the number
42
00:03:22,290 --> 00:03:25,110
of returns should be like 12 times nine.
43
00:03:25,140 --> 00:03:31,550
So how is it one, two, three, four, five, six, seven, eight, nine and 10, 11, 12?
44
00:03:32,550 --> 00:03:39,190
OK, so that's basically the whole process and the whole idea behind what this exercise should do.
45
00:03:39,210 --> 00:03:44,730
OK, so bear this in mind and basically take a few minutes.
46
00:03:44,730 --> 00:03:48,930
I think 10, 15 minutes is also a good time for your practice.
47
00:03:49,200 --> 00:03:55,410
And once you are done, let's proceed and do this exercise and the solution together.
48
00:03:56,490 --> 00:03:57,100
Awesome.
49
00:03:57,150 --> 00:04:08,310
So first of all, let us a little bit a little bit just modify our exercise and let's just for the sake
50
00:04:08,310 --> 00:04:15,250
of simplicity, continue with the previous option that we had using the long type.
51
00:04:15,450 --> 00:04:16,560
OK, so long.
52
00:04:17,400 --> 00:04:21,480
And let's call this function OK, let's call this function.
53
00:04:22,350 --> 00:04:29,110
How should we call it, let's say two one two one two nine one to nine.
54
00:04:29,550 --> 00:04:31,710
And this function is going to receive a number.
55
00:04:33,270 --> 00:04:35,720
And this number is going to be, again, length.
56
00:04:36,430 --> 00:04:42,480
OK, and now in these function, we know that the body of the function, first of all, we need to understand
57
00:04:42,480 --> 00:04:44,280
how we even print all these numbers.
58
00:04:44,310 --> 00:04:45,940
One, two, three, one, two, three, four, five.
59
00:04:46,410 --> 00:04:50,130
Basically, the idea is pretty much the same.
60
00:04:50,280 --> 00:04:54,900
OK, we will start with, let's say, Nomikos to zero.
61
00:04:54,900 --> 00:05:00,840
And then we know that, for example, length is equals to three.
62
00:05:01,380 --> 00:05:06,510
Then in this case, we know that number will be multiplied by ten plus one.
63
00:05:06,750 --> 00:05:14,250
In this case, it will give us one number equals to the previous number, which is one plus multiplied
64
00:05:14,250 --> 00:05:17,430
by ten, which is ten plus two.
65
00:05:17,640 --> 00:05:19,440
And in this case, it will be twelve.
66
00:05:20,370 --> 00:05:23,640
And then we go again and we just add three.
67
00:05:23,640 --> 00:05:25,650
And this will give us what you did.
68
00:05:25,650 --> 00:05:31,860
Give us one hundred and twenty last three, which is one hundred and twenty three.
69
00:05:32,370 --> 00:05:40,410
OK, so the logic is pretty much the same, just that in these examples where we use like adding a nine
70
00:05:40,410 --> 00:05:47,340
every time, basically if we want to make a number, a sequence of of digits just with nines, we simply
71
00:05:47,340 --> 00:05:50,310
add a nine and multiply the previous number 10.
72
00:05:50,640 --> 00:05:57,840
And in this case, we also multiply number by ten, but we just add some different number like one,
73
00:05:57,840 --> 00:05:59,850
two, three and so on and so forth.
74
00:06:00,000 --> 00:06:08,040
OK, so I hope the logic behind it is now clear to let me know if you've successfully found out this
75
00:06:08,040 --> 00:06:14,580
information by yourself and you came to this conclusion by yourself, if not a guy, that's not a problem.
76
00:06:14,580 --> 00:06:22,500
But you need to kind of to think a little bit more and to devote more more time to coming up to at least
77
00:06:22,770 --> 00:06:27,480
one or two options and then see if they really suit your solution.
78
00:06:28,800 --> 00:06:29,320
Awesome.
79
00:06:29,340 --> 00:06:30,570
So now let's proceed.
80
00:06:30,720 --> 00:06:39,510
And now we know that long are one to end should basically give us all this information.
81
00:06:39,510 --> 00:06:42,470
So the logic is going to be pretty much the same.
82
00:06:42,480 --> 00:06:46,830
So let's create time and then creating now equals to zero.
83
00:06:47,520 --> 00:06:54,540
And yeah, basically it's not going to be and it's going to be long because we are using a long time
84
00:06:54,540 --> 00:06:58,860
to store longer values, so long term equals to zero.
85
00:06:59,610 --> 00:07:07,950
And now we are going to run for equal to zero as long as it less the length I plus plus the only thing
86
00:07:07,950 --> 00:07:17,580
that we need to to check is some condition that was part of our exercise, which said if length is less
87
00:07:17,580 --> 00:07:25,230
than or equal to nine, then in this case this is the sequence we will return, OK, otherwise we will
88
00:07:25,230 --> 00:07:27,160
return the sequence of nines.
89
00:07:27,300 --> 00:07:28,560
So if.
90
00:07:31,240 --> 00:07:35,960
If length is less than or equal to nine.
91
00:07:36,160 --> 00:07:36,590
OK.
92
00:07:36,610 --> 00:07:43,780
And of course, it should be greater than zero that some base condition that I'm not going even to add
93
00:07:43,780 --> 00:07:50,050
here, because I think you you already know that OK, should be something like this.
94
00:07:50,380 --> 00:07:54,850
If length is less than zero, then preened or starved and so on.
95
00:07:55,230 --> 00:08:03,820
OK, so if length is less than or equal to nine, then in this case what we will do is just to execute
96
00:08:03,820 --> 00:08:04,930
these for a loop.
97
00:08:05,170 --> 00:08:07,830
OK, so let's just do it like this.
98
00:08:07,840 --> 00:08:11,650
So for a loop, if that's the case, we are going to execute this for a loop.
99
00:08:11,890 --> 00:08:18,310
And inside of these for loop, we are going simply to use a very similar technique to what it was used
100
00:08:18,310 --> 00:08:21,150
previously multiplied by ten plus.
101
00:08:21,160 --> 00:08:25,720
And the question now that remains is plus what should be used here?
102
00:08:25,840 --> 00:08:27,310
Should it be plus nine?
103
00:08:27,310 --> 00:08:30,010
Should it be plus one, plus two, plus three and so on?
104
00:08:30,460 --> 00:08:31,570
So what do you think?
105
00:08:31,600 --> 00:08:34,530
Take a moment, think about it and let me know.
106
00:08:34,540 --> 00:08:35,650
Here is the example.
107
00:08:35,890 --> 00:08:39,370
Look at the example and think what should we add here?
108
00:08:41,410 --> 00:08:45,670
So now that you're back, basically think about that.
109
00:08:45,670 --> 00:08:52,150
If you would have just used a like now multiplied by ten plus one, then the sequence should will be
110
00:08:52,150 --> 00:09:00,670
in this case only if all the numbers from a sequence of ones, if you were to have used here two, it
111
00:09:00,670 --> 00:09:04,590
will be a sequence of twos of threes and so on and so forth.
112
00:09:05,470 --> 00:09:11,860
But you want something that is changing that on the first iteration, it's one on the second iteration
113
00:09:11,860 --> 00:09:14,860
is two and the third is three and so on.
114
00:09:15,370 --> 00:09:17,410
So that's why you will use here.
115
00:09:17,410 --> 00:09:23,660
A variable that changes on every duration in this variable is none other than I.
116
00:09:23,980 --> 00:09:27,430
So in this case, you will take these I and you will specify here.
117
00:09:27,790 --> 00:09:32,340
But you know that on the first iteration, you don't want to take the value of zero.
118
00:09:32,350 --> 00:09:34,390
You want to take the value of one.
119
00:09:35,350 --> 00:09:38,410
Then in this case, it will look something like this.
120
00:09:38,710 --> 00:09:39,910
I plus one.
121
00:09:41,280 --> 00:09:47,340
So is that clear why we're using that, because on the first iteration, it will be like not multiplied
122
00:09:47,340 --> 00:09:51,810
by ten plus one, on the second iteration, it will be equal, equal to one.
123
00:09:51,810 --> 00:09:55,290
So it will be multiplied by ten plus two and so on and so forth.
124
00:09:55,500 --> 00:10:02,190
And then you will come up to this kind of solution on the example that we've just shown here.
125
00:10:02,290 --> 00:10:02,770
OK.
126
00:10:04,380 --> 00:10:11,430
OK, so they've conditioned if it if it is true, if length is less than or equal to nine, then we
127
00:10:11,430 --> 00:10:20,520
calculate now in this way and otherwise else what we should do about the ls basically about the else.
128
00:10:20,520 --> 00:10:23,640
We should simply copy all of this solution.
129
00:10:23,640 --> 00:10:23,960
Right.
130
00:10:23,970 --> 00:10:25,590
All of this part.
131
00:10:25,590 --> 00:10:33,330
We can also copy and run these for a loop here, or basically we can update these nine number a little
132
00:10:33,330 --> 00:10:35,400
bit to using also the long type.
133
00:10:36,120 --> 00:10:37,530
So it will look like this.
134
00:10:39,000 --> 00:10:42,980
And now what we will do is just to use this function.
135
00:10:43,140 --> 00:10:49,770
Then we will say now equals two nine number for the given length.
136
00:10:50,020 --> 00:10:54,510
OK, and that's basically it for this exercise.
137
00:10:54,510 --> 00:11:03,240
We are going to call this function that we've written on another exercise on another day of your work,
138
00:11:03,240 --> 00:11:10,590
let's say, and you're using a totally different function to create one function which is updated and
139
00:11:10,590 --> 00:11:11,760
different a little bit.
140
00:11:12,210 --> 00:11:18,720
So that I think that this is a very important point that you should bear in mind.
141
00:11:18,720 --> 00:11:23,790
Like, you create one function and then you use it for another function and then you proceed to create
142
00:11:23,790 --> 00:11:30,390
like your program in your system that utilizes a bunch of functions that some of them were developed
143
00:11:30,390 --> 00:11:31,890
by you, some of them not.
144
00:11:32,370 --> 00:11:34,160
OK, so I hope that's clear to you.
145
00:11:34,950 --> 00:11:39,400
And the last thing that remains is simply to return now.
146
00:11:39,990 --> 00:11:46,660
OK, so now would have been calculated either here or here by calling the other function.
147
00:11:47,820 --> 00:11:55,410
So now we can go you can run an example using the void main function, the main function to use some
148
00:11:55,410 --> 00:11:55,950
number.
149
00:11:56,310 --> 00:12:04,170
And yeah, basically this is just make sure that you do not use an integer here as a result because
150
00:12:04,170 --> 00:12:09,390
you're using Cura long and you have to print it a little bit differently.
151
00:12:10,660 --> 00:12:18,220
Percentage, these should be pretty much, I think, what you need right percentage the instead of just
152
00:12:18,220 --> 00:12:21,720
the percentage LD like long integer.
153
00:12:22,840 --> 00:12:24,280
So thank you guys for watching.
154
00:12:24,490 --> 00:12:30,090
My name is one, this is Alphatech and I will see you in the next videos.
155
00:12:30,370 --> 00:12:32,320
Until then, have a great time.
15579
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.