Skip to content

Instantly share code, notes, and snippets.

@shashisp
Created August 29, 2015 17:45
Show Gist options
  • Save shashisp/7823e36a14ca7a66f575 to your computer and use it in GitHub Desktop.
Save shashisp/7823e36a14ca7a66f575 to your computer and use it in GitHub Desktop.
m, n = raw_input().split()
m = int(m)
n = int(n)
e_list = []
e_list = raw_input().split()
combination = [(e_list[i],e_list[j]) for i in range(len(e_list)) for j in range(i+1, len(e_list))]
difference = []
for e in combination:
difference.append(abs(int(e[0]) - int(e[1])))
count = 0
for d in difference:
if d == n:
count+=1
print count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment