Of course it doesn’t pass, the library Ramda does not exist in Codewards.
You have to come up with the code to do all those things yourself:
1- How to create intervals:
// go from this
[1,2,3,4]
// to this
[[1,2],[2,3],[3,4]]
// and then to this
[[1,2],[2,3],[3,4],[4,1]]
2- How to convert a string like "HH:MM"
to a tuple of [23, 55]
for example. And then to the equivalent in total minutes.
3- How to convert an amount of minutes back to the string "HH:MM"
.
4- How to get the maximum value of of an array, I’ll give you this wisdom for free:
function maximum(list) {
return Math.max.apply(null, list);
}
5- How to sort an array in ascending order
6- How to get rid of duplicated elements
Now, the core function that ultimately makes the whole challenge take form is:
function diff([minutesA, minutesB]) {
return minutesB <= minutesA
? (1440 - minutesA) + minutesB - 1
: minutesB - minutesA - 1
}
Remember that 1440 is the equivalent of 24 hours in minutes. This function computes how many minutes apart are A from B. But for this, you have to make sure that the number of minutes from 0:00 up to A or B meet the condition minutesB <= minutesA
because remember than subtracting a lower value minus a greater value will yield a negative number and that after 24 hours the number starts from 1 again. The -1
is because the challenge says the alarm goes off for a full minute.