Exemple #1
0
    def _validate_input_yield(self, input_str):
        """
        Yield the current configuration of the machine at each step.
        """
        final = self._validate_input_yieldd(input_str)
        current_state = self.initial_state
        current_direction = None
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)
        for i in str(final):
            input_symbol = tape.read_symbol()
            try:
                (current_state, new_tape_symbol, current_direction
                 ), state1, current_state1 = self._get_transition1(
                     current_state, input_symbol, i)
            except ValueError:
                state, current_state = self._get_transition1(
                    current_state, input_symbol, i)
                yield None, None, None, current_state, state, tape, final
                break
            tape.write_symbol(new_tape_symbol)
            tape.move(current_direction)
            yield current_state, new_tape_symbol, current_direction, state1, current_state1, tape, final

        input_symbol = tape.read_symbol()
        if current_state in self.final_states:
            yield None, None, None, input_symbol, current_state, tape, final
        if current_state in self.reject_state:
            yield None, None, None, input_symbol, current_state, tape, final
Exemple #2
0
    def _validate_input_yield1(self, input_str):
        """
        Yield the current configuration of the machine at each step.
        """
        current_state = self.initial_state
        current_direction = None
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)

        while current_state not in self.final_states and current_state not in self.reject_state:
            input_symbol = tape.read_symbol()
            try:
                (current_state, new_tape_symbol, current_direction
                 ), state1, current_state1 = self._get_transition1(
                     current_state, input_symbol)
            # except ValueError if __validate_input_yield have not
            # 3 values (__validate_input_yield end in else)
            except ValueError:
                state, tape_symbol = self._get_transition1(
                    current_state, input_symbol)
                current_direction = None
                yield state, tape_symbol, tape, current_direction
                break
            tape.write_symbol(new_tape_symbol)
            tape.move(current_direction)
            yield current_state1, state1, tape, current_direction

        current_direction = None
        input_symbol = tape.read_symbol()
        if current_state in self.final_states:
            yield current_state, input_symbol, tape, current_direction
        elif current_state in self.reject_state:
            yield current_state, input_symbol, tape, current_direction
Exemple #3
0
    def _validate_input_yield_final(self, input_str, final):
        current_state = self.initial_state
        current_direction = None
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)
        for i in str(final):
            input_symbol = tape.read_symbol()
            try:
                (current_state, new_tape_symbol, current_direction
                 ), state1, current_state1 = self._get_transition1(
                     current_state, input_symbol, i)
            except ValueError:
                state, current_state = self._get_transition1(
                    current_state, input_symbol, i)
                yield None, None, None, current_state, state, tape
                break
            tape.write_symbol(new_tape_symbol)
            tape.move(current_direction)
            yield current_state, new_tape_symbol, current_direction, state1, current_state1, tape

        input_symbol = tape.read_symbol()
        if current_state in self.final_states:
            yield None, None, None, input_symbol, current_state, tape
        if current_state in self.reject_state:
            yield None, None, None, input_symbol, current_state, tape
Exemple #4
0
 def _validate_input_yield_final(self, input_str, final):
     current_state = self.initial_state
     current_direction = None
     cycle = False
     cycle1 = True
     crossnumber=[]
     tape = TMTape(self.left_end+input_str, blank_symbol=self.blank_symbol)
     for i in str(final):
         input_symbol = tape.read_symbol()
         z = self._length_transition(current_state, input_symbol)
         if z:
             crossnumber.append(str(z[-1])[-1])
         try:
             (current_state, new_tape_symbol, current_direction),state1,current_state1 = self._get_transition1(current_state, input_symbol,i)
         except ValueError:
             state,current_state = self._get_transition1(current_state, input_symbol,i)
             cycle1 = False
             yield None,None,None, current_state, state,tape, cycle, crossnumber
             break
         tape.write_symbol(new_tape_symbol)
         tape.move(current_direction)
         yield current_state, new_tape_symbol, current_direction,state1,current_state1,tape, cycle, crossnumber
         
     input_symbol = tape.read_symbol()
     crossnumber.append('1')
     if current_state in self.final_states:
         cycle1 = False
         yield None,None,None,input_symbol,current_state, tape, cycle, crossnumber
     elif current_state in self.reject_state:
         cycle1 = False
         yield None,None,None,input_symbol,current_state, tape, cycle, crossnumber
     elif cycle1:
         yield None,None,None,input_symbol,current_state, tape, cycle1, crossnumber
