Calculate moves in random dialer

Imagine you want to calculate the minimum amount of time it takes to type a random code, for example, ‘3428’ in a random dialer, for example, ‘523789614’ (ASCII art is coming).

[5][2][3]
[7][8][9]
[6][1][4]

  • It takes 0 seconds to move your finger to the first key, and it takes 0 seconds to press the key where you finger is located any number of times.
  • You can move your finger from one location to any adjacent key in one second.
  • Moving to a non-adjacent key is done as a series of moves to adjacent keys.