To find the third Sunday in March for any given year, start from March 1st and iterate through each day, using a day index function to check if each date is a Sunday (day index = 1), incrementing a Sunday counter until it reaches 3, then returning the current day number as the result.
Deep Dive
Voraussetzung
- Keine Daten verfügbar.
Nächste Schritte
- Keine Daten verfügbar.
Deep Dive
9618 Oct Nov 2024 P23 Question 6 | Past Paper PracticeHinzugefügt:
Okay brother, let's look at this question. This is our question 9618 from October-November Paper Two Variant Three 2024.
We are going to attempt question number six. It's related to the concept of It's a Date. So let's see quickly. Let's try to understand.
It's just that its wording was complicated. So everyone please focus on the wording with me. Quickly identify its patterns. Now according to this here he is telling you that is in some countries on the third Sunday in March. Correct? What do you want to say? In some countries, there is a third Sunday, like there are four Sundays in a month, so first Sunday, second Sunday, third Sunday, fourth Sunday and let's talk about the third Sunday. So the third Sunday in March means the third month. Daylight sleeping time begins when the clock moves forward by one hour. Now they are telling you that you have to create a module by the name of Adjust Clock which will take the year. This module will return an integer value representing the number of the day in March. Coming on 20th March, coming on 30th March.
When is the third Sunday coming? Coming on 20th March, reading on 2nd March, when is he reading? So, that's something I want to tell you. On which the clock moves forward. For example, the following line of the Sud code would assign the day number the value 20. Day number at Just Clock 2022 means the third Sunday fell on 20th March.
So now, based on whatever year you're given, when is You Should Be Able to Find Out Third Sunday coming out? That's it. There is so much work.
You people have to carry things in this manner.
How will you start?
Start from the first of March.
Go and see on the first of March. On March 1st, we have to count Sunday. Sunday counting will have to be performed. And how will you do it? Do flag looping. I will show you guys how to do it quickly and simply. As soon as our Sunday count reaches three, we will move our flag. will stop your loop.
And whatever the day number is, we will keep doing +1 +1 +1 +1 +1 one by one.
Children's work is easy. Ok? Now look at everything carefully. And you have to make dates.
Now how will we know when Sunday is coming? So for that we have let's go to our insert. Let me try define the insert.
Where did you go brother?
Ok. Here you go. This is our insert.
Inside this we have date functions. Let's see quickly. There is a function called day index. It takes the date and gives you the index accordingly.
If the value in the index is one.
If the day index is returning one, then that means it is Sunday. Do you understand? So we'll take a date, make a date. We will keep making dates, keep making dates, keep making dates all the time.
And whenever the value of day index is one, SundayCount + 1 SundayCount + 1 EG EG is true. This one is 22. Hey brother, where have you gone? Where did you go? Where did you go? Ok. Let's focus now. So now what do we have to do according to this? First thing is function. OK Function Heading Adjust K This Colon Anti You Take What does return?
Returns [nasal sound] Increase value is correct. I'm gonna leave some lines for declaration purposes and off to the I have to count down to Sunday.
Sunday count initializes to zero.
After that I need to make day number day number initialize to one first March I will start. Correct? I have to initialize the number D to one and then loop the flag because as soon as the Sunday count becomes three, the loop has to be stopped. So initializing flag arrow false.
Then a wild flag equals two fouls.
As long as the flag value is false, keep running the loop and what do you do in the loop?
Make a date. How do you make a date now? That's a good question.
Let's look into the insert set date name.
He has to give the day, month and year. So all these things have to be given to him. That will make us a date.
So let's make it quickly.
Date let's call it our date I don't know why I am good we don't say our date what do we say this date store it inside this date set date now you have to give three things to set date you have to give day day number which is our day number. You have to give the month which is your March January February March and then you have to give the year which is your this year which will be given to the parameters.
Correct? This date, set date, day number three, this year. Now we have to find its index.
Correct? Now let us calculate the day index.
Store it inside the index.
Go to the day index.
Use the module with the ah function.
Pass this date in it.
This will give us the index. If the value of our index is equal to one, then I'm supposing that it's Sunday, then I need to increment the value of my Sunday count.
Sunday count should be made equal to Sunday count +1. Correct?
Right now I am not going to focus on the right. So please don't judge me. Ok? Sunday count will equal to Sunday count +1. If the value of index is one. Correct? And if and after that once this thing is ready, what do you have to do now? A If index equals 1 then Sunday account equals to Sunday account + 1 What else do we need?
If index = 1 then SundayCount equals SundayCount + 1 Now we have to create one more condition here which is the condition to stop the loop.
If SundayCount = 3 Then Flag = true. Else, if the value of the sand account is not that much then we will keep incrementing within our day number.
Easy man, easy. Increment within the day number.
Increment the day number by adding the old value of the day number plus one.
Then we will test it on 2nd March. Then we will test it on 3rd March. Then we will test it on March 4th. It will continue in this manner.
End EF this also.
Now ah loop will stop our. That's it. The loop will stop.
As soon as the loop stops, the end while loop stops and returns its value.
Return day number and end function.
This was the whole story of this question. And this is how you are going to get books. So that's it.
ok sir? Is it clear to you? Let me know.
Ähnliche Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