Exemple #5
0
    def _validate_input_yield(self, input_str):
        """
        Check if the given string is accepted by this Turing machine.
        Yield the current configuration of the machine at each step.
        """
        current_state = self.initial_state
        current_direction = None
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)
        yield current_state, tape
        while current_state not in self.final_states:

            input_symbol = tape.read_symbol()
            (current_state, new_tape_symbol,
             current_direction) = self._get_transition(current_state,
                                                       input_symbol)
            tape.write_symbol(new_tape_symbol)
            tape.move(current_direction)

            yield current_state, tape
Exemple #6
0
    def _validate_input_yield(self, input_str):
        """
        Check if the given string is accepted by this Turing machine.
        Yield the current configuration of the machine at each step.
        """
        current_state = self.initial_state
        current_direction = None
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)
        yield current_state, tape

        # The initial state cannot be a final state for a DTM, so the first
        # iteration is always guaranteed to run (as it should)
        while current_state not in self.final_states:

            input_symbol = tape.read_symbol()
            (current_state, new_tape_symbol,
             current_direction) = self._get_transition(current_state,
                                                       input_symbol)
            tape.write_symbol(new_tape_symbol)
            tape.move(current_direction)

            yield current_state, tape
Exemple #7
0
    def _validate_input_yield_none_final(self, input_str, zoznam):
        """
        Yield the current configuration of the machine at each step.
        """
        final, cycle, cross, crossnumber = self._validate_input_yieldd_none_final(
            input_str, zoznam)
        current_state = self.initial_state
        current_direction = None
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)
        tapes = []
        current_directions = []
        input_symbols = []
        for state, paths in self.transitions.items():
            for symbols in paths.keys():
                length = len(symbols)

        for i in range(length - 1):
            tapes.append(i)
            current_directions.append(i)
            input_symbols.append(i)
        for i in tapes:
            tapes[i] = TMTape(self.left_end, blank_symbol=self.blank_symbol)
            current_directions[i] = None

        for i in str(final):
            all_tapes = []
            all_tapes.append(tape)
            count_x = 0

            input_symbolss = ()
            input_symbolss += tape.read_symbol(),
            for t in tapes:
                all_tapes.append(t)
                input_symbolss += t.read_symbol(),

            try:
                (current), state1, current_state1 = self._get_transition1(
                    current_state, input_symbolss, i)

            except ValueError:
                current_state, state = self._get_transition1(
                    current_state, input_symbolss, i)
                current = ()
                current += current_state,
                for s in state:
                    current += s,
                for t in tapes:
                    current += None,
                current += None,
                yield None, None, None, state, current_state, all_tapes, current, final, cycle, cross, crossnumber
                break

            current_state = current[count_x]
            count_x += 1
            new_tape_symbol = current[count_x]
            count_x += 1

            for t in tapes:
                new_tape_symbol = current[count_x]
                count_x += 1
                t.write_symbol(new_tape_symbol)

            current_direction = current[count_x]
            count_x += 1
            tape.move(current_direction)
            for t in tapes:
                current_direction = current[count_x]
                count_x += 1
                t.move(current_direction)
            yield current_state, new_tape_symbol, current_direction, state1, current_state1, all_tapes, current, final, cycle, cross, crossnumber

        input_symbolss = ()
        input_symbolss += tape.read_symbol(),
        current = ()
        current += current_state,
        current += tape.read_symbol(),
        for t in tapes:
            input_symbolss += t.read_symbol(),
            current += t.read_symbol(),
        for t in tapes:
            current += None,
        current += None,

        if current_state in self.final_states:
            yield None, None, None, input_symbolss, current_state, all_tapes, current, final, cycle, cross, crossnumber
        elif current_state in self.reject_state:
            yield None, None, None, input_symbolss, current_state, all_tapes, current, final, cycle, cross, crossnumber
        elif cycle == True:
            yield None, None, None, input_symbolss, current_state, all_tapes, current, final, cycle, cross, crossnumber
