Given two fractions a/b and c/d, compare them and print the larger of the two.
Example 1:
Input:
s = "5/6, 11/45"
Output: 5/6
Explanation:
5/6=0.8333... and 11/45=0.2444.... 
Clearly, 5/6 is greater, so we output it.
 
Example 2:
Input:
s = "8/1, 8/1"
Output: equal
Explanation:
We can see that both the fractions are same, 
so they are equal.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function compareFrac() which takes the string s as input parameters and returns the fraction that is greater. If they are equal, then return "equal".
Expected Time Complexity: O(len|s|)
Expected Auxiliary Space: O(1)
 
Constraints:
0<=a,c<=1000
1<=b,d<=1000

Difficulty: EASY
Tags: Number theory

Mathematics
Expected Time Complexity: O(len|s|)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3





class Solution:

    def compareFrac (self, s):

        

        # code here

        



Solutions:
class Solution:

	def compareFrac(self, s):
		a = ''
		for i in range(len(s)):
			if s[i] == '/':
				break
			else:
				a = a + s[i]
		b = ''
		for j in range(i + 1, len(s)):
			if s[j] == ',':
				break
			b = b + s[j]
		c = ''
		for k in range(j + 2, len(s)):
			if s[k] == '/':
				break
			c = c + s[k]
		d = ''
		for l in range(k + 1, len(s)):
			d = d + s[l]
		m = int(a) / int(b)
		n = int(c) / int(d)
		if m > n:
			return str(a) + '/' + str(b)
		elif m < n:
			return str(c) + '/' + str(d)
		else:
			return 'equal'


class Solution:

	def compareFrac(self, s):
		s = s.split(',')
		s[1] = s[1].replace(' ', '')
		x1 = s[0].split('/')
		x2 = s[1].split('/')
		ans1 = int(x1[0]) / int(x1[1])
		ans2 = int(x2[0]) / int(x2[1])
		if ans1 == ans2:
			return 'equal'
		if ans1 > ans2:
			return x1[0] + '/' + x1[1]
		return x2[0] + '/' + x2[1]


import re

class Solution:

	def compareFrac(self, s):
		pattern = '(\\d+)/(\\d+)'
		fractions = re.findall(pattern, s)
		frac1 = float(fractions[0][0]) / float(fractions[0][1])
		frac2 = float(fractions[1][0]) / float(fractions[1][1])
		if frac1 > frac2:
			return '{}'.format(fractions[0][0] + '/' + fractions[0][1])
		elif frac1 == frac2:
			return 'equal'
		else:
			return '{}'.format(fractions[1][0] + '/' + fractions[1][1])


import re

class Solution:

	def compareFrac(self, s):
		x = re.findall('\\d+\\/\\d+', s)
		res = str(x[0]).split('/')
		ans = str(x[1]).split('/')
		a = int(res[0]) / int(res[1])
		b = int(ans[0]) / int(ans[1])
		if a > b:
			return x[0]
		elif a == b:
			return 'equal'
		return x[1]


class Solution:

	def compareFrac(self, s):
		(f1, f2) = s.replace(' ', '').split(',')
		if eval(f1) > eval(f2):
			return f1
		if eval(f1) < eval(f2):
			return f2
		return 'equal'


import re

class Solution:

	def compareFrac(self, s):
		k = re.split(',', s)
		a1 = re.split('/', k[0])
		a2 = re.split('/', k[1])
		if int(a1[0]) / int(a1[1]) == int(a2[0]) / int(a2[1]):
			return 'equal'
		elif int(a1[0]) / int(a1[1]) > int(a2[0]) / int(a2[1]):
			return k[0]
		else:
			return k[1][1:]


class Solution:

	def compareFrac(self, s):
		lst = s.split(',')
		n1 = eval(lst[0])
		n2 = eval(lst[1])
		if n1 > n2:
			return lst[0].strip()
		elif n2 > n1:
			return lst[1].strip()
		return 'equal'


class Solution:

	def compareFrac(self, s):
		s = s.replace(' ', '')
		s = s.split(',')
		a = []
		for v in s:
			v = v.split('/')
			a.append(int(v[0]) / int(v[1]))
		if a[0] == a[1]:
			return 'equal'
		return s[a.index(max(a))]


class Solution:

	def compareFrac(self, s):
		l = list(s.split(','))
		a = list(l[0].split('/'))
		b = list(l[1].split('/'))
		div1 = int(a[0]) / int(a[1])
		div2 = int(b[0]) / int(b[1])
		if div1 == div2:
			return 'equal'
		elif div1 > div2:
			return l[0]
		else:
			return l[1][1:]


