function c=lookup_solve_3(a)

	c=[ 0 0 0; 
		0 0 0; #initialising the matrix c, which keep counts of which switch is pressed how many times
		0 0 0];	

	for x=0:2
		if(a(x*3+1)==1)
			a=toggle(a,x*3+2);	#turns off all the lights in the top row
			c(x*3+2)++;
		endif
	endfor

	for x=0:2
		if(a(x*3+2)==1)
			a=toggle(a,x*3+3);	#turns off all the lights in the middle row
			c(x*3+3)++;
		endif
	endfor

	# now checks the situation of bottom row and with the help of table presses the switches in top row

	if(a(3,:)==[0 0 1])
		a=toggle(a,4);
		c(4)++;
		a=toggle(a,7);
		c(7)++;
	endif

	if(a(3,:)==[0 1 0])
		a=toggle(a,1);
		c(1)++;
		a=toggle(a,4);
		c(4)++;
		a=toggle(a,7);
		c(7)++;
	endif

	if(a(3,:)==[0 1 1])
		a=toggle(a,1);
		c(1)++;
	endif

	if(a(3,:)==[1 0 0])
		a=toggle(a,1);
		c(1)++;
		a=toggle(a,4);
		c(4)++;
	endif

	if(a(3,:)==[1 0 1])
		a=toggle(a,1);
		c(1)++;
		a=toggle(a,7);
		c(7)++;
	endif

	if(a(3,:)==[1 1 0])
		a=toggle(a,7);
		c(7)++;
	endif

	if(a(3,:)==[1 1 1])
		a=toggle(a,4);
		c(4)++;
	endif

	for x=0:2
		if(a(x*3+1)==1)
			a=toggle(a,x*3+2);	#repeat the same process, turns off the lights in toprow
			c(x*3+2)++;
		endif
	endfor

	for x=0:2
		if(a(x*3+2)==1)
			a=toggle(a,x*3+3);	# repeat the same process, turns off the lights in middle row
			c(x*3+3)++;
		endif
	endfor

	for x=1:9
		c(x)=rem(c(x),2);		# if the button is pressed even number of times then, no need of it to be pressed and if it is pressed odd number of times then it should be pressed only once.
	endfor

	return;

endfunction