fork(1) download
  1. count = 0
  2. a = [1,5,3,4,2]
  3. k = 2
  4. for i in range(len(a) - 1):
  5. for j in range(i + 1, len(a)):
  6. if a[i] - a[j] == k:
  7. count += 1
  8. print("i = " + str(i))
  9. print("j = " + str(j))
  10. print ("count = " + str(count))
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
i = 1
j = 2
i = 3
j = 4
count = 2