Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Okey dokey, what is going on, ladies and gentlemen, and welcome to another very interesting yeah,
not so easy exercise using recursions.
And in this video, in this exercise, what you are going to do is basically to write some very nonintuitive
function.
And it's going to simply do to take you now, hopefully to to the next level, because this exercise
is very not straightforward.
And actually I kind of consider it to be much more complex than the previous exercises, at least then
the exercises you solved at the beginning of this section.
So without further ado, let us start working.
So what do you have to do in these exercises to write a function, a recursive function, so write a
recursive function that gets some, I don't know, natural number and at least function basically should
be, first of all, a recursive function and it should get some natural number.
And OK, so far, so good.
And now what the function has to do is let's say you have some number and you also know that this number
is compromised of digits.
Let's say I don't know and equals two, three, six, four, three, five, OK, something like that.
And you know that this is a number and this number is compromised of digits.
So you have the digit at index zero.
OK, well, we'll start from right to left.
OK, so the position of each digit in a number, we will assume that it has some index that we will
be able to refer to.
I don't know if index is the appropriate word for it, but let's say position.
OK, so a digit has a position and we start the position right from zero.
OK, so these five is a budget position zero.
This three is a digit at position one.
These four is a digit at position two and so on and so forth.
So let's just write it down because that's an example.
I'm trying to build it and to explain it also to you as we go so and equals two, three, six, four,
three, five.
So we will say that position zero, the number is five.
Position one, the number is three position position to the number four.
Position three, the number is six.
And position polarization for the number is three.
OK.
Awesome.
So that's basically of introduction to what we are going to do in this exercise.
So we get some number and it's a natural number.
And what we want to do is to make sure that every digit OK in a are in an even location has an even
value.
OK, and also that every digit in an odd location has an odd value.
OK, so for example, if you have this number, OK, so three six four three five, we will look at
all of its digits.
So we will start with digit with the first digit at position zero and we see that the position is even
but the number itself, the value is odd.
OK, and our position one, the position itself is odd and the value is also odd.
So we want this function to return return one.
If every digit
gets a at and even position has an even value as well as every digit at an odd position has an odd value.
Otherwise return zero.
OK, so that's otherwise.
And basically, what I mean by that is that for this example, the result will be zero because not every
even position there is an even value.
OK, so this is an even position, but the value is odd.
So that's very simple.
The result should be false, basically should be zero.
So let's see another example and let's say we have, I don't know, some simpler, simpler example.
So example number two, and it goes like this.
So for three and let's say eight.
So position zero has a value of eight.
Position one has a value of three and position two has a value of four.
And in this case, we will see that an even position, the reason even value it, even position there
is an even value and also at all the position, we have an odd value.
OK, so that's basically what we have for this example example, number two will have like return one
and for the first example, we will have to return zero.
OK, so that's the exercise.
Not so easy, not so trivial.
You have somehow to distinguish between many different options and many different possible numbers that
you have to take care of and how basically you find this position using some recursive approach, although
the the Terentiev approach using sound for a while loop, many seem a little bit easier to solve this
exercise, but that's not what we are here for.
Basically, we are here to solve it on using the recursive approach, the recursive concept and using
this recursive recursion function.
OK, so think about it, how you can solve it even even.
I don't know.
Let's try even to take a few hours.
If you still don't get like the perfect result that works for all of the numbers you are trying for
all of the natural numbers you were trying either.
These numbers are going to be one digit, two digits, three digits, five digits and so on and so forth.
OK, so take some time.
Think about it, even if you can solve it in a few hours.
Don't leave this exercise.
Don't jump straight to the solution.
Try to solve it on your own.
It's very important that it's not a trivial that's not an easy exercise and it's mandatory for you to
give it a shot on your own and to try to become a better programmer, because that's the process and
that's the way guys who.
So I hope everything is clear to you.
Let me know if you have any questions about this exercise and hopefully you will manage to solve it
on your own and then to compare it with my solutions.
If not, of course.
Please, after that, take the solutions video and make sure that everything is clear to you and that
you are capable of proceeding further.
So thank you guys for watching.
My name is what this is Alphatech and we are going to solve it together.
So let's go.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.