This commit is contained in:
2025-03-10 16:46:29 +01:00
parent 2915fec180
commit 46894bd504
4 changed files with 10 additions and 10 deletions

View File

@@ -4,9 +4,9 @@ class Korsók(Feladat):
def __init__(self, ke,c):
self.kezdő= ke
self.cél=c
self.K1=8
self.K1=3
self.K2=5
self.K3=3
self.K3=8
def célteszt(self, állapot):
return állapot[0]==self.cél or állapot[1]==self.cél
@@ -60,7 +60,7 @@ class Korsók(Feladat):
# utam.reverse()
# print(utam)
korso=Korsók((8,0,0),4)
korso=Korsók((2,2,3),4)
print(korso)
print(korso.rákövetkező(korso.kezdő))

View File

@@ -6,7 +6,7 @@ class Korso(Feladat): # feladat osztaly a szuroje
self.korsok=(3,5,8) #korsok meretei
def célteszt(self, allapot:tuple[int,int,int]) -> bool:
if allapot[1] == self.cél or allapot[2] == self.cél:
if allapot[0] == self.cél or allapot[1] == self.cél or allapot[2] == self.cél:
#teljesult a cél allpot
return True
else:
@@ -16,7 +16,7 @@ class Korso(Feladat): # feladat osztaly a szuroje
lepesek = []
for i in range(3):
for j in range(3):
if i != j:
if i != j: #nem toltunk onmagabol onamagaba
if allapot[i] > 0 and allapot[j] < self.korsok[j]: #van e folyadek vagy televan a korso:
m = min(allapot[i], self.korsok[j]-allapot[j]) #self.korsok[j] max(Hj)-aj
tmp_allapot = list(allapot) #ezzel szerkesztheto a tuple
@@ -26,9 +26,9 @@ class Korso(Feladat): # feladat osztaly a szuroje
lepesek.append(tmp) #amit a listaba rakunk
return lepesek
h3 = Korso((2,3,3), 4)
h3 = Korso((2,2,3), 4)
print(h3.rákövetkező(h3.kezdő))
print(h3.célteszt((1,4,3)))
print(h3.célteszt((2,5,6)))

View File

@@ -56,7 +56,7 @@ class Hanoi(Feladat):
return lepesek
K=Hanoi(8) # 2^n - 1
K=Hanoi(13) # 2^n - 1
print(len(szélességi_gráfkeresés(K).megoldás()))

View File

@@ -60,7 +60,7 @@ class Hanoi(Feladat):
return lepesek
h = Hanoi(8)
h = Hanoi(15)
#print(h.result('123', Act(0,'2')))
#print(h.rákövetkező('321'))
@@ -72,4 +72,4 @@ while h.célteszt(h.kezdő)==False:
h.mod(lepes)
#print(lepes)
k+=1
print(k)
print(k)