A condition of the task is:-
If the list is not ordered by increasing string length, then display the index of the first element that violates this order.
The list is:-
grandfather
grandmother
father
mother
son
daughter
cats
dog
program
car
My code displayed index 1 (Grandmother) as it is the first that does not increase (both grandfather and grandmother are length 11).
The CodeGym displayed 2 (father).
Of course, I think I'm right and CodeGym is wrong😄 but I'm willing to be convinced otherwise if I'm wrong????????
Jcode
Level 27
A question
Under discussion
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Gellert Varga
30 January 2022, 17:36useful
Take an example:
index 0 = 11;
index 1 = 11;
index 2 = 14;
index 3 = 14;
index 4 = 15;
How is it possible to sort the above elements in ascending order?
Exactly as shown above.
If there are two identical elements, they must be next to each other, and that does not violate the principle of ascending order.
In the list below, index 3 is the first one that violates the principle of ascending order:
index 0 = 5;
index 1 = 5;
index 2 = 7;
index 3 = 6;
+1
Jcode
30 January 2022, 20:59
Thanks Gellert for your feedback.
I agree with your interpretation.
It just goes to show, the easy(er) bit is the syntax the real challenge is the semantics.
0
Gellert Varga
30 January 2022, 21:42
There are some tasks where it is very difficult to understand what the task requires of us...
0
PeterC Android Developer
30 January 2022, 11:48
You need to post your code in order for me to respond to your question.
0