Finding My Favorite Times I really like times that follow certain patterns. In particular, I like times where all the digits are the same, or all of the digits increase arithmetically by one from left to right. Further, I viscerally hate when people put letters in my times, so all of that AM/PM nonsense is dead to me. Thus, my favorite times are:

0000 0123 1111 1234 2222 2345


For my peace of mind, I need you to write me a single program that, given the current time as input, both: (A) if it is not now one of my favorite times, tells me both (i) how many minutes it's been since my last favorite time as well as (ii) how many minutes from now my next favorite time will occur; and (B) if it is now one of my favorite times, supplies a single 'signal value'.

Input

Your program should accept (by whatever method: function argument, stdin, command line argument, etc.) the current time, in any of the following formats:


A four-digit time as a string
An integer that can be zero-padded on the left to make a four-digit time as a string
A sequence of four (or fewer) integers, ordered such that the first integer in the sequence is the leftmost (significant) digit in the time input (e.g., 0951 could be validly represented as [0, 9, 5, 1] or [9, 5, 1])


Representing 0000 as a zero-length sequence is acceptable



In the case of a string input, it should only contain digits, no colons or other punctuation.  Inputs can be assumed to always be valid 24-hour times: HHMM, where 0 &lt;= HH &lt;= 23 and 0 &lt;= MM &lt;= 59. Disregard the possibility of a leap second.

Output

Your program must supply (function returns, stdout, etc. are all fine) either (A) or (B), as appropriate to whether or not the input value is a target time.

For (A):

Supply two numeric values in any sensible format, such as:


Single-string output with a suitable delimiter
Sequential integer/string outputs, e.g., bash printing two lines to stdout:  

49
34

Length-two ordered return values, such as a Python list, a C array, etc.: [49, 34]


The values can come in either order. For example, both of the following would be valid outputs for an input of 1200:

49 34
34 49


The order and separator must be the same for all input values, however!

For (B):

Produce any otherwise unattainable result. The same result must be produced for all six of the target times, however. Infinite loops are excluded.

Sample Inputs/Outputs

YAY!!! is used here as a demonstrative example and is not prescriptive.

Input      Output
------    --------
 0000      YAY!!!
 0020      20 63
 0105      65 18
 0122      82 1
 0123      YAY!!!
 0124      1 587
 0852      449 139
 1111      YAY!!!
 1113      2 81
 1200      49 34
 1234      YAY!!!
 1357      83 505
 1759      325 263
 1800      326 262
 1801      327 261
 2222      YAY!!!
 2244      22 61
 2345      YAY!!!
 2351      6 9


This is code-golf, so shortest code in bytes wins. Standard loopholes are disallowed.
JavaScript (ES6), 87 83 bytes

Saved 4 bytes thanks to @l4m2

Takes input as a string. Returns either 0 or a 2-element array.

t=&gt;[i=0,83,588,83,588,83,15].every(d=&gt;(k=t-(t/25&gt;&gt;2)*40)&gt;(j=i,i+=d))|i-k&amp;&amp;[k-j,i-k]


Test cases



let f =

t=&gt;[i=0,83,588,83,588,83,15].every(d=&gt;(k=t-(t/25&gt;&gt;2)*40)&gt;(j=i,i+=d))|i-k&amp;&amp;[k-j,i-k]

console.log(f('0000')) // YAY!!!
console.log(f('0020')) // 20 63
console.log(f('0105')) // 65 18
console.log(f('0122')) // 82 1
console.log(f('0123')) // YAY!!!
console.log(f('0124')) // 1 587
console.log(f('0852')) // 449 139
console.log(f('1111')) // YAY!!!
console.log(f('1113')) // 2 81
console.log(f('1200')) // 49 34
console.log(f('1234')) // YAY!!!
console.log(f('1357')) // 83 505
console.log(f('1759')) // 325 263
console.log(f('1800')) // 326 262
console.log(f('1801')) // 327 261
console.log(f('2222')) // YAY!!!
console.log(f('2244')) // 22 61
console.log(f('2345')) // YAY!!!
console.log(f('2351')) // 6 9




How?

We do not care about the result of the .every() loop. Provided that the input is valid, it will always be falsy. What we're really interested in is when we exit this loop.

We exit as soon as we find a favorite time i (expressed in minutes) which is greater than or equal to the reference time k (the input time t converted in minutes). We then return 0 if i == k or the 2 delays otherwise.