Exemple #8
0
    def _validate_input_yieldd_none_final(self, input_str, none_zoznam):
        """return final configuration"""
        current_state = self.initial_state
        current_direction = None
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)

        zoznam = []
        zoznam.append(none_zoznam)
        cross = None
        crossnumber = None
        cycle = False
        counter = 0
        counter1 = 0
        z1 = str(none_zoznam)

        tapes = []
        current_directions = []
        input_symbols = []

        for state, paths in self.transitions.items():
            for symbols in paths.keys():
                length = len(symbols)

        symbolsss = ()
        while length > 0:
            symbolsss += self.left_end,
            length -= 1
        zoznam = self._length_transition(current_state, symbolsss)

        while zoznam and counter < 200:
            if len(zoznam) > 1 and cross == None and crossnumber == None:
                cross = len(str(zoznam[-1]))
                crossnumber = str(zoznam[-1])[-1]
            counter += 1
            zoznam1 = zoznam.pop(0)

            tape_n = TMTape(self.left_end + input_str,
                            blank_symbol=self.blank_symbol)
            all_tapes = []
            all_tapes.append(tape_n)
            current_directions = []
            input_symbols = []
            current_state = self.initial_state

            for state, paths in self.transitions.items():
                for symbols in paths.keys():
                    length = len(symbols)
            for i in range(length - 1):
                tapes.append(i)
                current_directions.append(i)
                input_symbols.append(i)
            for i in tapes:
                tapes[i] = TMTape(self.left_end,
                                  blank_symbol=self.blank_symbol)
                current_directions[i] = None

            count_x = 0

            input_symbolss = ()
            input_symbolss += tape_n.read_symbol(),
            for i in tapes:
                all_tapes.append(i)
                input_symbolss += i.read_symbol(),
            current_state = self.initial_state

            count = 0
            for possition in str(zoznam1):
                count_x = 0
                poss = possition
                count += 1
                if count == len(str(zoznam1)):
                    try:
                        (current), a, b = self._get_transition(
                            current_state, input_symbolss, poss)
                        current_state = current[count_x]
                        count_x += 1
                        if current_state in self.final_states:
                            return zoznam1, cycle, cross, crossnumber
                        new_tape_symbol = current[count_x]
                        count_x += 1
                        tape_n.write_symbol(new_tape_symbol)
                        for i in tapes:
                            new_tape_symbol = current[count_x]
                            count_x += 1
                            i.write_symbol(new_tape_symbol)
                        current_direction = current[count_x]
                        count_x += 1
                        tape_n.move(current_direction)
                        for i in tapes:
                            current_direction = current[count_x]
                            count_x += 1
                            i.move(current_direction)

                        input_symbolss = ()
                        input_symbolss += tape_n.read_symbol(),
                        for i in tapes:
                            all_tapes.append(i)
                            input_symbolss += i.read_symbol(),

                        z = self._length_transition(current_state,
                                                    input_symbolss)
                        if z and current_state != self.reject_state:
                            for i in z:
                                zoznam.append(int(str(zoznam1) + str(i)))
                    except ValueError:
                        (a) = self._get_transition(current_state,
                                                   input_symbolss, poss)
                else:
                    (current), a, b = self._get_transition(
                        current_state, input_symbolss, poss)
                    current_state = current[count_x]
                    count_x += 1
                    new_tape_symbol = current[count_x]
                    count_x += 1
                    tape_n.write_symbol(new_tape_symbol)
                    for i in tapes:
                        new_tape_symbol = current[count_x]
                        count_x += 1
                        i.write_symbol(new_tape_symbol)

                    current_direction = current[count_x]
                    count_x += 1
                    tape_n.move(current_direction)
                    for i in tapes:
                        current_direction = current[count_x]
                        count_x += 1
                        i.move(current_direction)

                    input_symbolss = ()
                    input_symbolss += tape_n.read_symbol(),
                    for i in tapes:
                        all_tapes.append(i)
                        input_symbolss += i.read_symbol(),

        else:
            tape = TMTape(self.left_end + input_str,
                          blank_symbol=self.blank_symbol)
            current_direction = None
            current_state = self.initial_state
            symbolsss = ()
            while length > 0:
                symbolsss += self.left_end,
                length -= 1

            for i in str(none_zoznam):
                all_tapes = []
                all_tapes.append(tape)
                tapes = []
                current_directions = []
                input_symbols = []
                for state, paths in self.transitions.items():
                    for symbols in paths.keys():
                        length = len(symbols)
                for i in range(length - 1):
                    tapes.append(i)
                    current_directions.append(i)
                    input_symbols.append(i)
                for i in tapes:
                    tapes[i] = TMTape(self.left_end,
                                      blank_symbol=self.blank_symbol)
                    current_directions[i] = None
                count_x = 0

                try:
                    (current), a, b = self._get_transition1(
                        current_state, input_symbolsss, i)
                except ValueError:
                    state, current_state = self._get_transition1(
                        current_state, input_symbolsss, i)
                    break
                for i in tapes:
                    new_tape_symbol = current[count_x]
                    count_x += 1
                    i.write_symbol(new_tape_symbol)
                current_direction = current[count_x]
                count_x += 1
                tape.move(current_direction)
                for i in tapes:
                    current_direction = current[count_x]
                    count_x += 1
                    i.move(current_direction)

            symbolsss = ()
            while length > 0:
                symbolsss += self.left_end,
                length -= 1

            zz = self._length_transition(current_state, input_symbolsss)
            while True and counter1 < 200:
                counter1 += 1
                possition = 1
                if len(zz) > 1:
                    possition = random.randrange(1, len(zz) + 1)
                z1 += str(possition)

                all_tapes = []
                all_tapes.append(tape1)
                tapes = []
                current_directions = []
                input_symbols = []
                for state, paths in self.transitions.items():
                    for symbols in paths.keys():
                        length = len(symbols)
                for i in range(length - 1):
                    tapes.append(i)
                    current_directions.append(i)
                    input_symbols.append(i)
                for i in tapes:
                    tapes[i] = TMTape(self.left_end,
                                      blank_symbol=self.blank_symbol)
                    current_directions[i] = None
                count_x = 0

                input_symbolss = ()
                input_symbolss += tape.read_symbol(),
                for i in tapes:
                    all_tapes.append(i)
                    input_symbolss += i.read_symbol(),
                try:
                    (current), a, b = self._get_transition(
                        current_state, input_symbolss, possition)
                    current_state = current[count_x]
                    count_x += 1
                    new_tape_symbol = current[count_x]
                    count_x += 1
                    tape.write_symbol(new_tape_symbol)
                    for i in tapes:
                        new_tape_symbol = current[count_x]
                        count_x += 1
                        i.write_symbol(new_tape_symbol)
                    current_direction = current[count_x]
                    count_x += 1
                    tape.move(current_direction)
                    for i in tapes:
                        current_direction = current[count_x]
                        count_x += 1
                        i.move(current_direction)

                    input_symbolss = ()
                    input_symbolss += tape1.read_symbol(),
                    for i in tapes:
                        all_tapes.append(i)
                        input_symbolss += i.read_symbol(),

                    input_symbolss = ()
                    input_symbolss += tape1.read_symbol(),
                    for i in tapes:
                        all_tapes.append(i)
                        input_symbolss += i.read_symbol(),

                    zz = self._length_transition(current_state, input_symbolss)
                    if current_state == self.reject_state:
                        return z1, cycle, cross, crossnumber
                except ValueError:
                    (current) = self._get_transition(current_state,
                                                     input_symbol, possition)
                    return z1, cycle, cross, crossnumber
            cycle = True
            return z1, cycle, cross, crossnumber
