human
What is a code to find minimum moves to reach target on an infinite line and the other steps required given the following:
Find minimum moves to reach target on an infinite line | Python 3 program to find minimum moves to reach target if we can move i steps in i - th move ..
Handling negatives by symmetry.
Keep moving while sum is smaller or difference is odd ..
Driver code"
Solution in Python:
assistant
#Here is code to find minimum moves to reach target on an infinite line and the other steps required.
 def reachTarget ( target ) :
	target = abs ( target )
	sum = 0
	step = 0
	while ( sum < target or ( sum - target ) % 2 != 0 ) :
		step = step + 1
		sum = sum + step
	return step
target = 5
print ( reachTarget ( target ) )