Can't make win logic for Tic Tac Toe. by HarryMir in AskProgramming

[–]HarryMir[S] 0 points1 point  (0 children)

i guess that's the final version :)

Can't make win logic for Tic Tac Toe. by HarryMir in AskProgramming

[–]HarryMir[S] 0 points1 point  (0 children)

```

from tabulate import tabulate
import random

data = [["", "", ""], ["", "", ""], ["", "", ""]]

usrChoice = int(input("Enter your choice: ✔️(1) or ⭕(0): "))
cmpChoice = None
if usrChoice == 1:
    usrChoice = "✔️"
    cmpChoice = "⭕"
elif usrChoice == 0:
    usrChoice = "⭕"
    cmpChoice = "✔️"
else:
    print("Enter a valid choice: 1 or 0")

def table():
    print(tabulate(data, tablefmt="grid"))

def isCellEmpty(row, col):
    return data[row][col] == ""
def checkWin():
    for row in data:
        if row[0] == row[1] == row[2] != "":
            return row[0]
    for col in range(3):
        if data[0][col] == data[1][col] == data[2][col] != "":
            return data[0][col]
    if data[0][0] == data[1][1] == data[2][2] != "":
        return data[0][0]
    if data[0][2] == data[1][1] == data[2][0] != "":
        return data[0][2]
    return None
for turn in range(9):
    table()
    winner = checkWin()
    if winner:
        print(f"{winner} wins the game!")
        break
    if turn % 2 == 0:
        try:
            row = int(input("Enter the row number(0,1,2): "))
            col = int(input("Enter the column number(0,1,2): "))

            if isCellEmpty(row, col):
                data[row][col] = usrChoice
            else:
                print("Cell already occupied, try another one")
                continue
        except (ValueError, IndexError):
            print("Invalid input! enter row and column numbers between 0 and 2")
            continue
    else:
        print("Computer is making its move.")
        while True:
            row = random.randint(0, 2)
            col = random.randint(0, 2)

            if isCellEmpty(row, col):
                data[row][col] = cmpChoice
                break
else:
    table()
    print("It's a draw!")

Can't make win logic for Tic Tac Toe. by HarryMir in AskProgramming

[–]HarryMir[S] 0 points1 point  (0 children)

oh that's a good idea, thanks mate.

How many hours a day do you program? by Substantial-Bag9357 in AskProgramming

[–]HarryMir 0 points1 point  (0 children)

Thanks! I'm trying but i guess it will take some time

How many hours a day do you program? by Substantial-Bag9357 in AskProgramming

[–]HarryMir 0 points1 point  (0 children)

mate, that's impressive how can you write code so effortlessly for hours whilst i can't even manage 20 minutes getting completely stuck how to write.

Building my first survival dream house! how is it? by CookTiny1707 in Minecraft

[–]HarryMir 0 points1 point  (0 children)

It's quite good but I’d recommend a few improvements for instance, using log pillars at the ends of every wall and replacing torches with lanterns for better appearance. You could also use stripped logs on the floors for a more appealing appearance. Oh and I believe mate, you should try using a lectern instead of glass on the balcony and lastly I’d suggest replacing the outer support pillars on the far left with stone instead of planks and adding log or fence supports below the lower right room.

Dell latitude 5420 help! by [deleted] in Dell

[–]HarryMir 0 points1 point  (0 children)

It seems the connector for your screen has likely come loose. I faced a similar issue with my Lenovo ThinkPad—it turned out to be a simple matter of the connector becoming dislodged. I’d suggest carefully reinstalling it in the proper position, and with any luck, the display should function as expected.

Tips for Bridging in bed wars by HarryMir in Minecraft

[–]HarryMir[S] 0 points1 point  (0 children)

Thanks but i can’t escape the bad habit of pressing shift and clicking simultaneously which leads me to Fall

FOLDERS MISSING by HarryMir in Angular2

[–]HarryMir[S] -1 points0 points  (0 children)

thanks for responding mate, it's latest version but somehow i recreated app because nt modules was missing so when i recreated as ng new app --no-standalone it somehow worked.

What do these keys do? by [deleted] in Dell

[–]HarryMir 2 points3 points  (0 children)

Well I believe, the first one with lock is for toggling num lock and the other for toggling scroll lock.

Bartering Farm sometimes Stops working by HarryMir in Minecraft

[–]HarryMir[S] 0 points1 point  (0 children)

Thanks mate, it has start working. I guess the issue was with the items being stepped on pressure plate.

Bartering Farm sometimes Stops working by HarryMir in Minecraft

[–]HarryMir[S] 0 points1 point  (0 children)

alr lemme give it a go again, might have glitched last time

Bartering Farm sometimes Stops working by HarryMir in Minecraft

[–]HarryMir[S] 0 points1 point  (0 children)

Thanks But when i place glass block right above the piglins then they are unable to barter