Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

minesweeper code added #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions awais_mazahir.py

This file was deleted.

41 changes: 41 additions & 0 deletions uzair_awan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
def minesweeper(A):
# defining intermdeiate list to add zeros on periphery of given list/grid
imd_lst = []
for u in range(0, 8):
A[u] = "O"+A[u]+"O"
imd_lst.append(A[u])
imd_lst.append("O"*10)
imd_lst.insert(0, "O"*10)

# writing code for iterating on each character of each string in list/grid
output_lst = []
for i in range(1, 9):
s = ""
for j in range(1, 9):
if imd_lst[i][j] == "X":
s += "X"
else:
counter = 0
for x in range(i-1, i+2):
for y in range(j-1, j+2):
if imd_lst[x][y] == "X":
counter += 1
else:
pass
s += str(counter)
output_lst.append(s)
return output_lst


if __name__ == "__main__":

test = ["XOOXXXOO",
"OOOOXOXX",
"XXOXXOOO",
"OXOOOXXX",
"OOXXXXOX",
"XOXXXOXO",
"OOOXOXOX",
"XOXXOXOX"]

print(minesweeper(test))