Пример #1
0
def move_to_front_c(e, v: collections.deque):
    eFound = v.count(e)
    counter = eFound
    while counter != 0:
        counter -= 1
        v.remove(e)
        v.appendleft(e)
    print(v)
Пример #2
0
def getNextRequest(discipline: str, queue: deque):
    if (discipline == "FIFO"):
        return queue.popleft()
    elif (discipline == "LIFO"):
        return queue.pop()
    elif (discipline == "RAND"):
        num = np.random.randint(0, queue.count())
        res = queue[num]
        queue.remove(res)
        return res
    else:
        print("неправильная дисциплина для getNextRequest")
        return None
Пример #3
0
def is_solved(s: deque, goal: list, limit=1):
    if s.count(goal) > limit:
        return True
    return False
Пример #4
0
def display_occurrences(source_deque: deque) -> None:

    for i in range(len(source_deque)):
        temp = source_deque[i]
        count = source_deque.count(temp)
        print(f"{temp} occurs {count} time{'s' if count > 1 else ''} in deque")