8.3 Creating an Athletic Competition Starting List Part 2
8 hours 33 minutes
Okay, Now we have to determine the status off
each athlete. So have they qualified or not?
And it's very simple if they were first or second within their group. So it can be simple if
and if it's one or two. Or let's say if this cell is here smaller than three because we're talking about integers, then it's qualified. So we're going to put here. Q.
But if if it's not, we're going to create the function, and this function is going to look for all the others
that they're not qualified by position
and then it's going to determine
to off them that have the best result meaning the lowest time.
And let's start with, uh, visual basic
sorry it's here.
let's insert on module.
let's ah, define it as a function.
And this function is going to be called
we're here, put a result as variable, so we're goingto put in that function. Result of that competitors and the function is going to determine
is it is the competitive, qualified or not,
and we have to define the type of this, uh, function. So it's going to be a string.
uh, What we're going to return is Q or an Q so qualified are not qualified,
and we first have to define some things. So
we're going to define some variables 1st 1 is going to be
none qualified time, and it's going to be an airy
So we have 24 competitors. Six have qualified, so we have
that have not qualified.
So it's going to be done like this. So even to say one to Il 18. So it has 18.
It's ah, it's a single dimensional array and it has 18
and, of course, as single because we're talking about times there, so it has to be decimal numbers single.
Then we're going to define some counters
a as sorry
in de Germ,
and also we have. I want this
and if we start needing something on the way,
we're going to
put them later.
So first of all, we're going to go through all 24 results
and look, if
in ah in ah
ah ranking is one or two.
So if it's not, if it's higher than two. Then we're going toe. Add the result in the
And if it's somebody who has qualified,
we're just just not going to do that. So
let's say like this. I won. We start with manual counters. Zero and then
we're going tow.
uh, loop for
sorry. We're going to go from 3 to 26
because these are the rose in original table
and then we're going to ask a question.
It is, if
off and then we're going to look at column G where the
ah rankings are
and we're going to add a row number, which is I.
So if the value off this is greater than two, that means that competitors have qualified. Then
we're going to do the following were first going toe add
one to the counter off.
Uh, the cells in this you ah, ray called and cute time.
And then we're going to say and
time off. I won. So off that position, we put
results are in column. If
and don't well, you.
So we have done this one successfully,
and we're just going to close this and we're going to say next.
So now we have that to Ray.
Now we have to sort it
and for sorting, we're going to use the bow standard,
most inefficient but most but the simplest sorting algorithm because we don't really care about how fast is going to happen because we have only 18 values.
So we've been safe, for I equals 1 to 18
and then for I won equals 1 to 17. And what we're looking now
is, and we have a question. So if
and cue time
is larger than an Q
time off I one plus one.
And if it's the case then
and this is what's happening. So we're going to go
18 times because we have 18.
remember, the cells are in the array,
and then we're going to check if the 1st 1
is larger than the next one. So the 2nd 1 and then the next pass is going to be 2nd 1 compared to 3rd 1 So if this one is larger,
then we're going toe, replace their positions.
So we're going to
and it's going to be cool and cute.
So it's a temporary
And then we go said, Thank your time off. I won
equals in cute time
I went plus one.
And then in cute time off
I one plus one
yeah, that's it. We have exchanged them. And if
and then here was going to be next
And then next I
So we have no sword to disarray successfully,
and now it's sorted. Now what? We have to see
if that's ah,
athlete has qualified or not. The one that we're asking this four.
So we have given its result. And now we're what? We're going to have a simple question.
So if result
smaller than en que time
it means if it's on a 17 or 18 position, remember again, we have sorted this in S O. The largest is first,
So it's descending order. So positions 17 and 18 they have the best time, so the lowest time. So we want to see if we're on position 17 or 18.
So if this is
the case, sorry,
happens when you
uh, we're going to return comp
status. So now we're using the name off. The function is variable. So we're saying, OK, this function is now variable and this is what's going to be returned to excel so
and it's equal.
So if that is the case
that competitors has qualified
and it's for a simple
is going to be equal,
And we're going to close on Dhe if.
And that's it.
This is this function.
You're going to save it.
We're going to close
going to close this one, and we're going to continue in next video.