Exemple #9
0
    def _validate_input_yield_final(self, input_str, final):
        current_state = self.initial_state
        current_direction = None
        cycle = False
        cycle1 = True
        crossnumber = []
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)
        tapes = []
        current_directions = []
        input_symbols = []

        for state, paths in self.transitions.items():
            for symbols in paths.keys():
                length = len(symbols)

        for i in range(length - 1):
            tapes.append(i)
            current_directions.append(i)
            input_symbols.append(i)
        for i in tapes:
            tapes[i] = TMTape(self.left_end, blank_symbol=self.blank_symbol)
            current_directions[i] = None
        for i in str(final):
            all_tapes = []
            all_tapes.append(tape)
            count_x = 0

            input_symbolss = ()
            input_symbolss += tape.read_symbol(),
            for t in tapes:
                all_tapes.append(t)
                input_symbolss += t.read_symbol(),

            z = self._length_transition(current_state, input_symbolss)
            if z:
                crossnumber.append(str(z[-1])[-1])
            try:
                (current), state1, current_state1 = self._get_transition1(
                    current_state, input_symbolss, i)
            except ValueError:
                current_state, state = self._get_transition1(
                    current_state, input_symbolss, i)
                cycle1 = False
                current = ()
                current += current_state,
                for s in state:
                    current += s,
                for t in tapes:
                    current += None,
                current += None,
                yield None, None, None, state, current_state, all_tapes, current, cycle, crossnumber
                break

            current_state = current[count_x]
            count_x += 1
            new_tape_symbol = current[count_x]
            count_x += 1

            for t in tapes:
                new_tape_symbol = current[count_x]
                count_x += 1
                t.write_symbol(new_tape_symbol)

            current_direction = current[count_x]
            count_x += 1
            tape.move(current_direction)
            for t in tapes:
                current_direction = current[count_x]
                count_x += 1
                t.move(current_direction)
            yield current_state, new_tape_symbol, current_direction, state1, current_state1, all_tapes, current, cycle, crossnumber

        input_symbolss = ()
        input_symbolss += tape.read_symbol(),
        current = ()
        current += current_state,
        current += tape.read_symbol(),
        for t in tapes:
            input_symbolss += t.read_symbol(),
            current += t.read_symbol(),
        for t in tapes:
            current += None,
        current += None,

        crossnumber.append('1')
        if current_state in self.final_states:
            cycle1 = False
            yield None, None, None, input_symbolss, current_state, all_tapes, current, cycle, crossnumber
        elif current_state in self.reject_state:
            cycle1 = False
            yield None, None, None, input_symbolss, current_state, all_tapes, current, cycle, crossnumber
        elif cycle1:
            yield None, None, None, input_symbolss, current_state, all_tapes, current, cycle1, crossnumber
