Arithmetic... tock... tick... tock This question brought to you by a game I like to play when stuck in long phone meetings.

Given any two times from a 24 hour clock (from 00:00 to 23:59), how many valid mathematical equations can be generated with all of the times in between using only basic arithmetic operations?

Input: two four digit strings (no colon) representing valid times in a 24 hours cycle.

Examples:

For input=0000, 1300

03:26 produces: "0+3*2=6" and "03*2=6" etc.
11:10 produces quite a few, including: "1*1=1+0" and "1=1=1^0" and  "1=11^0" etc.
12:24 produces: "1/2=2/4" and "1=(2*2)/4" etc.


Valid operations are:


addition
subtraction
multiplication
division (floating point)
exponentiation
factorial


Other allowable symbols


Parentheses
Equal signs


Shortest code wins.

Notes


The goal is to find the number of valid expressions between two times, not the number of times that contain a valid expression.
The two times given as input are included in the range of times.
You may group the digits in any way possible, so "1223" can be "12 23" or " 1 2 23" or "1 223" etc. etc.
You may use as many parentheses as needed.
You may use more than one = sign. For instance, the time 11:11 has the valid expression 1=1=1=1.
If the first time occurs chronologically after the second time, the range of times should wrap as if crossing into the next day.
The numbers must remain in their original order- you may not re-order the digits.
When clustering numbers, zero's may absolutely be the front most digit, in which case, they are ignored ("0303" clustered as "03 03" is just two digits with the value of 3.)
You MAY NOT use the minus sign as unary negation. Therefore, "12:01" does NOT produce "1-2=-(01)", but DOES produce "1-2=0-1".
You MAY NOT add decimal points to digits. Therefore, "12:05" does NOT produce "1/2=0.5".
No chaining of factorials- a digit may be followed by at most one "!", no more, otherwise, many times would have infinite solutions. Ex: "5!" is valid but "5!!" is not valid.
Python3, 363 chars

Since no answer is given till today, I hand in what I got. Sadly, the try/except block is too fat, I didn't found a way to save chars there. It is really tricky with the nested loops there, not all can be done with list comprehensions I think, but maybe someone can tell me how.

However, I restricted the challenge myself to only use basic math '+-*/' and no parentheses.

a,b = input().split()
r=0
for time in [c for c in range(int(a),int(b)) if c/10%10&lt;6]:
 t,*ts='%04d'%time
 e=[t]
 for d in ts:
  e=[(n+o+d,n+d)[o==' '] for o in ' -+*/=' for n in e]
 for h in [g for g in [e.split('=') for e in e if '='in e] if len(g)&gt;1]:
  for k in h:
   try:
    if eval(h[0]) != eval(k):
     break
   except:
    break
  else:
   r+=1
print(r)


My full code (hope something explanatory) on this CodeGolf can be found on my pastebin.