#!/bin/ruby require 'json' require 'stringio' # Complete the lagDuration function below. def lagDuration(h1, m1, h2, m2, k) # Return an integer denoting the duration of time in minutes by which the clock has been lagging. hm1 = h1 * 60 + m1 hm2 = h2 * 60 + m2 hme = hm1 + k * 60 hme - hm2 end fptr = File.open(ENV['OUTPUT_PATH'], 'w') q = gets.to_i q.times do |q_itr| h1M1H2M2 = gets.rstrip.split h1 = h1M1H2M2[0].to_i m1 = h1M1H2M2[1].to_i h2 = h1M1H2M2[2].to_i m2 = h1M1H2M2[3].to_i k = gets.to_i result = lagDuration h1, m1, h2, m2, k fptr.write result fptr.write "\n" end fptr.close()