Exemple #10
0
    def _validate_input_yieldd(self, input_str):
        """return final configuration"""
        current_state = self.initial_state
        zoznam = self._length_transition(current_state, self.left_end)

        z1 = ""
        current_direction = None
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)
        while zoznam:
            zoznam1 = zoznam.pop(0)
            current_direction = None
            tape1 = TMTape(self.left_end + input_str,
                           blank_symbol=self.blank_symbol)
            current_state = self.initial_state
            count = 0
            for possition in str(zoznam1):
                poss = possition
                count += 1
                input_symbol = tape1.read_symbol()
                if count == len(str(zoznam1)):
                    try:
                        (current_state, new_tape_symbol,
                         current_direction) = self._get_transition(
                             current_state, input_symbol, poss)
                        if current_state in self.final_states:
                            return zoznam1
                        tape1.write_symbol(new_tape_symbol)
                        tape1.move(current_direction)
                        input_symbol = tape1.read_symbol()
                        z = self._length_transition(current_state,
                                                    input_symbol)
                        if z and current_state != self.reject_state:
                            for i in z:
                                zoznam.append(int(str(zoznam1) + str(i)))
                    except ValueError:
                        (current_state,
                         new_tape_symbol) = self._get_transition(
                             current_state, input_symbol, poss)
                else:
                    (current_state, new_tape_symbol,
                     current_direction) = self._get_transition(
                         current_state, input_symbol, poss)
                    tape1.write_symbol(new_tape_symbol)
                    tape1.move(current_direction)
        else:
            current_state = self.initial_state
            zz = self._length_transition(current_state, input_str[0])
            current_direction = None
            tape = TMTape(self.left_end + input_str,
                          blank_symbol=self.blank_symbol)
            input_symbol = tape.read_symbol()
            while True:
                possition = 1
                if len(zz) > 1:
                    possition = random.randrange(1, len(zz) + 1)
                z1 += str(possition)
                try:
                    (current_state, new_tape_symbol,
                     current_direction) = self._get_transition(
                         current_state, input_symbol, possition)
                    tape.write_symbol(new_tape_symbol)
                    tape.move(current_direction)
                    input_symbol = tape.read_symbol()
                    zz = self._length_transition(current_state, input_symbol)
                    if current_state == self.reject_state:
                        return z1
                except ValueError:
                    (current_state, new_tape_symbol) = self._get_transition(
                        current_state, input_symbol, possition)
                    return z1
