BuggleInc / PLM

Programmer's Learning Machine
http://people.irisa.fr/Martin.Quinson/Teaching/PLM/
Other
63 stars 40 forks source link

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

Open PLMbugz opened 5 years ago

PLMbugz commented 5 years ago

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