Diagonal Winning Algo - Python 3 Programming Tutorial p.12

preview_player
Показать описание
Welcome to part 12 of the Python 3 basics series, where we're going to be talking about how we can validate the winners of our TicTacToe game in the final way: diagonally!

#python #programming #tutorial
Рекомендации по теме
Комментарии
Автор

Good to see one of your classic series get a reboot. Excellent job as always, Harrison!

LucidProgramming
Автор

I gotta say, this is the most real tutorial I've seen so far. Whenever you run into a problem just google it. In most of the programming tutorials I've seen the programmers were either going off a script or were good enough to program whatever it is they were teaching without aid.

johnnybadmen
Автор

If im not mistaken, the issue you ran into at 14:55 is that you said "print(a)" instead of "print(i)" after "for i in a..."

XIsleTheWanderer
Автор

I appreciate your explanations, logic and smart approach, thank you for all the work, I'm trying to pick up Python and I stop to think and google things, while I'm following. Found this on Stackoverflow and I quite liked it.

"When converting the list to a set, duplicate elements are removed. So if the length of the converted set is 1, then this implies that all the elements are the same."

So while stopping at the beginning I applied this logic and did the below, which worked nicely & thought I'd add it here.


diags = []
for ix in range(len(game)):
diags.append(game[ix][ix])
if len(set(diags)) == 1:
print("Winner!")

ktebe
Автор

this man has the greatest collection of cups i have ever seen

LetsJobu
Автор

The unexpected output at 14:45 was because "a" was being printed {print(a)} instead of printing "i" {print(i)}

teetechsys
Автор

If you could do a 3 - 4 part video on classes some time that will be super awesome.
I think most new guys learning programming like me, always learn classes until its too late, as the videos that do cover classes are all very brief and straight forward. Then the day you want to start building larger programs using classes, you realize that you actually don't know classes at all.

PS, enjoyed this video as well.

hawkeyezar
Автор

Another great video, thanks. And I find that the +- 20 minute video length is great because we get a bit of a flow going before the fun has to end (but I guess others might disagree).

lank_asif
Автор

thank you, thank, thank you very much!!! You showed me that programming(or coding) is very interesting and challenging.

NikitaMelik-Marutov
Автор

19:10 For me it isn't necessarily the video length - it's where you get in the content. They tend to end right as you're getting into the details.

LabGecko
Автор

Use list comprehensions: diag1 = [game[i][i] for i in range(len(game))] diag2 = [game[i][len(game)-i] for i in range(len(game))]

brotherlui
Автор

I'm going through these videos step by step, so this might be changed later on, but I just wanted to share what I personally wrote to get a more unanimous code, while still having the same end result:

diags = []
for row, col in
diags.append(game[row][col])

diags = []
for row, col in enumerate(range(len(game))):
diags.append(game[row][col])

I think this makes it a lot more obvious that these do the same things, just in different directions. Let me know if this can be improved upon further!

FH-uxrf
Автор

I enjoy the way you set-up your vids. I'd rather it be broken down into chapters that feel natural. Rather than trying to cram everything to make it shorter, or add filler to make it longer. And seeing the little goofs and problem-solving means a lot too. Shows that all skill levels face similar challenges.

blzfrost
Автор

you really are bob ross of coding mann

shaikhtanzil
Автор

At this time 9:22 my solution was:
for idx in rows:
for idy in cols:
diags.append(game[idx][idy])
break

Zwiesel
Автор

Thank you for creating this channel!! Love that laugh

ganeshnayak
Автор

instead of using reversed could you just use range(len(game), -1, -1) .

John-yyoy
Автор

Advanced python tutorials would be awesome. Thanks

siscominimal
Автор

This session took me a bit longer to digest. I think the time is just perfect. Thanks

extrememike
Автор

this is better and short algorithm for second diagonal check


def wind2(game):
diag1=[]
for item in range(len(game)):



if diag1.count(diag1[0])== len(diag1) and diag1[0] !=0:
print("winner")

shoebshaikh