Exemple #11
0
    def _validate_input_yield1(self, input_str):
        """
        Check if the given string is accepted by this Turing machine.

        Yield the current configuration of the machine at each step.
        """
        current_state = self.initial_state
        current_direction = None
        tapes = []
        current_directions = []
        input_symbols = []
        tape = TMTape(self.left_end + input_str,
                      blank_symbol=self.blank_symbol)

        for state, paths in self.transitions.items():
            for symbols in paths.keys():
                length = len(symbols)

        for i in range(length - 1):
            tapes.append(i)
            current_directions.append(i)
            input_symbols.append(i)
        for i in tapes:
            tapes[i] = TMTape(self.left_end, blank_symbol=self.blank_symbol)
            current_directions[i] = None

        while current_state not in self.final_states and current_state not in self.reject_state:
            all_tapes = []
            all_tapes.append(tape)
            count = 0
            input_symbol = tape.read_symbol()
            j = 0
            input_sym = "('"
            input_sym += input_symbol
            input_sym += "', "

            for i in tapes:
                all_tapes.append(i)
                input_symbols[j] = i.read_symbol()
                input_sym += "'"
                input_sym += input_symbols[j]
                input_sym += "',"
                j += 1
            input_sym += ")"
            input_symbolss = literal_eval(input_sym)

            try:
                (current), state1, current_state1 = self._get_transition1(
                    current_state, input_symbolss)
                current_state = current[count]
                count += 1
            # except ValueError if __validate_input_yield have not
            # 3 values (__validate_input_yield end in else)
            except ValueError:
                state, tape_symbol = self._get_transition1(
                    current_state, input_symbolss)
                yield state, tape_symbol, all_tapes, current
                break
            new_tape_symbol = current[count]
            count += 1
            tape.write_symbol(new_tape_symbol)
            for i in tapes:
                new_tape_symbol = current[count]
                count += 1
                i.write_symbol(new_tape_symbol)

            current_direction = current[count]
            count += 1
            tape.move(current_direction)
            for i in tapes:
                current_direction = current[count]
                count += 1
                i.move(current_direction)
            yield current_state1, state1, all_tapes, current

        input_symbol = tape.read_symbol()
        j = 0
        input_sym = "('"
        input_sym += input_symbol
        input_sym += "', "

        for i in tapes:
            input_symbols[j] = i.read_symbol()
            input_sym += "'"
            input_sym += input_symbols[j]

            input_sym += "',"
            j += 1
        input_sym += ")"
        input_symbolss = literal_eval(input_sym)

        if current_state in self.final_states:
            yield current_state, input_symbolss, all_tapes, current
        elif current_state in self.reject_state:
            yield current_state, input_symbolss, all_tapes, current