import re

class Solution:

	def compareFrac(self, s):
		l = []
		pattern = re.compile('\\d+')
		pat1 = pattern.findall(s)
		for i in pat1:
			l.append(i)
		m = int(l[0]) / int(l[1])
		n = int(l[2]) / int(l[3])
		if m == n:
			return 'equal'
		elif m > n:
			return l[0] + '/' + l[1]
		else:
			return l[2] + '/' + l[3]


from fractions import Fraction as f

class Solution:

	def compareFrac(self, s):
		x = s.split(', ')
		y = f(x[0])
		z = f(x[1])
		if y > z:
			return x[0]
		elif z > y:
			return x[1]
		else:
			return 'equal'


class Solution:

	def compareFrac(self, s):
		s = s.split(',')
		s[1] = s[1].replace(' ', '')
		x1 = s[0].split('/')
		x2 = s[1].split('/')
		ans1 = int(x1[0]) / int(x1[1])
		ans2 = int(x2[0]) / int(x2[1])
		if ans1 == ans2:
			return 'equal'
		if ans1 > ans2:
			return x1[0] + '/' + x1[1]
		return x2[0] + '/' + x2[1]
if __name__ == '__main__':
	ob = Solution()
	t = int(input())
	for _ in range(t):
		s = input()
		print(ob.compareFrac(s))


class Solution:

	def compareFrac(self, s):
		l = s.split(', ')
		g = l[0].split('/')
		t = l[1].split('/')
		r = int(g[0]) / int(g[1])
		f = int(t[0]) / int(t[1])
		if r > f:
			return l[0]
		elif f > r:
			return l[1]
		return 'equal'
if __name__ == '__main__':
	ob = Solution()
	t = int(input())
	for _ in range(t):
		s = input()
		print(ob.compareFrac(s))


import re

class Solution:

	def compareFrac(self, s):
		pat = '\\b(\\d+)\\/(\\d+)\\b'
		ris = re.findall(pat, s)
		x = float(ris[0][0]) / float(ris[0][1])
		y = float(ris[1][0]) / float(ris[1][1])
		if x == y:
			return 'equal'
		if x > y:
			return ris[0][0] + '/' + ris[0][1]
		return ris[1][0] + '/' + ris[1][1]


import re

class Solution:

	def compareFrac(self, s):
		pat = '\\b(\\d+)\\/(\\d+)\\b'
		ris = list()
		for l in re.finditer(pat, s):
			ris.append((l.group(), float(l.group(1)) / float(l.group(2))))
		if ris[0][1] == ris[1][1]:
			return 'equal'
		if ris[0][1] > ris[1][1]:
			return ris[0][0]
		return ris[1][0]


class Solution:

	def compareFrac(self, s):
		l = s.split(',')
		p = eval(l[0])
		q = eval(l[1])
		if p > q:
			return l[0]
		if p == q:
			return 'equal'
		p = l[1].replace(' ', '', 1)
		return p


class Solution:

	def compareFrac(self, s):
		KEK = s.split(', ')
		a = KEK[0]
		b = KEK[1]
		A = a.split('/')
		B = b.split('/')
		c = int(A[0])
		d = int(A[1])
		C = int(B[0])
		D = int(B[1])
		if c / d == C / D:
			return 'equal'
		elif c / d > C / D:
			return str(c) + '/' + str(d)
		elif c / d < C / D:
			return str(C) + '/' + str(D)


class Solution:

	def compareFrac(self, s):
		num1 = s[:s.find('/')]
		den1 = s[s.find('/') + 1:s.find(',')]
		num2 = s[s.find(' ') + 1:s.rfind('/')]
		den2 = s[s.rfind('/') + 1:]
		fraction1 = int(num1) / int(den1)
		fraction2 = int(num2) / int(den2)
		if fraction1 > fraction2:
			return s[:s.find(',')]
		elif fraction1 == fraction2:
			return 'equal'
		else:
			return s[s.find(' ') + 1:]


class Solution:

	def compareFrac(self, s):
		l = []
		l = s.split(',')
		l0 = ()
		l1 = ()
		l0 = l[0].split('/')
		l1 = l[1].split('/')
		if int(l0[0]) / int(l0[1]) > int(l1[0]) / int(l1[1]):
			return l[0]
		elif int(l0[0]) / int(l0[1]) < int(l1[0]) / int(l1[1]):
			return str(int(l1[0])) + '/' + l1[1]
		else:
			return 'equal'