All language subtitles for 20. Advanced - Odd Even Positions and Values Finder - Solution

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,020 --> 00:00:02,280 Oh, right. 2 00:00:02,400 --> 00:00:11,160 So I think this process was not an easy one for you, but still, if you're here, I want to thank you 3 00:00:11,160 --> 00:00:17,100 and I want to say that you are doing great because even coming to the solutions video is not an easy 4 00:00:17,100 --> 00:00:18,360 task after these. 5 00:00:18,360 --> 00:00:20,250 Not so easy exercise. 6 00:00:21,420 --> 00:00:23,820 So let us get started. 7 00:00:23,850 --> 00:00:24,340 All right. 8 00:00:25,170 --> 00:00:33,720 And what I want us to do, first of all, is basically to try to think even how would you approach this 9 00:00:33,720 --> 00:00:34,520 exercise? 10 00:00:34,830 --> 00:00:38,310 So let's say that we have here, let me get my pen. 11 00:00:38,340 --> 00:00:41,670 OK, so let us take a look at this example. 12 00:00:41,670 --> 00:00:43,020 Four, three, eight. 13 00:00:43,080 --> 00:00:51,570 OK, so since we know that we are going to use a recursion function that probably probably there is 14 00:00:51,570 --> 00:00:54,240 going to be some recursive calls. 15 00:00:54,240 --> 00:00:54,570 Right. 16 00:00:54,570 --> 00:00:57,530 For or recursive instances. 17 00:00:58,200 --> 00:01:04,830 So let's say there is an instance for an equals two, four, three, eight and then an equals two, 18 00:01:04,830 --> 00:01:07,710 four, three and then an equals to four. 19 00:01:07,980 --> 00:01:09,120 Basically, that's it. 20 00:01:09,310 --> 00:01:16,980 OK, I'm just I'm just trying to like to go over the steps and over your. 21 00:01:17,900 --> 00:01:25,760 Possibly thoughts that you had during the solution, so are and equals two, four, three, eight and 22 00:01:25,760 --> 00:01:28,310 equals two for a three and and equals to four. 23 00:01:28,940 --> 00:01:39,410 So we can say that whenever we reach some point when and he's less than 10, OK, which means it's going 24 00:01:39,410 --> 00:01:50,840 to be it's going to be one digit number, then in this case, we have to like to think what should be 25 00:01:50,840 --> 00:01:51,680 returned. 26 00:01:53,000 --> 00:01:54,400 So that's very interesting. 27 00:01:54,410 --> 00:01:57,020 Guys, what do you think should be returned here? 28 00:01:57,380 --> 00:02:00,050 Should it be if if that's the case? 29 00:02:00,060 --> 00:02:07,130 Because because I think that a lot of you guys thought of this way of and what will happen if and is 30 00:02:07,130 --> 00:02:12,860 less than 10, which is something that you would have used for a base case, what do you think should 31 00:02:12,860 --> 00:02:14,450 be returned in such a case? 32 00:02:14,990 --> 00:02:24,290 Should be returned just the value of one, OK, or the value of zero, basically saying we said previously 33 00:02:24,590 --> 00:02:32,420 that we will return one if every digit and that an even possession has an even value as well as every 34 00:02:32,420 --> 00:02:36,920 digit in the opposition will have an odd value. 35 00:02:37,640 --> 00:02:43,570 But here we have like just one one value of one digit. 36 00:02:44,150 --> 00:02:46,910 So how can we say is this position is. 37 00:02:48,820 --> 00:02:56,020 Is this position is more positive, this position is even or odd, so what do you think? 38 00:02:57,570 --> 00:03:06,840 And to be honest, I think it's kind of hard to assess if these four here was at an even or odd position, 39 00:03:06,840 --> 00:03:15,720 since there may be also another number, like four or three, four, four, three, eight, OK, and 40 00:03:15,720 --> 00:03:27,510 it will basically it's a lot like this, but yeah, four four, four, three, eight. 41 00:03:27,930 --> 00:03:30,110 And it will basically look something like this. 42 00:03:30,120 --> 00:03:30,390 Right. 43 00:03:30,400 --> 00:03:33,190 So it will look silly. 44 00:03:33,290 --> 00:03:34,620 Not not like this. 45 00:03:34,620 --> 00:03:45,450 So for three, eight, four, three, eight and let's say I don't know, let's say five for example. 46 00:03:45,840 --> 00:03:51,620 So this will be just also the recursion calls for and divided by ten for every recursive call. 47 00:03:51,630 --> 00:03:59,160 So what I want to say by these is that also for at least number and also for this number, the value 48 00:03:59,160 --> 00:04:06,550 of four can be at an even index like here, or it can be in an odd index like here. 49 00:04:06,550 --> 00:04:07,470 Right, because zero. 50 00:04:07,470 --> 00:04:08,530 One, two, three. 51 00:04:08,910 --> 00:04:09,240 So. 52 00:04:10,230 --> 00:04:17,250 The assumption of if is less than 10, then return one or zero, just based on the fact that you have 53 00:04:17,250 --> 00:04:20,820 one digit is not the correct way to go. 54 00:04:21,900 --> 00:04:23,650 So what do you think? 55 00:04:24,000 --> 00:04:25,980 How should we basically approach that? 56 00:04:27,040 --> 00:04:34,650 And one of the things that I suggest to you to understand is the fact that, first of all, for every 57 00:04:34,770 --> 00:04:43,230 natural number you may have for the end itself, OK, for the end itself, that's the very that's the 58 00:04:43,230 --> 00:04:46,500 catch here, let's say, or the basic trick. 59 00:04:46,890 --> 00:04:50,650 So for every M, there are only two options. 60 00:04:50,670 --> 00:04:53,430 OK, two options either. 61 00:04:54,390 --> 00:04:58,350 Either the number of digits is even or odd. 62 00:04:58,380 --> 00:05:00,150 OK, so even. 63 00:05:01,790 --> 00:05:02,510 We're on. 64 00:05:03,440 --> 00:05:09,950 Number of digits, OK, so every number is compromised of digits, so every number goes like this, 65 00:05:09,950 --> 00:05:19,100 like digit one digit too, and so on up until some digit M right every number, this may be one digit 66 00:05:19,100 --> 00:05:21,530 number, two digits number and so on. 67 00:05:22,430 --> 00:05:27,390 And the number of these digits, maybe either odd or even. 68 00:05:28,010 --> 00:05:33,950 OK, so that's the first step that I want you to understand, because that's going to be crucial and 69 00:05:33,950 --> 00:05:36,130 very important for our solution. 70 00:05:36,740 --> 00:05:38,060 So even and odd. 71 00:05:38,060 --> 00:05:47,390 So even and odd does not mean that there is something about the positions that that's just the dust. 72 00:05:47,630 --> 00:05:54,080 That just means that there are even even digits or digits. 73 00:05:54,080 --> 00:06:02,480 So that example here, like twenty six or four, eight, seven, five, I don't know, two digits, 74 00:06:02,480 --> 00:06:04,730 four digits, even number of digits. 75 00:06:04,970 --> 00:06:08,990 Odd will be like three five seven five. 76 00:06:08,990 --> 00:06:10,110 I don't know, something like that. 77 00:06:10,130 --> 00:06:14,290 OK, three digits, one digit odd number of digits. 78 00:06:14,300 --> 00:06:20,090 So let's just on droid here that everything will be also clear to you. 79 00:06:20,090 --> 00:06:23,000 Number of digits. 80 00:06:24,190 --> 00:06:24,710 Awesome. 81 00:06:25,090 --> 00:06:32,710 So that's the number of digits, number of digits, and now what I want us to do is basically to use 82 00:06:32,710 --> 00:06:42,640 the same approach that we used previously by just taking the end and to call these recursive calls. 83 00:06:42,750 --> 00:06:48,220 OK, but these recursive calls are going to have some catch, OK? 84 00:06:48,820 --> 00:06:57,670 On every iteration, I want us to divide the value by a hundred, OK, and to test two. 85 00:06:57,910 --> 00:07:06,580 Basically two are things the value on the rightmost value and the value the other value that I will 86 00:07:06,790 --> 00:07:08,600 just show you in a bit. 87 00:07:08,620 --> 00:07:15,430 OK, the rightmost value and one to each left and we will have two scenarios here. 88 00:07:15,670 --> 00:07:20,120 First scenario is if and is less than 10. 89 00:07:20,680 --> 00:07:25,840 OK, meaning we got one digit and if and is less than a hundred. 90 00:07:25,960 --> 00:07:30,190 OK, so these are going to be our two base cases. 91 00:07:31,200 --> 00:07:34,440 And why is that why do we have to base cases? 92 00:07:35,310 --> 00:07:47,640 Because whenever we will have and deal with our values that have like that have even numbers of digits, 93 00:07:48,180 --> 00:07:51,890 then in this case, every time that you are going to divide it by 100. 94 00:07:52,350 --> 00:07:58,230 OK, then let's say I don't know, let's say four four eight seven five. 95 00:07:58,230 --> 00:08:01,170 You divided by a hundred, you get like forty eight. 96 00:08:01,290 --> 00:08:04,860 So you will always be like in this region. 97 00:08:05,110 --> 00:08:14,640 OK, for all the values that have like a number of digits, even every time you divide by 100, you 98 00:08:14,640 --> 00:08:15,900 will always fall here. 99 00:08:16,200 --> 00:08:20,910 Either way, it's going to be like, no, like these two six, five, four, three, two. 100 00:08:21,330 --> 00:08:24,870 You divided by a hundred and then you divide it by also a hundred. 101 00:08:24,870 --> 00:08:27,000 And then this value is going to be here. 102 00:08:27,070 --> 00:08:35,370 OK, you are never going to reach these base case where you simply have this if and these less than 103 00:08:35,370 --> 00:08:45,210 10 never for even for one number of digits equal to even on the other hand, you are always going to 104 00:08:45,210 --> 00:08:51,690 reach these place for numbers that have an odd number of digits. 105 00:08:51,700 --> 00:08:55,860 So in this case, three will reach here five seven five. 106 00:08:55,860 --> 00:09:01,020 When you divide it by a hundred, you're also going to remain with five and you are going to reach this 107 00:09:01,020 --> 00:09:01,360 place. 108 00:09:01,950 --> 00:09:09,570 So this fact, the differences between these two base cases is actually used to distinguish between 109 00:09:09,570 --> 00:09:17,810 two cases when we have a number of digits and even number of digits and an odd number of digits. 110 00:09:18,540 --> 00:09:20,040 And why is it so useful? 111 00:09:20,910 --> 00:09:29,730 That's useful because it will allow us during the process to know in advance, OK, to compare basically 112 00:09:29,730 --> 00:09:39,180 these two values, the rightmost and one on its left, and simply to build our way up once we know the 113 00:09:39,180 --> 00:09:39,870 position. 114 00:09:39,960 --> 00:09:47,100 OK, so here we will know that if we if any less than one hundred, let's say it will be like four eight. 115 00:09:47,460 --> 00:09:54,210 OK, then in this case we know to check that both of them satisfy the condition, if so, return one, 116 00:09:54,210 --> 00:09:55,680 otherwise return zero. 117 00:09:56,100 --> 00:10:03,480 And then we will have like on the way up four eight seven five and we will check this out and these 118 00:10:03,480 --> 00:10:09,120 out and we will know that this will be always at an even position and this will always be at an odd 119 00:10:09,120 --> 00:10:09,700 position. 120 00:10:10,320 --> 00:10:15,150 OK, so once again, that's not so trivial to grasp at first. 121 00:10:15,330 --> 00:10:24,330 OK, I'm going to write the code and then we are going to go over this visualisation process again, 122 00:10:24,330 --> 00:10:28,520 OK, with a few examples to make sure that everything is clear to you. 123 00:10:28,530 --> 00:10:34,180 So don't worry, you hopefully will understand everything that goes behind the scenes. 124 00:10:34,250 --> 00:10:40,050 OK, so now let us start writing of the solution, guys. 125 00:10:40,080 --> 00:10:43,020 OK, so let's just make sure that I'm recording this. 126 00:10:43,020 --> 00:10:43,650 Yes. 127 00:10:44,100 --> 00:10:47,130 And then I'll start with the solution. 128 00:10:47,130 --> 00:10:50,190 Let's remove everything from here from the screen. 129 00:10:50,640 --> 00:10:51,360 Awesome. 130 00:10:51,360 --> 00:10:58,680 And let's go here and let's call our function, first of all, the type of the function. 131 00:10:58,800 --> 00:10:59,730 What should it be? 132 00:11:00,400 --> 00:11:01,830 Let's stay with an integer. 133 00:11:01,830 --> 00:11:02,040 Right. 134 00:11:02,040 --> 00:11:09,570 Because the two optional values that can be returned from this function are simply either zero or one. 135 00:11:10,500 --> 00:11:11,040 All right. 136 00:11:11,040 --> 00:11:11,370 So. 137 00:11:13,260 --> 00:11:25,620 And let's call it I don't know, I don't know even the or I don't know, um, even on Phonic, let's 138 00:11:25,620 --> 00:11:30,590 call it for now and get some value or some natural number of him. 139 00:11:30,900 --> 00:11:31,370 Awesome. 140 00:11:32,100 --> 00:11:39,330 So we said that we are going to treat mainly to base cases, OK, to base cases. 141 00:11:39,780 --> 00:11:43,160 The first one is when M is less than 10. 142 00:11:43,800 --> 00:11:58,110 And if that's the case, let us see if OK if no if these and modular two equals to zero, if that's 143 00:11:58,110 --> 00:12:08,700 the case, if it a one digit one digit number, OK, one digit number, that simply means that we were 144 00:12:08,940 --> 00:12:16,110 working with on some end value that have in the first place. 145 00:12:16,110 --> 00:12:24,930 And the first recursive call, an odd digit, an odd number of digits, then it means that this digit 146 00:12:25,220 --> 00:12:32,010 OK, this digit right here is going to be at what position at and what do you think. 147 00:12:33,020 --> 00:12:40,310 And even position, right, because again, here is a simple example, four, three, eight, and if 148 00:12:40,310 --> 00:12:43,030 we divided by 100, we simply get these four. 149 00:12:43,310 --> 00:12:48,740 So if we will take a look, these four will be at an even position always. 150 00:12:48,750 --> 00:12:49,070 Right? 151 00:12:49,070 --> 00:12:49,400 Right. 152 00:12:49,400 --> 00:12:54,070 Because every time we are going to divide by 100, it's going to be at an even position. 153 00:12:54,680 --> 00:12:55,120 Awesome. 154 00:12:55,550 --> 00:13:04,760 So if and can be divided by two without the remainder, that means that the value is even also. 155 00:13:04,940 --> 00:13:11,660 And if that's the case, we can assume that we will return one because the condition is satisfied, 156 00:13:12,140 --> 00:13:22,790 otherwise we will return zero because the condition is not satisfied, meaning we have one digit and 157 00:13:22,790 --> 00:13:28,580 its position is even, but the value cannot be divided by two without the remainder. 158 00:13:28,850 --> 00:13:35,330 That means that the final result should be zero because the condition is not satisfied. 159 00:13:35,360 --> 00:13:38,270 This condition here right for returning one. 160 00:13:39,800 --> 00:13:40,360 Awesome. 161 00:13:40,730 --> 00:13:44,510 So now let us proceed for the second base case. 162 00:13:44,900 --> 00:13:51,740 And these base case is basically something like this if and is less than one hundred, meaning it is 163 00:13:51,740 --> 00:13:53,900 a two digits number. 164 00:13:54,320 --> 00:13:56,930 OK, and if that's two digits. 165 00:13:56,930 --> 00:13:58,820 No, that's awesome. 166 00:13:58,820 --> 00:13:59,140 Right. 167 00:13:59,150 --> 00:14:05,870 Because that means we simply are we simply we simply we simply. 168 00:14:05,870 --> 00:14:06,860 What does it mean? 169 00:14:07,100 --> 00:14:09,260 What do you think, if anything, less than one hundred. 170 00:14:09,270 --> 00:14:10,970 What does it mean then. 171 00:14:11,670 --> 00:14:17,800 It means we are we remain with just two digits, OK. 172 00:14:17,900 --> 00:14:21,500 And it will look like we don't have an example here. 173 00:14:21,500 --> 00:14:26,300 So let's say we simply will also make another example. 174 00:14:27,560 --> 00:14:32,180 We will make another example, its example three, and it will be like this. 175 00:14:32,570 --> 00:14:34,130 So five here. 176 00:14:34,140 --> 00:14:34,910 So did it. 177 00:14:35,870 --> 00:14:39,110 And also we will use also like something like this. 178 00:14:39,140 --> 00:14:45,650 OK, so position zero, position zero will have five. 179 00:14:45,650 --> 00:14:47,660 Position one will have eight. 180 00:14:47,660 --> 00:14:53,180 Position two will have three and position three will have four. 181 00:14:53,210 --> 00:14:53,540 OK. 182 00:14:54,520 --> 00:14:58,040 So what do we have here? 183 00:14:58,240 --> 00:15:04,240 What do we have here if AMM is less than 100 hundred, meaning we divided this time by a hundred, we 184 00:15:04,240 --> 00:15:09,790 got forty three, then in this case, we know that we will have two digits. 185 00:15:09,940 --> 00:15:12,070 OK, do digits four and three. 186 00:15:12,410 --> 00:15:15,710 OK, that's the base case we are planning to reach. 187 00:15:15,730 --> 00:15:26,440 So four and three and this three lies on position even and these four will lie on position on OK so 188 00:15:26,740 --> 00:15:27,430 do digits. 189 00:15:27,670 --> 00:15:34,180 Are the rightmost digit at even position. 190 00:15:34,630 --> 00:15:35,110 Right. 191 00:15:35,120 --> 00:15:46,390 Even pause and leftmost, leftmost or left digit is at odd position. 192 00:15:46,690 --> 00:15:53,200 OK, you see, you see what we're doing here so we know we will have two digits and the rightmost digit 193 00:15:53,740 --> 00:15:59,410 that can be accessed by using these and modulo 10 can be accessed. 194 00:15:59,890 --> 00:16:07,930 And it will it is going to be at an even position and the one on its left is going to be at an odd position. 195 00:16:09,250 --> 00:16:19,540 All right, so OK, if that's the case, we are going to see the following if an Modula 10, which is 196 00:16:19,540 --> 00:16:24,720 their rightmost digit, can be divided by two without a remainder. 197 00:16:24,880 --> 00:16:28,420 OK, if it can be divided by two without the remainder. 198 00:16:29,020 --> 00:16:38,710 And also if we take the leftmost digit in such a case and divided by two without a remainder or basically 199 00:16:38,710 --> 00:16:40,700 with the remainder of one. 200 00:16:41,560 --> 00:16:51,870 So if that happens, that will mean that the rightmost digit at the even position is the value is even 201 00:16:52,150 --> 00:17:03,190 and also the left value in between these two digits is an odd value, has an odd value. 202 00:17:03,190 --> 00:17:06,430 And it's also, as we said, at an odd position. 203 00:17:06,790 --> 00:17:10,240 If that's the case, what do you think we should return? 204 00:17:10,630 --> 00:17:13,030 We should return one. 205 00:17:13,570 --> 00:17:18,670 OK, otherwise, of course, we can return zero. 206 00:17:20,320 --> 00:17:21,230 Is that clear? 207 00:17:21,700 --> 00:17:30,130 OK, we just tweeted the two base cases, so that was basically case one base case still in the differences 208 00:17:30,130 --> 00:17:34,510 between them is that these base cases going to be reached. 209 00:17:34,680 --> 00:17:38,170 OK, if we correctly build the following line of code. 210 00:17:40,090 --> 00:17:51,070 If we are, it's going to be reached only for numbers that have been in an odd number of digits. 211 00:17:51,070 --> 00:17:58,270 And these base case is going to be reached for numbers that have only on an even number of digits. 212 00:17:59,830 --> 00:18:00,240 Whoo! 213 00:18:00,490 --> 00:18:02,480 All right, so let us proceed. 214 00:18:02,530 --> 00:18:09,380 And now what we are going to do is basically to ask the following question. 215 00:18:09,700 --> 00:18:17,500 So that's going to be regarding our, um, our recursive call. 216 00:18:17,890 --> 00:18:20,850 So our recursive call is going to be very simple. 217 00:18:21,220 --> 00:18:29,350 We are going to ask we are going to ask if an modula to or basically Modula 10. 218 00:18:29,350 --> 00:18:42,370 Modula Two, which means the rightmost digit, if it is and even digit and also if this digit of digit 219 00:18:42,370 --> 00:18:52,840 on on its left, OK, one on its left, so much about 10 if this digit the rightmost digit and also 220 00:18:53,020 --> 00:19:00,070 the one digit on its left, OK, and divided by 10 modulo 10 can be divided by two. 221 00:19:00,940 --> 00:19:08,410 OK, if that's the case, OK, we are going to assume that if that's the case, we are going to return 222 00:19:08,410 --> 00:19:09,220 the result. 223 00:19:09,950 --> 00:19:14,320 OK, four are these even all function. 224 00:19:14,590 --> 00:19:18,020 Four and a hundred. 225 00:19:19,210 --> 00:19:24,640 OK, so that's very not so intuitive else return zero. 226 00:19:26,360 --> 00:19:33,860 OK, so that's not so intuitive to to grasp at first, but first of all, what I want you to understand 227 00:19:33,860 --> 00:19:43,850 is the distinguished distinguish distinguish we've made between numbers with odd and even number of 228 00:19:43,850 --> 00:19:44,320 digits. 229 00:19:44,840 --> 00:19:51,710 And now regarding these recursive call, I think the best way to understand it is simply to use some 230 00:19:51,710 --> 00:19:54,410 drawing and to use some examples. 231 00:19:54,440 --> 00:20:00,140 OK, so let us start let me get my pen and let's start drawing. 232 00:20:00,260 --> 00:20:00,770 OK, so. 233 00:20:01,950 --> 00:20:09,480 Let's say that we are going to start with this third example, so it's going to be like four, three, 234 00:20:09,510 --> 00:20:16,110 eight five, OK, this condition is false, this condition is false. 235 00:20:16,110 --> 00:20:20,550 And we are going to ask if five in this case, that's five. 236 00:20:20,550 --> 00:20:25,290 If five is even, is there even what do you think? 237 00:20:25,600 --> 00:20:27,180 Is it even know? 238 00:20:27,180 --> 00:20:27,980 It's not even. 239 00:20:28,230 --> 00:20:30,480 But we are checking the even position. 240 00:20:30,990 --> 00:20:33,600 We are checking the even position. 241 00:20:34,050 --> 00:20:37,800 OK, that's the rightmost element, if that's the case. 242 00:20:38,220 --> 00:20:44,970 But it's not, then we simply go to the else and we return zero. 243 00:20:45,520 --> 00:20:52,860 OK, so the result for these will be zero and it kind of makes sense since you can see here and even 244 00:20:52,860 --> 00:20:55,140 position but an odd value. 245 00:20:55,440 --> 00:20:58,590 So that's basically it for this example. 246 00:20:58,620 --> 00:20:59,820 So that's how you find it. 247 00:21:00,790 --> 00:21:04,160 Now, let us proceed to another example. 248 00:21:04,680 --> 00:21:06,630 So let's see what it is. 249 00:21:07,530 --> 00:21:08,940 Let's go a little bit up. 250 00:21:08,940 --> 00:21:10,890 So four, three, eight. 251 00:21:11,080 --> 00:21:16,100 OK, so four, three and four and eight. 252 00:21:16,890 --> 00:21:24,980 OK, so now we are going to let's just remove that so we'll see everything on the screen. 253 00:21:24,990 --> 00:21:26,040 Also the code. 254 00:21:26,700 --> 00:21:29,760 OK, so now we are going to ask the following question. 255 00:21:29,760 --> 00:21:31,390 Condition, false condition, false. 256 00:21:32,010 --> 00:21:34,830 So if the rightmost digit is even. 257 00:21:35,130 --> 00:21:35,990 Yes, it is. 258 00:21:36,360 --> 00:21:40,430 And one on its left, which is three is odd. 259 00:21:40,440 --> 00:21:41,310 Yes it is. 260 00:21:41,790 --> 00:21:47,400 Then we are going to return all four and divided by one hundred, which is four. 261 00:21:47,900 --> 00:21:53,960 OK, so this result basically depends on what it's going to return us for even often. 262 00:21:53,980 --> 00:21:54,630 Four, four. 263 00:21:55,230 --> 00:22:03,780 And if we are going to come here, this is the base case related right to numbers with just odd number 264 00:22:03,780 --> 00:22:04,440 of digits. 265 00:22:05,220 --> 00:22:07,500 Then in this case, this condition is true. 266 00:22:07,500 --> 00:22:08,820 Four is less than 10. 267 00:22:09,150 --> 00:22:14,040 If four can be divided by two without the remainder, that is true. 268 00:22:14,040 --> 00:22:20,580 The value is even and it was at an even position, then we are going to return one. 269 00:22:20,790 --> 00:22:23,280 And also from here we are going to return. 270 00:22:23,280 --> 00:22:25,110 One final result is one. 271 00:22:25,390 --> 00:22:32,310 All the conditions, conditions are satisfied exactly as we explained and expected. 272 00:22:33,720 --> 00:22:36,580 And now let us see the final example. 273 00:22:36,630 --> 00:22:38,280 OK, I hope everything is clear. 274 00:22:38,310 --> 00:22:40,350 Ask me if you have still any questions. 275 00:22:41,220 --> 00:22:43,170 Let us see the final example. 276 00:22:43,200 --> 00:22:43,980 What was it? 277 00:22:44,820 --> 00:22:45,450 What was it? 278 00:22:45,600 --> 00:22:49,600 Three six three six four three five. 279 00:22:49,620 --> 00:22:50,250 OK, so. 280 00:22:51,400 --> 00:22:57,200 That's it, three, six, four, three, five. 281 00:22:57,270 --> 00:23:05,230 OK, so let us check let us check if and Modula 10, which is the rightmost digit, can be divided by 282 00:23:05,230 --> 00:23:07,240 two without a reminder ups. 283 00:23:07,420 --> 00:23:10,040 No, it can be so return to zero. 284 00:23:10,510 --> 00:23:11,400 And there you go. 285 00:23:11,560 --> 00:23:15,680 Basically, you return zero right from the start. 286 00:23:16,690 --> 00:23:21,750 So these are this is it about the examples that I wanted to show you. 287 00:23:21,760 --> 00:23:28,900 Of course, there are a lot of additional examples that we can use, but I think I've covered at least 288 00:23:28,900 --> 00:23:31,660 a few of them to make it more clear to you. 289 00:23:31,660 --> 00:23:38,590 And now I want to simply summarize the steps that we used to solve this exercise. 290 00:23:39,490 --> 00:23:39,910 So. 291 00:23:41,310 --> 00:23:50,580 Step number one was to distinguish between two main scenarios, scenario number one was like to understand 292 00:23:50,700 --> 00:23:58,950 that there should be some sort of different treatment and different solution for situations when you 293 00:23:58,950 --> 00:24:03,970 have an odd or even number of digits in a given number. 294 00:24:04,240 --> 00:24:07,980 OK, so that was the first thing we had to take care of. 295 00:24:07,980 --> 00:24:12,780 And we simply got got got it taken care of at this step. 296 00:24:13,170 --> 00:24:19,590 Of course, if you see it for the first time, this kind of exercise, it's not so easy to grasp and 297 00:24:19,590 --> 00:24:27,720 it's not so trivial to understand the separation between assuming that if there are going to be odd 298 00:24:27,720 --> 00:24:33,780 number of digits, then if you divide it by 100 every time and you reach these kind of time that the 299 00:24:33,780 --> 00:24:36,570 number that digit is going to be at even position. 300 00:24:36,900 --> 00:24:42,330 And here you will have two digits and, you know, like it's very hard at first time. 301 00:24:42,570 --> 00:24:50,820 But now, since you kind of know the basics in the approach, it should be easier for you to solve or 302 00:24:51,510 --> 00:24:57,000 exercises of a similar concept and of a similar complexity. 303 00:24:57,570 --> 00:24:58,950 OK, so that's about it. 304 00:24:59,370 --> 00:25:04,710 And the first place then we have like to understand how to make the recursive call. 305 00:25:04,710 --> 00:25:10,920 So we understood why we're using and divide it by a hundred every time that it will be able to distinguish 306 00:25:11,670 --> 00:25:23,400 for us two cases like here and every time we don't care if we have like numbers of an odd number of 307 00:25:23,400 --> 00:25:28,200 digits or an even number of digits, we don't care about it since we start from there. 308 00:25:28,200 --> 00:25:29,090 Right, OK. 309 00:25:29,100 --> 00:25:30,810 And when we start from there, right. 310 00:25:31,080 --> 00:25:38,360 Every time we will see the rightmost element, it should have a value that is even and one only two 311 00:25:38,370 --> 00:25:40,740 left should have a value that is odd. 312 00:25:41,220 --> 00:25:47,220 Otherwise there is no sense to make any recursive calls and we will simply assume that the return result 313 00:25:47,220 --> 00:25:48,690 should be zero. 314 00:25:48,780 --> 00:25:56,580 OK, so every time we we we since we divide by 100, every time we are going to start like from from 315 00:25:56,580 --> 00:26:01,410 position zero and then from position to and from position four and so on and so forth. 316 00:26:01,800 --> 00:26:03,390 So that makes sense. 317 00:26:03,590 --> 00:26:12,180 OK, and the final distinguish between the two based cases will be handled in these kind of sections. 318 00:26:14,130 --> 00:26:18,750 Who so guys, this exercisable is not an easy one. 319 00:26:18,850 --> 00:26:20,460 I hope you've got a hold of it. 320 00:26:20,880 --> 00:26:24,930 If you still have any questions, feel free to ask them. 321 00:26:25,230 --> 00:26:34,860 And for those of you that know the answers to the questions being asked, also, we kind and try to 322 00:26:34,860 --> 00:26:41,640 help your associates and your friends if they have, like, questions that you can address and you can 323 00:26:42,360 --> 00:26:50,880 answer very accurately, since that's also kind of a good learning process when you try to explain it 324 00:26:50,880 --> 00:26:51,870 to someone else. 325 00:26:52,440 --> 00:26:55,720 And yeah, this is it for these Medio guys. 326 00:26:55,740 --> 00:26:56,850 My name is Vlad. 327 00:26:57,000 --> 00:26:58,110 This is Alphatech. 328 00:26:58,230 --> 00:27:02,710 I hope you like the course so far and until next time, I'll see you then. 329 00:27:03,300 --> 00:27:08,550 Oh, and by the way, don't forget to let me know what you think of the video and maybe to leave some 330 00:27:08,580 --> 00:27:14,130 review that I will know that the process is going exactly as planned. 331 00:27:14,280 --> 00:27:15,450 Or at least I hope so. 332 00:27:17,040 --> 00:27:17,390 Yeah. 333 00:27:17,580 --> 00:27:18,140 Bye bye. 31692

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