human
Print all triplets in sorted array that form AP | Function to print all triplets in given sorted array that forms AP.
Use hash to find if there is a previous element with difference equal to arr [ j ] - arr [ i ].
Driver code"
Solution in Python:

=====
Write me a code to print all triplets in sorted array that form AP and the other steps required?
assistant
#Here is code to print all triplets in sorted array that form AP and the other steps required.
 def printAllAPTriplets ( arr , n ) :
	s = [ ] ;
	for i in range ( 0 , n - 1 ) :
		for j in range ( i + 1 , n ) :
			diff = arr [ j ] - arr [ i ] ;
			if ( ( arr [ i ] - diff ) in arr ) :
				print ( " { } ▁ { } ▁ { } " . format ( ( arr [ i ] - diff ) , arr [ i ] , arr [ j ] ) , end =   " " ) ;
	s . append ( arr [ i ] ) ;
arr = [ 2 , 6 , 9 , 12 , 17 , 22 , 31 , 32 , 35 , 42 ] ;
n = len ( arr ) ;
printAllAPTriplets ( arr , n ) ;