Manafall Daily Quest

Simple Time Conversion

Function Name: convertTo24HourFormat

Description

Write a function that converts 12-hour time format to 24-hour format.

The function should be able to distinguish between AM and PM to convert the time accurately.

Ignore the possibility of invalid time inputs and focus on the conversion logic.

The input time will be a string in the format 'hh:mm AM' or 'hh:mm PM'.

The output should be a string in the format 'HH:mm', where 'HH' is the hour in 24-hour format.

Requirements

  • The function should take a single string parameter.
  • When the input is '12:00 AM', the output should be '00:00'.
  • When the input is '12:00 PM', the output should be '12:00'.
  • The function should correctly handle the conversion of minutes.
  • Input hours less than 12 should be properly formatted with a leading zero in the output if necessary.

Examples

convertTo24HourFormat('01:45 PM') should return '13:45'.convertTo24HourFormat('11:59 PM') should return '23:59'.convertTo24HourFormat('12:30 AM') should return '00:30'.convertTo24HourFormat('07:20 AM') should return '07:20'.

Links

https://en.wikipedia.org/wiki/12-hour_clockhttps://en.wikipedia.org/wiki/24-hour_clock

Array Pair Sum

Sat Sep 07 2024

Write a function that finds and returns a pair of numbers from a given array of integers that adds up to a given sum. If there are multiple pairs that match the given sum, the function should return the first pair found. If no such pair exists, return an indication that no such pair has been found, such as null or an empty list.

Prev Quest

Friendly Numbers

Mon Sep 09 2024

Write a function 'isFriendly' that determines if two numbers are friendly numbers. Friendly numbers are two or more numbers with a common abundancy, which means that the sum of the proper divisors (excluding the number itself) of each number divided by the number itself is equal for both numbers. The function should take two integer parameters and return a boolean value - true if the numbers are friendly, false otherwise.

Next Quest