File size: 1,817 Bytes
ab18fdf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b3ea2a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# === TOOLS ===
def letter_counter(word, letter):
    """
    Count the number of occurrences of a letter in a word or text.

    Args:
        word (str): The input text to search through
        letter (str): The letter to search for

    Returns:
        str: A message indicating how many times the letter appears
    """
    word = word.lower()
    letter = letter.lower()
    count = word.count(letter)
    return count

def prime_factors(n):
    """
    Compute the prime factorization of a positive integer.
    Args:
        n (int): The integer to factorize. Must be greater than 1.
    Returns:
        List[int]: A list of prime factors in ascending order.
    Raises:
        ValueError: If n is not greater than 1.
    """
    n = int(n)
    if n <= 1:
        raise ValueError("Input must be an integer greater than 1.")

    factors = []
    while n % 2 == 0:
        factors.append(2)
        n //= 2

    divisor = 3
    while divisor * divisor <= n:
        while n % divisor == 0:
            factors.append(divisor)
            n //= divisor
        divisor += 2

    if n > 1:
        factors.append(n)

    return factors

def roll_dice(faces, rolls):
    """
    Simulate rolling dice.

    Args:
        faces (int): Number of faces on the die.
        rolls (int): Number of times to roll the die.

    Returns:
        List[int]: A list of results from each roll.
    """
    import random
    return [random.randint(1, faces) for _ in range(rolls)]

def coin_flip(flips):
    """
    Simulate flipping a coin multiple times.

    Args:
        flips (int): Number of times to flip the coin.

    Returns:
        List[str]: A list of results from each flip ("Heads" or "Tails").
    """
    import random
    return ["Heads" if random.randint(0, 1) == 0 else "Tails" for _ in range(flips)]