Predict a Collision: Will the robber get away?

Python 3, 29 bytes

lambda s,p,a:(a-2*s)**2<8*a*p

Try it online!


The cop's position at time t is st.

The robber's position at time t is a(t)(t+1)/2 + p.

The signed distance from the cop to the robber is (a/2)t^2 + (a/2-s)t + p.

It never reaches zero if the discriminant is negative, the discriminant being (a/2 - s)^2 - 4(a/2)(p) = [(a-2s)^2-8ap]/4, which has the same sign as (a-2s)^2-8ap.

Japt, 13 bytes

²/W-V-U<o0W x

Test it online!


U, V, and W are the implicit inputs. First, with Uo0W we create the range [0, W, 2*W, ...] until it reaches U. x then sums this, which gives how far the robber travels before reaching cop speed. We'll call this r.

Now, how far does the cop travel in this time? We can calculate this using U * (U // W - 1), which can be rearranged to (U * U) // W - U. We'll call this c.

Now for the final step: does the robber get away? All we need to do here is check if c < r + V, or rearranged, c - V < r.

Cubically, 61 bytes


Try it online! For this to work in TIO, you may need to replace & with &1 due to a bug in the interpreter.

This is a shameless port of Leaky Nun's answer. Input is in the form a s p, where a is robber's acceleration, s is cop's speed, and p is robber's position.

If the acceleration is too high, this will fail. I don't know how high of an acceleration this program will support, but I know it isn't any higher than 1260. The limiting factor is that it stores the acceleration in the cube and checks if the cube is solved by checking only if the top face's sum is 0 (an incomplete check). It seems to work for acceleration = 50, but I haven't tested to see how high it can get.

How it works

$:7                             Store the first number in the notepad
   (                )6          Loop until notepad is 0
    U1R3U1F3D2                  Rotate the cube a certain way
              *1-1/1            Subtract 1 from the notepad

+7                              Add first input to the notepad
  $-77                          Subtract second input from the notepad twice
      *6                        Multiply the notepad by itself (square it)

$                               Get next input
 (                            ) Loop indefinitely
  -77777777                     Subtract third input 8 times
           D2F1U3R1U3           "Unrotate" the cube
                     !0{     }  If the top face is 0
                        <0        Check if notepad < 0, store in notepad
                          %6      Output notepad as number
                            &     End the program