Skip to content

Instantly share code, notes, and snippets.

@Gribouillis
Gribouillis / matrices.py
Last active December 13, 2024 08:25
An algorithm to partition a bipartite graph
from collections import defaultdict
from itertools import count
import numpy as np
__version__ = "2024.12.13"
def create_graph(a):
"""Returns a graph from a n x n array of bools
@Gribouillis
Gribouillis / vengy.py
Created January 6, 2025 14:37
Testing a formula puporting to give the k-th prime number
# testing a formula for the k-th prime number
# https://math.stackexchange.com/questions/5019919/an-exact-formula-for-the-k-th-prime-number
from mpmath import ceil, ln, mp, mpf, zeta
mp.dps = 500
mp.pretty = True
one = mpf("1")
two = mpf("2")
@Gribouillis
Gribouillis / self-socket.py
Created February 2, 2025 22:40 — forked from bregma/self-socket.py
Using the self-pipe trick in Python3
#!/usr/bin/python3
#
# Investigate the use of the self-pipe trick from Python
#
import logging
import os
import selectors
import signal
import struct