Untitled

mail@pastecode.io avatar
unknown
python
a year ago
1.3 kB
1
Indexable
Never

plansza  = ['498263157',\
'136578294',\
'572491683',\
'819342765',\
'653817942',\
'247659831',\
'761935428',\
'985124376',\
'324786519']
    
dic_szablon = {}
for i in range(1,10):
    dic_szablon[i] = 1
    
def check(dic, plan):
    dic_temp = {}
    for item in plan:
        for char in item:
            dic_temp[int(char)] = item.count(char)
        if dic_temp == dic:
            dic_temp.clear()
            continue
        else:
            return False
    return True

def trans(lst):
    temp_lst = []
    temp_str =''
    i = 0
    while i < 9:
        for item in lst:
            temp_str += item[i]
        temp_lst.append(temp_str)
        temp_str = ''
        i += 1
    return temp_lst
    
def kwadrat(lst):
    i = 0
    k = 0
    step = 0
    temp_lst = []
    temp_str = ''
    while step < 3:
        for item in lst:
            temp_str += item[3*i:2*(i+1)+i+1]
            if item == lst[2*(k+1)+k]:
                temp_lst.append(temp_str)
                temp_str = ''
                k += 1
        i += 1
        k = 0
        step += 1
    return temp_lst    

plansza_trans = trans(plansza)
plansza_kwadrat = kwadrat(plansza)


if check(dic_szablon, plansza) and check(dic_szablon, plansza_trans) and check(dic_szablon, plansza_kwadrat):
    print("Tak")
else:
    print("Nie")