<jupyter_start><jupyter_text>Partie 2<jupyter_code>class CircularLinkedList(object):
    def __init__(self, init_values):
        self.min_ = min(init_values)
        self.max_ = max(init_values)
        self.head = None
        self.first = None

        history = SortedDict()
        last = None
        for value in init_values:
            node = CircularLinkedList.Node(value, None)
            if last is None:
                self.head = node # First item
            else:
                last.next = node # Others items
            history[value] = node
            last = node

        last.next = self.head # Circular

        for a, b in Iter.multimove(history.values(), 2):
            b.iPrev = a

        history.peekitem(0)[1].iPrev = history.peekitem()[1]

        self.first = history.peekitem(0)[1]


    def __next__(self):
        self.head = next(self.head)

    class Node(object):
        def __init__(self, value, next_):
            self.value = value
            self.next = next_
            self.iPrev = None

        def __next__(self):
            return self.next
def turn(cll):
    taked = (cll.head.next.value, cll.head.next.next.value, cll.head.next.next.next.value)
    target = cll.head.iPrev
    while target.value in taked:
        target = target.iPrev

    last_taken = cll.head.next.next.next
    cll.head.next, target.next, last_taken.next = last_taken.next, cll.head.next, target.next

    next(cll)
def display(cll, join=False):
    res = []

    last = cll.head
    res.append(last.value)
    while (last := last.next) != cll.head:
        res.append(last.value)
    
    if join:
        return ''.join(map(str, res))
    else:
        return res
cll = CircularLinkedList(data)
for i in range(100):
    turn(cll)
cll.head = cll.first
display(cll, join=True)[1:]<jupyter_output><empty_output><jupyter_text>Partie 2.2<jupyter_code>data += range(max(data) + 1, 1000001)
cll = CircularLinkedList(data)
for i in range(10000000):
    turn(cll)
cll.head = cll.first
a = cll.head.next.value
b = cll.head.next.next.value

a, b, a*b<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12047619047619047, 'fraction_numerical': 0.01380952380952381, 'mean_word_length': 2.262422360248447, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '628415', 'license': 'MIT', 'n_tokens_mistral': 755, 'n_tokens_neox': 719, 'n_words': 151, 'path': 'AdventOfCode 2020/AOC.23.ipynb', 'repo_name': 'BhasherBEL/ProgrammingChallenges', 'size': '2100'}