def additional_answer(self, Houses: SuperSequence): (Nat1, Nat2) = n_Vars(2) for _ in members([House(nationality=Nat1, pet='zebra'), House(nationality=Nat2, drink='water')], Houses): ans = f'\n\tThe {Nat1} both own a zebra and drink water.' if Nat1 == Nat2 else \ f'\n\tThe {Nat1} own a zebra, and the {Nat2} drink water.' print(ans)
yield if __name__ == '__main__': from timeit import default_timer as timer (start1, end1, start2, end2) = (timer(), None, None, None) Houses = LinkedList([House() for _ in range(5)]) inp = None for _ in zebra_problem(Houses): print('\nHouses: ') for (indx, house) in enumerate(Houses.to_python_list()): print(f'\t{indx+1}. {house}') (Nat1, Nat2) = n_Vars(2) for _ in members([ House(nationality=Nat1, pet='zebra'), House(nationality=Nat2, drink='water') ], Houses): ans = f'The {Nat1} both own a zebra and drink water.' if Nat1 == Nat2 else \ f'The {Nat1} own a zebra, and the {Nat2} drink water.' end1 = timer() print(ans) inp = input('\nMore? (y, or n)? > ').lower() start2 = timer() if inp != 'y': break if inp == 'y': print('No more solutions.')