Programming contests

DEIK Regionális Programozó Csapatverseny, gyakorló feladatsor

October 26, 2012 8:00 PM – November 23, 2012 12:00 AM

Chimes

In the village of Bellstown, a new clock system has been installed into the old church’s tower. The new clock makes the bell chime every hour on the hour, exactly as many times as the small clock hand shows (e.g., two times at 2 o’clock as well as at 14 o’clock). Additionally, the bell chimes one time at quarter past every hour, two times at half past every hour and one time at quarter to every hour of every day and night. Since the new clock system was installed, tourists have been continuously asking the old bellman how many times the bell chimes between two times. The bellman needs your help to answer these questions as fast as possible.

Your task is to write a program that computes the number of bell chimes between two times of a day.

Input Specification

The input contains multiple test cases. Each test case consists of a single line that contains two times separated by a space. The form of a time is HH:MM, where HH is the hour given either by one or two digits ranging from 0 to 24, and MM is the minute given exactly by two digits ranging from 0 to 59. The first time of a day is 0:00 and the last time of a day is 24:00. Both times are within a day, and the first time (start time) is always less than the second time (end time).

Output Specification

Output for each test case is a line with a single integer, which is the number of bell chimes between the two given times, the start time exclusive and the end time inclusive.

Sample Input

  1. 0:15 1:00
  2. 14:30 14:45
download as text file

Output for Sample Input

  1. 4
  2. 1
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019