File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
src/hackerrank/problem-solving Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -29,3 +29,28 @@ function timeConversion(s) {
29
29
30
30
return `${ hours } :${ minutes } :${ seconds } ` ;
31
31
}
32
+
33
+ /**
34
+ * 012: HackerLand University has the following grading policy:
35
+ *
36
+ * Every student receives a grade in the inclusive range from 0 to 100.
37
+ * Any grade less than 40 is a failing grade.
38
+ *
39
+ * Sam is a professor at the university and likes to round each student's grade according to these rules:
40
+ * If the difference between the grade and the next multiple of 5 is less than 3, round grade up to the next multiple of 5.
41
+ * If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.
42
+ */
43
+
44
+ function gradingStudents ( grades ) {
45
+ let count = [ ] ;
46
+ for ( let i = 0 ; i < grades . length ; i ++ ) {
47
+ if ( grades [ i ] % 5 == 3 && grades [ i ] >= 38 ) {
48
+ count . push ( grades [ i ] + 2 ) ;
49
+ } else if ( grades [ i ] % 5 == 4 && grades [ i ] >= 38 ) {
50
+ count . push ( grades [ i ] + 1 ) ;
51
+ } else {
52
+ count . push ( grades [ i ] ) ;
53
+ }
54
+ }
55
+ return count ;
56
+ }
You can’t perform that action at this time.
0 commit comments