Someone is asked to perform the following operations on a randomly chosen number between 1 and 10.
 
Step 1: Double the chosen number.
 
Step 2: Add a number K(even number given as input) to the number obtained after Step1
Step 3: Divide the obtained number in Step 2 by 2.
Step 4: Now subtract the obtained number in Step 3 with the original chosen number N
Your task is to find the answer obtained at the end of Step 4 ,i.e,at the end of all the mentioned operations performed on the number chosen.
 
Example 1:
Input:
K = 10
Output:
5
Explanation:
Suppose chosen number is 3, then after
Step 1: number=6
Step 2: number=6+10=16
Step 3: number=16/2=8
Step 4: 8-3=5(required answer).
No matter what number Rohan chooses
the answer always comes to be 5.
Example 2:
Input:
K = 2
Output:
1
Explanation:
Suppose chosen number is 8, then after
Step 1: number=16
Step 2: number=16+2=18
Step 3: number=18/2=9
Step 4: 9-8=1(required answer).
No matter what number Rohan chooses
the answer always comes to be 1.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function mindGame() which takes an Integer K as input and returns the answer.
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
2 <= K <= 10^{8}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def mindGame(self, K):

        # code here

Solutions:
class Solution:

	def mindGame(self, K):
		return K // 2


class Solution:

	def mindGame(self, K):
		n = 8
		return (n + n + K) // 2 - n


class Solution:

	def mindGame(self, K):
		z = 5
		n = z * 2
		n = n + K
		n = n // 2
		n = n - z
		return n


class Solution:

	def mindGame(self, K):
		a = 4
		c = (a + K) // 2
		d = c - 2
		return d


class Solution:

	def mindGame(self, K):
		m = K * 2
		l = m + K
		n = l // 2
		N = n - K
		return N


class Solution:

	def mindGame(self, K):
		n = 4
		a = n * 2
		b = a + K
		c = b / 2
		d = c - n
		return int(d)


import random

class Solution:

	def mindGame(self, K):
		return K // 2


import random as R

class Solution:

	def mindGame(self, K):
		a = R.randint(1, 9)
		return (2 * a + K) // 2 - a


class Solution:

	def mindGame(self, K):
		select = 3
		random = select
		random = random * 2
		random += K
		random //= 2
		random -= select
		return random


class Solution:

	def mindGame(self, K):
		nums = t + t
		nums = nums + K
		nums = nums // 2
		nums = nums - t
		return nums


class Solution:

	def mindGame(self, k):
		n = 3
		f = n * 2
		m = f + k
		l = m // 2
		p = l - n
		return p


class Solution:

	def mindGame(self, K):
		n = 3
		nn = n * 2
		nnk = nn + K
		s = nnk // 2
		res = s - n
		return res


class Solution:

	def mindGame(self, k):
		import random
		n = random.randint(1, 10)
		p = (2 * n + k) // 2 - n
		return p


import random

class Solution:

	def mindGame(self, K):
		a = random.randint(1, 10)
		s = a * 2
		s += K
		s /= 2
		s -= a
		return int(s)


import random as rd

class Solution:

	def mindGame(self, K):
		a = rd.randint(1, 10)
		s1 = a * 2
		s2 = s1 + K
		s3 = int(s2 / 2)
		s4 = s3 - a
		return s4


class Solution:

	def mindGame(self, K):
		return int(K / 2)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		K = int(input())
		ob = Solution()
		print(ob.mindGame(K))


import random

class Solution:

	def mindGame(self, K):
		n = random.randint(1, 11)
		r = 2 * n
		r = K + r
		r = r // 2
		r = r - n
		return r
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		K = int(input())
		ob = Solution()
		print(ob.mindGame(K))


class Solution:

	def mindGame(self, K):
		k = 3
		k1 = k * 2
		k1 = K + k1
		k1 = k1 // 2
		s = k1 - k
		return s
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		K = int(input())
		ob = Solution()
		print(ob.mindGame(K))


class Solution:

	def mindGame(self, k):
		n = 3
		o = 2 * n + k
		o = o // 2
		o = o - n
		return o
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		K = int(input())
		ob = Solution()
		print(ob.mindGame(K))


class Solution:

	def mindGame(self, K):
		i = 10
		m = 2 * i
		n = m + K
		t = n / 2
		r = int(t - i)
		return r
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		K = int(input())
		ob = Solution()
		print(ob.mindGame(K))


class Solution:

	def mindGame(self, K):
		n = 6
		d = n + K
		e = d // 2
		return e - 3
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		K = int(input())
		ob = Solution()
		print(ob.mindGame(K))


import random

class Solution:

	def mindGame(self, K):
		rand = random.randint(1, 10)
		return int((rand * 2 + K) / 2 - rand)


import random

class Solution:

	def mindGame(self, K):
		num = int(10 * random.random())
		x = num
		num *= 2
		num += K
		num = num // 2
		num = num - x
		return num


class Solution:

	def mindGame(self, K):
		temp = K
		K = K * 2
		K = K + temp
		K = K / 2
		K = K - temp
		return int(K)


class Solution:

	def mindGame(self, K):
		temp = K
		a = 2 * K + temp
		b = a // 2
		b = b - temp
		return b


import random

class Solution:

	def mindGame(self, K):
		n = random.randint(1, 10)
		return (2 * n + K) // 2 - n


class Solution:

	def mindGame(self, K):
		import random
		l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
		n = random.choice(l)
		r = n
		n = n * 2
		n = n + K
		n = n / 2
		n = abs(int(r - n))
		return n


from random import randint

class Solution:

	def mindGame(self, K):
		return K // 2


class Solution:

	def mindGame(self, K):
		num = (2 + K) // 2
		return num - 1


import random

class Solution:

	def mindGame(self, K):
		a = random.randint(1, 10)
		b = 2 * a
		c = b + K
		d = c / 2
		e = d - a
		return int(e)


import random

class Solution:

	def mindGame(self, K):
		n = random.randint(0, K)
		f = 2 * n + K
		l = f / 2
		h = int(l - n)
		return h


import random as R

class Solution:

	def mindGame(self, k):
		N = R.randrange(1, 11)
		n = N
		n = n * 2
		n = n + k
		n = n // 2
		n = n - N
		return n


import random

class Solution:

	def mindGame(self, K):
		random_num1 = random.randint(1, 10)
		random_num = random_num1 * 2
		random_num = random_num + K
		random_num = random_num // 2
		random_num = random_num - random_num1
		return random_num


import random

class Solution:

	def mindGame(self, K):
		list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
		a = random.choice(list1)
		b = a * 2
		c = b + K
		d = c // 2
		e = d - a
		return e


class Solution:

	def mindGame(self, K):
		return K >> 1


import random

class Solution:

	def mindGame(self, K):
		num = int(random.random())
		num2 = num + K
		num2 = num2 / 2
		num2 = num2 - num
		return int(num2)


class Solution:

	def mindGame(self, K):
		st1 = t * 2
		st2 = st1 + K
		st3 = st2 / 2
		st4 = st3 - t
		return int(st4)


class Solution:

	def mindGame(self, K):
		a = t + t + K
		b = a / 2
		c = b - t
		return int(c)


import random

class Solution:

	def mindGame(self, K):
		rando = random.randrange(1, 10)
		number = rando * 2
		number += K
		number /= 2
		number = int(number)
		number -= rando
		return number


import random

class Solution:

	def mindGame(self, K):
		n1 = random.randint(1, 10)
		n2 = n1 * 2
		n3 = n2 + K
		n4 = n3 / 2
		final = n4 - n1
		return int(final)


class Solution:

	def mindGame(self, K):
		import random
		rn = random.randint(1, 11)
		S1 = 2 * rn
		S2 = S1 + K
		S3 = S2 / 2
		S4 = S3 - rn
		return int(S4)


class Solution:

	def mindGame(self, K):
		N = 2
		n = N * 2
		h = n + K
		j = int(h / 2)
		k = j - N
		return k


class Solution:

	def mindGame(self, K):
		n = 5
		n1 = n * 2
		n2 = n1 + K
		n3 = n2 // 2
		n4 = n3 - n
		return n4