Given two positive integers num1 and num2, the task is to find the sum of the two numbers on a 12 hour clock rather than a number line.
Example 1:
Input: num1 = 5, num2 = 7
Output: 0
Explaination: 5+7=12, which in 12 hour 
clock format is 0.
Example 2:
Input: num1 = 3, num2 = 5
Output: 8
Explaination: 3+5=8, which is 12 hour 
format is intact.
Your Task:
You do not need to read input or print anythign. Your task is to complete the function clockSum() which takes num1 and num2 as input parameters and returns the 12 hour clock format addition of the numbers.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ num1, num2 ≤ 50

Source: geeksforgeeks | Difficulty: EASY
Tags: Number theory

Mathematics

Starter code: #User function Template for python3



class Solution:

    def clockSum(self, num1, num2):

        # code here

Solutions:
class Solution:

	def clockSum(self, num1, num2):
		s = num1 + num2
		if s == 12:
			return 0
		elif s < 12:
			return s
		else:
			return s % 12


class Solution:

	def clockSum(self, num1, num2):
		s = num1 + num2
		p = s % 12
		return p


class Solution:

	def clockSum(self, num1, num2):
		return (num1 + num2) % 12


class Solution:

	def clockSum(self, num1, num2):
		s = num1 + num2
		S = s % 12
		return S


class Solution:

	def clockSum(self, num1, num2):
		sum = num1 + num2
		while sum >= 12:
			sum = sum - 12
		return sum


class Solution:

	def clockSum(self, num1, num2):
		return (num1 + num2) % 12 if num1 + num2 >= 12 else num1 + num2


class Solution:

	def clockSum(self, num1, num2):
		t = num1 + num2
		if t == 12 or t == 24:
			return 0
		elif t < 12:
			return t
		elif t > 12:
			t1 = t % 12
			return t1


class Solution:

	def clockSum(self, num1, num2):
		k = num1 + num2
		if k < 12:
			return k
		else:
			return k - int(k / 12) * 12


class Solution:

	def clockSum(self, num1, num2):
		a = num1 + num2
		if a < 12:
			return a
		if a >= 12:
			while a >= 12:
				a -= 12
			return a


class Solution:

	def clockSum(self, num1, num2):
		t = num1 + num2
		if t < 12:
			return t
		elif t >= 12:
			return t % 12


class Solution:

	def clockSum(self, num1, num2):
		x = (num1 + num2) // 12
		if (num1 + num2) % 12 == 0:
			return 0
		elif num1 + num2 < 12:
			return num1 + num2
		elif num1 + num2 > 12 * x and num1 + num2 * (x + 1):
			return num1 + num2 - 12 * x


class Solution:

	def clockSum(self, num1, num2):
		num = num1 + num2
		i = 12
		if num >= 12:
			i = num // i
			return num - 12 * i
		return num


class Solution:

	def clockSum(self, num1, num2):
		res = num1 + num2
		if res % 12 == 0:
			return 0
		elif res < 12:
			return res
		elif res > 12:
			res2 = res % 12
			return res2


class Solution:

	def clockSum(self, num1, num2):
		ans = num1 + num2
		while ans >= 12:
			ans = ans - 12
		return ans


class Solution:

	def clockSum(self, num1, num2):
		if num1 + num2 < 12:
			return num1 + num2
		elif num1 + num2 > 12 and num1 + num2 < 24:
			return num1 + num2 - 12
		elif num1 + num2 > 24:
			return (num1 + num2) % 12
		elif num1 + num2 == 24:
			return 0
		else:
			return 0


class Solution:

	def clockSum(self, num1, num2):
		su = num1 + num2
		result = su % 12
		return result


class Solution:

	def clockSum(self, num1, num2):
		num1 = int(num1)
		num2 = int(num2)
		sum = (num1 + num2) % 12
		return sum


class Solution:

	def clockSum(self, num1, num2):
		rem = num1 + num2
		if rem >= 12:
			while rem >= 12:
				rem = rem - 12
		return rem


class Solution:

	def clockSum(self, num1, num2):
		sum1 = num1 + num2
		if sum1 < 12:
			return sum1
		return sum1 % 12


class Solution:

	def clockSum(self, num1, num2):
		if num1 + num2 <= 11:
			return num1 + num2
		elif num1 + num2 == 12:
			return 0
		return (num1 + num2) % 12