alchemist/laboratory.py
def do_a_reaction(self):
        """Carry out a reaction using the given lower and upper shelves

        Going through each substance in the lower shelf in order, check if
        there are any substances in the upper shelf that can react with the
        currently chosen substance from the lower shelf. If this does not
        exist, continue to the next substance, if there are potential
        reactants in the upper shelf, pick one uniformly random from this set,
        carry out the reaction and return the updated shelves by removing the
        reactants.

        Note that if none of the substances in the lower shelf can react with
        any of the substances in the upper shelf, the shelves will stay the
        same and no reaction will take place (e.g. this method becomes
        idempotent in this case).

        :return reaction_occurred: boolean specifying if a reaction occurred
        """
        reaction_occurred = False
        for substance_lower in self.shelves["lower"]:
            possible_targets = [
                i
                for i, target in enumerate(self.shelves["upper"])
                if self.can_react(substance_lower, target)
            ]
            if not possible_targets:
                continue
            else:
                substance_upper_index = random.choice(possible_targets)
                self.update_shelves(substance_lower, substance_upper_index)
                reaction_occurred = True
                return reaction_occurred
        return reaction_occurred
Carry out a reaction using the given lower and upper shelves

        Going through each substance in the lower shelf in order, check if
        there are any substances in the upper shelf that can react with the
        currently chosen substance from the lower shelf. If this does not
        exist, continue to the next substance, if there are potential
        reactants in the upper shelf, pick one uniformly random from this set,
        carry out the reaction and return the updated shelves by removing the
        reactants.

        Note that if none of the substances in the lower shelf can react with
        any of the substances in the upper shelf, the shelves will stay the
        same and no reaction will take place (e.g. this method becomes
        idempotent in this case).

        :return reaction_occurred: boolean specifying if a reaction occurred
        
Carry out a reaction using the given lower and upper shelves
Going through each substance in the lower shelf in order, check if
there are any substances in the upper shelf that can react with the
currently chosen substance from the lower shelf. If this does not
exist, continue to the next substance, if there are potential
reactants in the upper shelf, pick one uniformly random from this set,
carry out the reaction and return the updated shelves by removing the
reactants.

Note that if none of the substances in the lower shelf can react with
any of the substances in the upper shelf, the shelves will stay the
same and no reaction will take place .
Carry out a reaction using the given lower and upper shelves Going through each substance in the lower shelf in order check if there are any substances in the upper shelf that can react with the currently chosen substance from the lower shelf . If this does not exist continue to the next substance if there are potential reactants in the upper shelf pick one uniformly random from this set carry out the reaction and return the updated shelves by removing the reactants . Note that if none of the substances in the lower shelf can react with any of the substances in the upper shelf the shelves will stay the same and no reaction will take place .
def do_a_reaction(self):
        reaction_occurred = False
        for substance_lower in self.shelves["lower"]:
            possible_targets = [
                i
                for i, target in enumerate(self.shelves["upper"])
                if self.can_react(substance_lower, target)
            ]
            if not possible_targets:
                continue
            else:
                substance_upper_index = random.choice(possible_targets)
                self.update_shelves(substance_lower, substance_upper_index)
                reaction_occurred = True
                return reaction_occurred
        return reaction_occurred
def do_a_reaction ( self ) : reaction_occurred = False for substance_lower in self . shelves [ "lower" ] : possible_targets = [ i for i , target in enumerate ( self . shelves [ "upper" ] ) if self . can_react ( substance_lower , target ) ] if not possible_targets : continue else : substance_upper_index = random . choice ( possible_targets ) self . update_shelves ( substance_lower , substance_upper_index ) reaction_occurred = True return reaction_occurred return reaction_occurred
Carry out a reaction using the given lower and upper shelves
Going through each substance in the lower shelf in order, check if
there are any substances in the upper shelf that can react with the
currently chosen substance from the lower shelf.
Carry out a reaction using the given lower and upper shelves Going through each substance in the lower shelf in order check if there are any substances in the upper shelf that can react with the currently chosen substance from the lower shelf .
"""Carry out a reaction using the given lower and upper shelves

        Going through each substance in the lower shelf in order, check if
        there are any substances in the upper shelf that can react with the
        currently chosen substance from the lower shelf. If this does not
        exist, continue to the next substance, if there are potential
        reactants in the upper shelf, pick one uniformly random from this set,
        carry out the reaction and return the updated shelves by removing the
        reactants.

        Note that if none of the substances in the lower shelf can react with
        any of the substances in the upper shelf, the shelves will stay the
        same and no reaction will take place (e.g. this method becomes
        idempotent in this case).

        :return reaction_occurred: boolean specifying if a reaction occurred
        """
boolean specifying if a reaction occurred
boolean specifying if a reaction occurred
reaction_occurred
self