Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code grading not consistent with mission instructions - not ignoring all instances of max value #522

Open
PLMbugz opened this issue Mar 3, 2019 · 0 comments

Comments

@PLMbugz
Copy link

PLMbugz commented Mar 3, 2019

For this lesson, I am supposed to "compute the second maximal value contained in an array, i.e. the value that becomes the maximum if you remove every instance of the current maximum from the array." As I understand it, that means that if the array has more than one instance of its maximum value, my code must ignore all of them, returning the next largest number. But when I am graded, the system is asking me to NOT ignore a second instance of the maximum value.

The array of numbers is: {22,24,1,14,-13,25,1,25,18}. Per the instructions, my code ignores both 25's and returns 24. But the PLM is saying that the expected answer is 25. This is not consistent with the instructions given in the mission statement.

Here is my code:

public int max2Value(int[] tab) {
int first = tab[0];
int second = Integer.MIN_VALUE;
for (int i = 1; i < tab.length; i++) {
if (tab[i] > first) {
second = first;
first = tab[i];
}
if (tab[i] >= second && tab[i] < first) {
second = tab[i];
}
}
return second;
}

--------------------[ Technical Information ]--------------------
(This can help us fixing your problem, please don't erase)

Lesson: welcome
Exercise: welcome.lessons.welcome.array.search.SecondMaxValue
Programming Language: Java
Locale: English (United States)
Java version: 11.0.1 (VM: OpenJDK 64-Bit Server VM; version: 11.0.1+13-Ubuntu-3ubuntu3.18.10.1)
OS: Linux (version: 4.18.0-15-generic; arch: amd64)
PLM version: 2.7 (20170901)
Public user ID: PLM6e527c892fb4e499ce3404b433efcb1eb7f70feb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant