fork download
  1. x = [1, 5, 2, 4, 1]
  2. k = 3
  3. seen = set()
  4. found = False
  5.  
  6. for num in x:
  7. if (num + k) in seen:
  8. print(f"Difference found: {num + k} - {num} = {k}")
  9. found = True
  10.  
  11. seen.add(num)
  12.  
  13. if not found:
  14. print("No difference found")
Success #stdin #stdout 0.07s 14060KB
stdin
Standard input is empty
stdout
Difference found: 5 - 2 = 3
Difference found: 4 - 1 = 3