Тёмный

Tic Tac Toe winning logic for programmers 

Hitesh Choudhary
Подписаться 940 тыс.
Просмотров 64 тыс.
50% 1

Опубликовано:

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 183   
@abhinavchauhangujjar6456
@abhinavchauhangujjar6456 5 лет назад
And Sir, we don't have to check anything until any of zero or cross move at least 3 times, in other words at least 5 box should be filled or 4 moves should pass before doing any checking, and i observed that first mover can play at most 5 times and second mover can play at most 4 times, can we use that fact for efficiency.
@SichuunduW762
@SichuunduW762 4 года назад
hello! look at this.making use of a two dimensional array,write the code that permits two players to play a game of tic tac toe (also known as noughts and crosses). use 0 to represent an empty square.1 to represent a cross, and 2 to represent a nought. this requires implementing several algorithms; asking for the user`s input and placing their symbol looping between two different players alternating the symbol checking for a win. must be done in java. show the pseudocode and the java code
@tejaswipandava
@tejaswipandava 3 года назад
Ya, I was also thinking the same thing. The first thing we need to do is have an if the check for the total no of turns in case they exceed 4. if they exceed we can start our logic. Also, one more idea I was getting is instead of having 8 checks (row, column, and diagonals) why not reduce the check. I mean when ever a user selects a value (say position 8) let's check all possible combinations with that position that would reduce the checks to max 3. (positions [0,4,8],[2,5,8][6,7,8])
@sujithsaikalakonda4863
@sujithsaikalakonda4863 2 года назад
I absolutely loved your explanation sir. I thought of making this game from last 5 months, but I couldn't make it. I decided to make a game till the end of 2021. So I sat at 11:30pm on 31st dec 2021, I saw the TITLE of the video is interesting and started watching, It was so impressive and I started making own cases and started writing code. I divided the progress of game into small parts/tasks and Finally at 1:30 I completed. However the code is very big. But the game is just with if else and loops. I was motivated a lot with this video and just wanted to share. Thank you very very very very much sir. And make some more logical videos like this. STAY SAFE.
@anshpng
@anshpng 5 лет назад
We can make the code more efficient by creating a 3x3 matrix from a 2D array and then running 2 loops to check conditions for horizontal and vertical boxes.
@samantasunanda
@samantasunanda Год назад
Even your comment hold O(n^2) time complexity, writing small code makes it efficient?
@supentamu3073
@supentamu3073 Год назад
Great job Hitesh Marvellously simple . I loved it .😍
@clasherdamn5862
@clasherdamn5862 2 года назад
I am learning react and yess I am at tic tac toe chapter and I got the logic now heading back It's such a great explanation 👍🏻
@TunsalatOgTomat
@TunsalatOgTomat 4 года назад
jeez you made that easy, thank you bhaee... greetings from denmark :)
@jayeshfirke1507
@jayeshfirke1507 5 лет назад
Its really simple logic to understand pls make more stuff like that
@venkateshnambi1576
@venkateshnambi1576 3 года назад
came hear to build this game in react .. Basics first! then next!!!
@asimtarapathak8648
@asimtarapathak8648 5 лет назад
Loved this video ❤️. It's was so easy and simple logic.
@vivekshukla9485
@vivekshukla9485 3 года назад
Came here while learning Angular from LCO. I was concerned how we will do it but the way you explained was really awesome!
@visheshgupta4990
@visheshgupta4990 7 месяцев назад
Thank you so much sir the way you explain it looks how simple and I am able to understand this logic and able to think thanks alot , I came up here from your react native series
@kunalkathe3198
@kunalkathe3198 5 лет назад
That thumbnail is really catchy! 😀 Video👌👌
@mdwaqar4702
@mdwaqar4702 5 лет назад
Just thinking about that and not wanted to take any kind of help from internet but as I don't want to miss any of your video. I watched it and its damn simple logic.
@AmanKumar-tv1yl
@AmanKumar-tv1yl 4 года назад
Hi Hitesh, You are simply amazing. You have the skills to make complex things easy to understand.
@nayhamanzoor1848
@nayhamanzoor1848 4 года назад
I'm designing tic tac toe in Oracle development.....love this video ....it clears my logic ... thank you sir
@mockingbird3809
@mockingbird3809 5 лет назад
Who Came From Flutter Course in Learn Code Online?..😉
@greensphinx
@greensphinx 3 года назад
Not me :D
@NIKHIL27B
@NIKHIL27B 3 года назад
From angular
@mohitchaudhari3398
@mohitchaudhari3398 3 года назад
from React
@coolpot
@coolpot 2 года назад
this guy is great, his udemy on angular is what everyone else should aspire to, also i often have trouble understanding indian accents on courses, but this guy has amazing english language speaking ability and his courses are to the point - new favourite of mine :)
@aheribanerji7056
@aheribanerji7056 2 года назад
Which course??
@RandomGuy-hi2jm
@RandomGuy-hi2jm 5 лет назад
*Can we optimize this problem? DS*
@tejaswipandava
@tejaswipandava 3 года назад
optimization: The first thing we need to do is have an if the check for the total no of turns in case they exceed 4. if they exceed we can start our logic. Also, one more idea I was getting is instead of having 8 checks (row, column, and diagonals) why not reduce the check. I mean whenever a user selects a value (say position 8) let's check all possible combinations with that position that would reduce the checks to max 3. (positions [0,4,8],[2,5,8][6,7,8])
@bhalsodnirva104
@bhalsodnirva104 5 лет назад
OMG...started loving yr channel more...😍😍😍😍That was so easy and interesting..plz plz plz add videos like this to build the logic..humble request
@SichuunduW762
@SichuunduW762 4 года назад
nice one. here is a question.making use of a two dimensional array,write the code that permits two players to play a game of tic tac toe (also known as noughts and crosses). use 0 to represent an empty square.1 to represent a cross, and 2 to represent a nought. this requires implementing several algorithms; asking for the user`s input and placing their symbol looping between two different players alternating the symbol checking for a win. must be done in java. show the pseudocode and the java code
@AmitSingh-nr8jz
@AmitSingh-nr8jz 4 года назад
no need to scan all rows , cols & diagonals to decide winning state, if u changed any cell and it is not corner cell then just check corresponding row & col, else you will have to consider corresponding diagonal as well . so in after each u have to either check for (row & col) or (row, col & dig) to decide winning state. this question is not about how do u decide winning state after each move, it is more how efficiently u decide :)
@9-HAPPYTHOUGHTS
@9-HAPPYTHOUGHTS 5 лет назад
dear sir tell me about block chain technology whether this technology behind bitcoin or not?
@alittlecoding
@alittlecoding 5 лет назад
yes, sir. blockchain technology is behind bitcoin.
@hrithikchavva6127
@hrithikchavva6127 5 лет назад
I loved this video !!! Thank u sir for letting me know how to go for standard approach for such problems
@ravigunz
@ravigunz 5 лет назад
come here from LCO's, complete flutter course, simply amazing explanation. thank you!
@hassaan-dev
@hassaan-dev Год назад
💜You explained easily difficult logic
@sigmaboom332
@sigmaboom332 4 года назад
The explanation is very easy Thank you
@sujaypagam1149
@sujaypagam1149 Год назад
💌🤟 logic 🔥 Learning react js from lco... and just loved it
@abhinavsinha9923
@abhinavsinha9923 3 года назад
Yea it was very interesting and very enjoyable! Cool HC!
@vinodagoudapatil1517
@vinodagoudapatil1517 3 года назад
From your Angular course, I am here!
@priyanshusharma2310
@priyanshusharma2310 2 года назад
I came here from your react course :), your course is really good
@BeyondRecognitionLifestyle
@BeyondRecognitionLifestyle 5 лет назад
You made this really easy to understand. Thank you!
@darshanthakral5505
@darshanthakral5505 5 лет назад
Was actually stuck at that point, Thanks for helping us..😊😊
@SunilKumar-ib2bq
@SunilKumar-ib2bq Год назад
Amazing explaination!
@swarajgadre5630
@swarajgadre5630 3 года назад
Very nicely explained sir!!!!!!!
@unpluggedaman
@unpluggedaman 5 лет назад
Great, could you do a similar video for the Simon Game logic as well!
@yashrajanshukla7790
@yashrajanshukla7790 5 лет назад
8:29 sir haven't cut that seen because he want to show that yes professionals also makes mistakes That builds a connection between teacher and students But it's he didn't hide the mistakes he accepted it Salute you sir
@wrednax8594
@wrednax8594 4 года назад
THANK YOU SIR. GOD BLESS YOU
@sail_sail30
@sail_sail30 5 лет назад
What if we do it like this? We use magic squares. 6 1 8 7 5 3 2 9 4 In any direction the sum is 15, hence is the winning logic.
@harshagarwal3855
@harshagarwal3855 5 лет назад
This logic can really work if there ain't any other 3 letter combination giving 15
@sail_sail30
@sail_sail30 5 лет назад
Yes i have tested it always gives 15 in any direction, vertical, horizontal or diagonal
@ranjandass13
@ranjandass13 5 лет назад
I thought you're going to explain some logic or algorithm where the computer will win every time or something like that. Some intelligent comp player.
@AbhishekJain-zu1uf
@AbhishekJain-zu1uf 5 лет назад
Me too
@jayanthm2597
@jayanthm2597 5 лет назад
Thank you,my everyday challenges and doubts are always solved by you...
@anonyone8834
@anonyone8834 8 месяцев назад
How are you everywhere??????
@MohitK96
@MohitK96 5 лет назад
I still remember that because of this fu@#ing problem I left learning java and app development. I was learning on my own, doing Head first java, everything was going smooth and then this problem appeared, wasted almost 4-5 days, was lost in college stuff and ultimately never did again...
@nagavedareddy5891
@nagavedareddy5891 3 года назад
You're a True gem sir...!
@edtechbymeera
@edtechbymeera 4 года назад
Fantastic explanation of the logic..Programming is all about conceptual thinking and analysis rather than coding. You are great
@yashrajanshukla7790
@yashrajanshukla7790 5 лет назад
Absolutely simple .. And this video will help beginners to understand it better
@shivsingh5117
@shivsingh5117 Год назад
Now, After watching the video "It is very simple"❤❤🙏🙏
@benelansari7228
@benelansari7228 Год назад
Could you tell me how to improve my problem skills and solve problems like tic-tac-toe in a eaier way? thank you
@varishali1400
@varishali1400 5 лет назад
Sir can you please show me how to implement computer mode in this game?
@pramaffairs4331
@pramaffairs4331 Год назад
life saver.... Thanks
@AkshayGupta-dd4ht
@AkshayGupta-dd4ht 4 года назад
this logic is tooooooooo simple for noobs . thanks you and for legends minimax algo
@ron3799
@ron3799 3 года назад
Couldn't you do if pos[0] == pos[1] == pos[2] instead?
@maelstrom57
@maelstrom57 3 года назад
You couldn't. A computer would interpret pos[0] == pos[1] == pos[2] as ( pos[0] == pos[1] ) == pos[2] namely true/false == pos[2]
@ron3799
@ron3799 3 года назад
@@maelstrom57 thank u
@zakiulhasan808
@zakiulhasan808 5 лет назад
Sir what kind of glass you are using.Is it any blue light protection glass? Do we have to use that kind of product?
@ritiksaxenaofficial
@ritiksaxenaofficial 5 лет назад
When I started learning C++... I made it using array and lots of *if* and *else* statements. But this logic is quite simple✌🏻
@abolfazldaneshvar1441
@abolfazldaneshvar1441 Год назад
Thank very Usefull !
@farhan787
@farhan787 5 лет назад
8:28 both time wrong sir "Tic toc tae" and "tic-toc-tech", it happens but I really liked that you didn't cut that part.
@HiteshCodeLab
@HiteshCodeLab 5 лет назад
😂
@souvikbanerjee1635
@souvikbanerjee1635 5 лет назад
In C pos[i] will be filled up with garbage value if the player have not played any move there so we can simply check (for the horizontal case) if pos[0]==pos[1] and pos[1]==pos[2] so if the player have not filled out any of the places it will not match anyway because of the garbage value concept. I tried to code that with this logic and found some strange error which says that the subscripted value is not either array nor pointers nor vectors . I just want to know if I am thinking correctly , and this error is occurring because of my logic or not.
@creatorsconnect8807
@creatorsconnect8807 5 лет назад
I love ur logic pls make more such kind of stuff .
@AkshayMohanty743
@AkshayMohanty743 2 года назад
Great way of teaching 😊
@azamat0180
@azamat0180 5 лет назад
Thank you so much👍
@Rishi-xj2iy
@Rishi-xj2iy 2 года назад
your personality reflects some shade of professor from money heist spain
@statuslounge9407
@statuslounge9407 3 года назад
here i am trying to build logic for Codechef May Challenge
@msdhaliwal
@msdhaliwal 4 года назад
creating react app from your latest react course at LCO ( complete reactJs developer bootcamp )
@raghuakuthota4900
@raghuakuthota4900 5 лет назад
Loved this video... pretty simple :) - thank you so much
@shoaibhasan4026
@shoaibhasan4026 Год назад
Thank you so much you're life saver Sir everytime ❤
@miw879
@miw879 3 года назад
This is a great channel!
@mohdnawazishalam3255
@mohdnawazishalam3255 5 лет назад
Need some more videos like this
@lightyagami3222
@lightyagami3222 5 лет назад
Haha i told my each and every friends to subscribe 💗
@rahulkhatri5158
@rahulkhatri5158 4 года назад
thanks for simply explaining the logic.
@VamshiKrishna-ud5qt
@VamshiKrishna-ud5qt 4 года назад
Hello hitesh please explain match tied logic in tic tac toe
@AbhisekMaitiOfficial
@AbhisekMaitiOfficial 4 года назад
tic tac tae !!!!! tic tac tak :::: hitesh sir some times mashed up in pronunciation and i really enjoyed funny comments in middle of lecture and i never bored when watching his lecture.
@vishwaraval1930
@vishwaraval1930 4 года назад
Nice you explained it amazingly I made my game like you have explianed
@mariafernandaabreufonseca9640
@mariafernandaabreufonseca9640 2 года назад
Really helpful. Thanks 👍
@jaypatel9392
@jaypatel9392 4 года назад
Yes I have enjoyed.plz make this kind of videos
@manivelarung
@manivelarung 4 года назад
came from Hitesh's Angular course
@AbhishekJain-zu1uf
@AbhishekJain-zu1uf 5 лет назад
Instead of using so many "ands" cant we just write if board[i] == board[j] == board[k] as most of the languages support this notation
@RobinSingh-gv2if
@RobinSingh-gv2if 3 года назад
Thanks Man.
@gauravchinawale783
@gauravchinawale783 Год назад
We should be able to write a dynamic conditions This is all hard coded for school kids this might be fun
@anuragtawaniya7746
@anuragtawaniya7746 4 года назад
very helpful sir
@viral_codes
@viral_codes 5 лет назад
Thank you very much sir.
@Vikram_singh_ji
@Vikram_singh_ji 2 года назад
Vikram was here (at the time of learning react)!!!
@CreativeJE
@CreativeJE 5 лет назад
You should have taught a better way to do this it's very insufficient way
@ender2999
@ender2999 4 года назад
"insufficient"? Do you speak English? Inefficient?
@maelstrom57
@maelstrom57 3 года назад
@@ender2999 Imagine criticizing someone's English when you can't even open a dictionary. www.thefreedictionary.com/insufficient
@ashutoshanand4040
@ashutoshanand4040 5 лет назад
Multiple if statement may not be the good option 😑 Can we reduce time complexity?
@HiteshCodeLab
@HiteshCodeLab 5 лет назад
Once you understand core concept, hundreds of ways to deal with situation.
@sujaykamatkar788
@sujaykamatkar788 5 лет назад
yeah another method I use is just write 1 if statement then add condition using OR like if ( pos[0] == pos[1] == pos[2] or pos[3] == pos[4] == [5] or.... )
@unknownkumar3749
@unknownkumar3749 4 года назад
I have learned only one language(c++) I will make this logic in C ++ ... even if UserInterface is bad !
@sujaykamatkar788
@sujaykamatkar788 5 лет назад
Hello Sir, I have one problem My program is running but it can't go to second player. Can you help me?
@TopAPPSTamil
@TopAPPSTamil 5 лет назад
omg more time i did nt realize and still 5.30pm what logic is this ?? but now i got it😍😍😍 plzzz doooooo more more this kind of videoo dude
@HiteshCodeLab
@HiteshCodeLab 5 лет назад
I am known for making things simple. 🙂
@ranuranjan7937
@ranuranjan7937 3 года назад
who came from reactjs course?, sir logic too simple and very helpful
@theskysthelimit.
@theskysthelimit. 3 года назад
thank you!
@code_with_ali
@code_with_ali 5 лет назад
Thanks for the video . prefect explanation.
@Himachaliyan
@Himachaliyan 4 года назад
Can we make it shorter and simple..
@yashrajanshukla7790
@yashrajanshukla7790 5 лет назад
Just a tip for my beginner friends:- If you can't make logics .. try solving some algorithms and maths And break the problem in simple steps
@MrDevihem
@MrDevihem Год назад
I was expecting something with logic and efficiency .... this is hardcoding the positions for winning with "if's" .
@rajshekharrakshit9058
@rajshekharrakshit9058 4 года назад
U r awesome sir, thank u
@VeteranAyush
@VeteranAyush 3 года назад
Great
@alexjuniortupapa
@alexjuniortupapa 7 месяцев назад
Thanks for sharing
@_sharmaji.dev_
@_sharmaji.dev_ 5 лет назад
Great Video. Waiting for Saturday challenge....
@purnapavanchandra6823
@purnapavanchandra6823 5 лет назад
Sir, what about Saturday coding challenges?
@ProgrammingWithProject
@ProgrammingWithProject 5 лет назад
Sir I enjoyed this video please make more video to raise the ability of logical thinking. Well I also teach PHP and JavaScript at my RU-vid channel with the help of project. Sir you are my inspiration.
@mdfaiz5539
@mdfaiz5539 5 лет назад
Your thumbnails are improving day by day
@shantanumishra6488
@shantanumishra6488 5 лет назад
Thankyou sir you are the best ❤️❤️
@SoftwareMahima2024
@SoftwareMahima2024 3 года назад
Super cool video
Далее
How to write tic tac toe logic
17:44
Просмотров 11 тыс.
JavaScript Pro Tips - Code This, NOT That
12:37
Просмотров 2,5 млн
Best AI assistant for developers is free
10:40
Просмотров 25 тыс.
AI company just raised 1 billion dollar in seed round
14:52
Finishing tic tac toe in react native
13:27
Просмотров 11 тыс.
Cursor Is Beating VS Code (...by forking it)
18:00
Просмотров 94 тыс.
Tic Tac Toe in p5.js (Coding Challenge 149)
24:01
Просмотров 1,4 млн
Build Tic Tac Toe With JavaScript - Tutorial
41:46
Просмотров 358 тыс.