Gokulakrishnan

Step counter

Sep 14th, 2020
818
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a = [1234, 4321]
  2. b = [2345, 3214]
  3.  
  4. step = 0
  5. for idx, _ in enumerate(a):
  6.     x = [int(i) for i in str(a[idx])]
  7.     y = [int(i) for i in str(b[idx])]
  8.     for i, _ in enumerate(x):
  9.         t1 = int(x[i])
  10.         t2 = int(y[i])
  11.         step += abs(t1-t2)
  12. print(step)
RAW Paste Data