Exemple #12
0
    def _validate_input_yieldd_none_final(self, input_str, none_zoznam):
        """return final configuration"""
        current_state = self.initial_state
        current_direction = None
        tape = TMTape(self.left_end+input_str, blank_symbol=self.blank_symbol)

        zoznam = []
        zoznam.append(none_zoznam)
        cross = None
        crossnumber = None
        cycle = False
        counter = 0
        counter1 = 0
        z1 = str(none_zoznam) 
        while zoznam and counter < 200:
            if len(zoznam) > 1 and cross == None and crossnumber == None :
                cross = len(str(zoznam[-1]))
                crossnumber = str(zoznam[-1])[-1]
            counter +=1 
            zoznam1 = zoznam.pop(0)
            current_direction = None
            tape_n = TMTape(self.left_end+input_str, blank_symbol=self.blank_symbol)
            current_state = self.initial_state
            count = 0
            for possition in str(zoznam1):
                poss = possition
                count += 1
                input_symbol = tape_n.read_symbol()
                if count == len(str(zoznam1)):
                    try:
                        (current_state, new_tape_symbol, current_direction) = self._get_transition(current_state, input_symbol,poss)
                        if current_state in self.final_states:
                            return zoznam1, cycle, cross, crossnumber
                        tape_n.write_symbol(new_tape_symbol)
                        tape_n.move(current_direction)
                        input_symbol = tape_n.read_symbol()
                        z = self._length_transition(current_state, input_symbol)
                        if z and current_state != self.reject_state:
                            for i in z:
                                zoznam.append(int(str(zoznam1)+str(i)))
                    except ValueError:
                        (current_state, new_tape_symbol) = self._get_transition(current_state, input_symbol,poss)
                else:
                    (current_state, new_tape_symbol, current_direction) = self._get_transition(
                    current_state, input_symbol,poss)
                    tape_n.write_symbol(new_tape_symbol)
                    tape_n.move(current_direction)  
        else:
            tape = TMTape(self.left_end+input_str, blank_symbol=self.blank_symbol)
            current_direction = None
            current_state = self.initial_state
            for i in str(none_zoznam):
                input_symbol = tape.read_symbol()
                try:
                    (current_state, new_tape_symbol, current_direction),state1,current_state1 = self._get_transition1(current_state, input_symbol,i)
                except ValueError:
                    state,current_state = self._get_transition1(current_state, input_symbol,i)
                    break
                tape.write_symbol(new_tape_symbol)
                tape.move(current_direction)

            input_symbol = tape.read_symbol()
            zz = self._length_transition(current_state, input_symbol)
            while True and counter1 < 200:
                counter1 +=1
                possition = 1
                if len(zz) > 1:
                    possition = random.randrange(1,len(zz)+1)
                z1+=str(possition)
                try:
                    (current_state, new_tape_symbol, current_direction) = self._get_transition(current_state, input_symbol,possition)    
                    tape.write_symbol(new_tape_symbol)
                    tape.move(current_direction)
                    input_symbol = tape.read_symbol()
                    zz = self._length_transition(current_state, input_symbol)
                    if current_state == self.reject_state:
                        return z1, cycle, cross, crossnumber
                except ValueError:
                    (current_state, new_tape_symbol) = self._get_transition(current_state, input_symbol,possition)
                    return z1, cycle, cross, crossnumber
            cycle = True
            return z1, cycle, cross, crossnumber