[algogeeks] TIC TAC TOE
Given a 3X3 matrix , with 1's 0's and -1's ( 1 is player one 0 is player two -1 is none) how ll you find who is the winner / draw in a tic tac toe game in the most effiecient manner... -- With Regards, Balaji.S -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] TIC TAC TOE
Excuse me MR.balaji :P U got selected for Microsoft Redmond :P still preparing ? :P On Thu, Jul 28, 2011 at 6:01 AM, Balaji S balaji.ceg...@gmail.com wrote: Given a 3X3 matrix , with 1's 0's and -1's ( 1 is player one 0 is player two -1 is none) how ll you find who is the winner / draw in a tic tac toe game in the most effiecient manner... -- With Regards, Balaji.S -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Tic Tac Toe
i think u r missing the cases when o is winning and and countx counto then answer should be no On Fri, Jun 17, 2011 at 12:19 PM, KK kunalkapadi...@gmail.com wrote: https://www.spoj.pl/problems/TOE1/ For which test case does this program fail #includeiostream #includevector using namespace std; bool isWin(vector vectorchar v, char ch); int main() { vectorchar col(3); vector vectorchar v(3, col); int t, i, j; bool x, o; cin t; while(t--) { int counto = 0, countx = 0; for(i=0; i3; i++) for(j=0; j3; j++) { cin v[i][j]; if(v[i][j] == 'O') counto++; else if(v[i][j] == 'X') countx++; } //cout countx counto endl; if(! ( (countx == counto + 1) || (countx == counto) ) ) cout no endl; else { x = isWin(v, 'X'); o = isWin(v, 'O'); //cout x = x o = o endl; if(o x) cout no endl; else cout yes endl; } } return 0; } bool isWin(vector vectorchar v, char ch) { int i, j=0; for(i=0; i3; i++) { if(v[i][j] == v[i][j+1] v[i][j+1] == v[i][j+2] v[i] [j] == ch) return true; } i=0; for(j=0; j3; j++) { if(v[i][j] == v[i+1][j] v[i+1][j] == v[i+2][j] v[i] [j] == ch) return true; } if(v[0][0] == v[1][1] v[1][1] == v[2][2] v[0][0] == ch) return true; if(v[2][0] == v[1][1] v[1][1] == v[0][2] v[1][1] == ch) return true; return false; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] tic-tac-toe in a distributed environment
1) write a program to play tic-tac-toe in a distributed environment.The two players will be playing from different machines.. 2)write a program for real time video broadcasting by using RTP protocol? could u help me by sending the codes of any of those problem? -- DIPANKAR DUTTA M-TECH,Computer Science Engg. EC Dept,IIT ROORKEE Uttarakhand , India – 247667 --- website:http://people.iitr.ernet.in/shp/09535009/Website/index.html ph no-09045809987 Lab: 286454 email:dipan...@iitr.ernet.in email%3adipan...@iitr.ernet.in -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] tic tac toe
someone - going by the exact words of the problem description. Just see all the 8 possible winning combinations(row,column, 2 diagonals)...if anyone combination is filled by the same player..then there is a winner. I know it sounds trivial, correct me if i am wrong. On Sat, Jan 8, 2011 at 11:16 AM, divya sweetdivya@gmail.com wrote: Design an algorithm to figure out if someone has won in a game of tic- tac-toe. give O(N) soln -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] tic tac toe
Design an algorithm to figure out if someone has won in a game of tic- tac-toe. give O(N) soln -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.