Am I over the speed limit?

Python 2, 71 bytes

m,s=input()
for c in s.split('=')[:-1]:s=float(c or s);m-=1/s
print m<0

Try it online!

Python's dynamic type system can take quite some abuse.

Splitting the input string s.split('=') turns k equal signs into k-1 empty-string list elements (except at the end, where one must be cut off). For example,

"3.0===20====".split('=')[:-1] == ['3.0', '', '', '20', '', '', '']

The code iterates over these elements, updating the current speed s each time it sees a number. The update is done as s=float(c or s), where if c is a nonempty string, we get float(c), and otherwise c or s evaluates to s, where float(s) just keeps s. Note that c is a string and s is a number, but Python doesn't require doesn't require consistent input types, and float accepts either.

Note also that the variable s storing the speed is the same one as taking the input string. The string is evaluated when the loop begins, and changing it within the loop doesn't change what is iterated over. So, the same variable can be reused to save on an initialization. The first loop always has c as a number, so s=float(c or s) doesn't care about s's initial role as a string.

Each iteration subtracts the current speed from the allowance, which starts as the speed limit. At the end, the speed limit has been violated if this falls below 0.


Python 3, 79 bytes

import re;g=re.sub
lambda m,s:eval(g('=','-~',g('([^=]+)',r'0+1/\1*',s))+'0')>m

Try it online!

For example, the input 3.0==========20=== is converted to the string

0+1/3.0*-~-~-~-~-~-~-~-~-~-~0+1/20*-~-~-~0 

and evaluated, and the result is compared to the input speed. Each -~ increments by 1. I'm new to regexes, so perhaps there's a better way, like making both substitutions at once. Thanks to Jonathan Allan for pointing out how to match on all but the = character.


GNU C, 128 bytes

#import<stdlib.h>
f(float t,char*r){float l,s=0;for(;*r;){for(l=atof(r);*(++r)-61;);for(;*r++==61;)s+=1/l;--r;}return t<s-.001;}

Handles non-integer speed limits also. #import<stdlib.h> is needed for the compiler not to assume that atof() returns an int.

t<s-.001 is needed to make the exact speed limit test case to work, otherwise rounding errors cause it to think you were speeding. Of course, now if the time is 1.4999 instead of 1.5, it doesn't consider that speeding. I hope that's okay.

Try it online!