-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradingStudents.php
More file actions
49 lines (27 loc) · 772 Bytes
/
Copy pathgradingStudents.php
File metadata and controls
49 lines (27 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
* Complete the 'gradingStudents' function below.
*
* The function is expected to return an INTEGER_ARRAY.
* The function accepts INTEGER_ARRAY grades as parameter.
*/
function gradingStudents($grades){
$newGrades = array();
foreach($grades as $index => $grade){
if($grade > 37){
$mod = $grade % 5;
if($mod == 0){
$newGrades[$index] = $grade;
}else{
(5 - $mod) < 3 ? $newGrades[$index] = ($grade + (5 - $mod)) : $newGrades[$index] = $grade;
}
}else{
$newGrades[$index] = $grade;
}
}
return $newGrades;
}
/*
https://www.hackerrank.com/challenges/grading/problem?isFullScreen=true
*/
?>