def solution(S, T): sh, sm, ss = map(int, S.split(":")) th, tm, ts = map(int, T.split(":")) cnt = 0 while True: ssh, ssm, sss = str(sh), str(sm), str(ss) if sh < 10: ssh = '0' + str(sh) if sm < 10: ssm = '0' + str(sm) if ss < 10: sss = '0' + str(ss) merge = ssh + ssm + sss if len(set(merge)) <= 2: cnt += 1 if th == sh and sm == tm and ss == ts: break ss += 1 if ss == 60: ss = 0 sm += 1 if sm == 60: sm = 0 sh += 1 return cnt print(solution("00:00:59", "00:01:00")) print(solution("22:22:21", "22:22:23")) print(solution("15:15:00", "15:15:12")) print(solution("00:00:00", "23:59:59")) print(solution("00:00:00", "00:00:11"))
1
3
1
504
12