# SAT solver #2

unknown
python
2 years ago
3.7 kB
8
Indexable
Never
```class House:
def __init__(self, color="", nationality="", pet="", drinks="", cig_brand=""):
self.__color = color
self.__nationality = nationality
self.__pet = pet
self.__drinks = drinks
self.__cig_brand = cig_brand

self.__color = new_color

self.__nationality = new_nationality

self.__pet = new_pet

self.__drinks = new_drinks

self.__cig_brand = new_cig_brand

def allAttribute(self):
return self.__color, self.__nationality, self.__pet, self.__drinks, self.__cig_brand

def getColor(self):
return self.__color

def getNationality(self):
return self.__nationality

def getPet(self):
return self.__pet

def getDrinks(self):
return self.__drinks

def getCigBrand(self):
return self.__cig_brand

# main
house1 = House()
house2 = House()
house3 = House()
house4 = House()
house5 = House()
# know for sure
# analyse 1

print("Know for sure")
print(f"house1 = {house1.allAttribute()}")
print(f"house2 = {house2.allAttribute()}")
print(f"house3 = {house3.allAttribute()}")
print(f"house4 = {house4.allAttribute()}")
print(f"house5 = {house5.allAttribute()}")

arr = [house1, house2, house3, house4, house5]

for i in range(len(arr)):
if arr[i].getNationality() == "" and arr[i].getPet() == "":
if arr[i - 1].getNationality() == "Swede" and arr[i - 1].getPet() == "Dogs":
continue
else:
if arr[i].getNationality() == "" and arr[i].getDrinks() == "":
if arr[i - 1].getCigBrand() == "Pall Mall" and arr[i - 1].getPet() == "":
if arr[i - 1].getCigBrand() == "Blue Master" and arr[i - 1].getDrinks() == "":
if arr[i - 1].getNationality() == "German" and arr[i - 1].getCigBrand() == "":
if arr[i - 1].getPet() == "Cats" and arr[i].getCigBrand() == "":
if arr[i - 1].getCigBrand() == "Blends" and arr[i].getPet() == "":
if arr[i].getCigBrand() == "Blends" and arr[i - 1].getDrinks() == "" and arr[i + 1].getDrinks() != "":
if arr[i].getCigBrand() == "Blends" and arr[i + 1].getDrinks() == "" and arr[i - 1].getDrinks() != "":

print('\n')
print("All attribute of houses")
print(f"house1 = {house1.allAttribute()}")
print(f"house2 = {house2.allAttribute()}")
print(f"house3 = {house3.allAttribute()}")
print(f"house4 = {house4.allAttribute()}")
print(f"house5 = {house5.allAttribute()}")

print('\n')