Techgig

World Army vs Aliens

World Army vs Aliens

The world is going to be attacked by the aliens. The space intelligence department has raised an alarm and the world armies are coming together to fight them. The planning and strategizing is being done to make the maximum impact on the alien ships. The deadly missiles are to be put into action. The missiles are targeted to destroy the alien ships in space and disable them to land on the Earth.


The army is planning to launch the attack at A time (hh mm) to get an advantage. For each attack, they know the time the missile will require to hit the coming alien ship. They all are busy in preparation and want to know the time at which the blast will occur and the alien ship will be destroyed in pieces. Can you find the time of the blast ?


Note: The World Army follows a 24-hour time format and you need to find the time of blast accordingly. The time will be in the hh mm format.


Example:


Input Format

The first line of input consists of the launch time in hh mm format separated by space.

The second line of input consists of the travel time for the missile in hh mm format separated by space.


Constraints

00<= hh <=23

00<= mm <=59


Output Format
Print the time at which the blast will occur and the spaceship will be destroyed.

#JAVA
import java.util.*;

public class CandidateCode {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr = new int[4];
arr[0] = sc.nextInt(); // departure time hh
arr[1] = sc.nextInt(); // departure time mm
arr[2] = sc.nextInt(); // travel time hh
arr[3] = sc.nextInt(); // travel time mm

float totalMinutesOfTravel = (arr[2] * 60) + arr[3];

for (float i = 1; i <= totalMinutesOfTravel; i++) {
arr[1] += 1;
if (arr[1] > 59) {
arr[1] = 0;
arr[0] += 1;
if (arr[0] > 23) {
arr[0] = 0;
}
}
}
System.out.println(String.format("%02d", arr[0]) + " " + String.format("%02d", arr[1]));
}
}

#PYTHON
departureTimeHH,departureTimeMM = input().split(" ")
TravelTimeHH,TravelTimeMM = input().split(" ")
departureTimeHH = int(departureTimeHH)
departureTimeMM = int(departureTimeMM)
TravelTimeHH = int(TravelTimeHH)
TravelTimeMM = int(TravelTimeMM)

totalMinutesOfTravel = (TravelTimeHH * 60) + TravelTimeMM

for x in range(1, totalMinutesOfTravel+1, 1):
departureTimeMM += 1
if departureTimeMM > 59:
departureTimeMM = 0
departureTimeHH += 1
if departureTimeHH > 23:
departureTimeHH = 0

print(f"{departureTimeHH:02d}", f"{departureTimeMM:02d}")

#C & C++
#include <stdio.h>

int main() {

    int departureTimeHH, departureTimeMM, TravelTimeHH, TravelTimeMM;
    scanf("%d %d", &departureTimeHH, &departureTimeMM);
    scanf("%d %d", &TravelTimeHH, &TravelTimeMM);
    
    int totalMinutesOfTravel = (TravelTimeHH * 60) + TravelTimeMM;
    
    for(int i=1; i<=totalMinutesOfTravel; i++){
        departureTimeMM += 1;
        if (departureTimeMM > 59){
            departureTimeMM = 0;
            departureTimeHH += 1;
            if (departureTimeHH > 23){
                departureTimeHH = 0;
            }
        }    
    }
    printf("%02d %02d", departureTimeHH, departureTimeMM);
    return 0;
}

#GO
func main() {
var departureTimeHH int
var departureTimeMM int
var travelTimeHH int
var travelTimeMM int

fmt.Scanf("%d %d", &departureTimeHH, &departureTimeMM)
fmt.Scanf("%d %d", &travelTimeHH, &travelTimeMM)

totalMinutesOfTravel := (travelTimeHH * 60) + travelTimeMM

for i := 1; i <= totalMinutesOfTravel; i++ {
departureTimeMM += 1
if departureTimeMM > 59 {
departureTimeMM = 0
departureTimeHH += 1
if departureTimeHH > 23 {
departureTimeHH = 0
}
}
}
fmt.Printf("%02d %02d", departureTimeHH, departureTimeMM)