Support our Blind Hand Charity by donating at 9818291723. Your contribution has the potential to bring about significant positive change for humanity.

Search This Blog

Thursday, November 9, 2023

MINE SWEEPER

import random as ran
r=int(input("Enter the number of rows = "))
c=int(input("Enter the number of columns = "))
b=int(input("Enter the number of bombs = "))
l=[]
k=[]
for i in range(1,r*c+1):
    l.append(i)
    k.append(i)
while l.count(0)!=b:
    t=ran.randint(0,len(l)-1)
    l.pop(t)
    l.insert(t,0)
while True:
    s=-1
    for i in range(0,r):
        for j in range(s,c+s):
            if s<=len(l):
                s+=1
                print(k[s],end=' ')
        print()
    n=int(input("Enter the number = "))
    if l.count(n)==1:
        t=k.index(n)
        k.pop(t)
        k.insert(t,'ૐ')
    else:
        s=-1
        for i in range(0,r):
            for j in range(s,c+s):
                if s<=len(k):
                    s+=1
                    if k[s]=='ૐ':
                        l[s]='ૐ'
                        print(k[s],end=' ')
                    elif l[s]==0:
                        print('☪',end=' ')
                        l[s]='☪'
                    else:
                        l[s]='X'
                        print('X',end=' ')
            print()
    if l.count('☪')==b:
        print('------------------------')
        print("ALLAH HU AKBAR")
        break
    if (l.count('ૐ')+l.count('X'))==(len(l)-b):
        print('------------------------')
        print("ALLAH TA'ALA KI TUM PR REHMT HAI")
        break

OUTPUT