# Python's sequences as Vibe takes them (D188): negative indexes, slices with a step, a
# slice as a new list, starred elements and targets, loops over a str and over a list of
# tuples, comprehensions whose types are inferred, and split's result used at once. Its
# output is CPython's.


def main() -> None:
    xs: list[int] = [10, 20, 30, 40, 50, 60, 70]
    s = "abcdefghij"
    print(xs[-1], xs[-7], s[-1], "hello"[-2])
    print(xs[1:6:2], xs[::-1], xs[5:1:-2])
    print(s[::3], s[8:2:-2], s[::-1])
    ws: list[int] = xs[1:3]
    ws.append(5)
    ys = xs[:]
    ys[0] = 99
    print(len(xs), ws, xs[0], ys[0])
    zs = [*ws, 4, *ys[5:]]
    print(zs)
    h, *rest = "hey"
    first, *middle, last = xs
    print(h, rest, first, middle, last)
    vowels = 0
    for ch in s:
        if ch in "aeiou":
            vowels = vowels + 1 if vowels < 100 else vowels
    print(vowels)
    pairs: list[tuple[int, int]] = [(1, 10), (2, 20)]
    for k, v in pairs:
        print(k, v)
    squares = [x * x for x in range(5) if x % 2 == 0]
    by_ten = {x: x // 10 for x in xs[:3]}
    residues = {x % 3 for x in range(10)}
    print(squares, by_ten, residues)
    print("a, b, c".split(", ")[1], len("x y z".split()))


if __name__ == "__main__":
    main()
