# see https://www.codewars.com/kata/5340298112fa30e786000688/solutions/python

from TestFunction import Test

def twos_difference(lst): 
  if lst == []: return []
  lst = [x for x in sorted(lst)]
  rv = []
  for i in range(len(lst)):
    for j in range(len(lst)):
      if lst[i] - lst[j] == 2:
        rv.append((lst[j], lst[i]))
  return rv

test = Test(None)
test.assert_equals(twos_difference([1, 2, 3, 4]), [(1, 3), (2, 4)])
test.assert_equals(twos_difference([1, 3, 4, 6]), [(1, 3), (4, 6)])
test.assert_equals(twos_difference([0, 3, 1, 4]), [(1, 3)])
test.assert_equals(twos_difference([4, 1, 2, 3]), [(1, 3), (2, 4)])
test.assert_equals(twos_difference([6, 3, 4, 1, 5]), [(1, 3), (3, 5), (4, 6)])
test.assert_equals(twos_difference([3, 1, 6, 4]), [(1, 3), (4, 6)])
test.assert_equals(twos_difference([1, 3, 5, 6, 8, 10, 15, 32, 12, 14, 56]), [(1, 3), (3, 5), (6, 8), (8, 10), (10, 12), (12, 14)])
test.assert_equals(twos_difference([1, 4, 7, 10]), [])
test.assert_equals(twos_difference([]), [])