Skip to content

Instantly share code, notes, and snippets.

View bennuttall's full-sized avatar

Ben Nuttall bennuttall

View GitHub Profile
@bennuttall
bennuttall / solutions.txt
Last active May 8, 2024 16:43
Wordle checker
CIGAR
REBUT
SISSY
HUMPH
AWAKE
BLUSH
FOCAL
EVADE
NAVAL
SERVE
@bennuttall
bennuttall / conway.py
Last active April 2, 2024 11:42
Conway's Game of Life in Python with PyGame - by Ben Nuttall & Amy Mather
from time import sleep
from random import randint
import pygame
pygame.init()
#Initialise the screen
xmax = 600 #Width of screen in pixels
ymax = 600 #Height of screen in pixels
screen = pygame.display.set_mode((xmax, ymax), 0, 24) #New 24-bit screen
@bennuttall
bennuttall / dots.py
Last active August 27, 2023 00:05
DOTS Python code
from gpiozero import InputDevice
NUM_PINS = 28
PULL_UP_PINS = [2, 3]
PINS = list(set(list(range(NUM_PINS))) - set(PULL_UP_PINS))
MINIMUM_DOTS_REQUIRED = 5
COLOR_PINS = {
27: 'red',
10: 'green',
@bennuttall
bennuttall / hands.txt
Last active August 14, 2023 19:58
Poker hands solution
High Card: 1,302,540 (50.1177%)
Pair: 1,098,240 (42.2569%)
Two Pair: 123,552 (4.7539%)
Three of a Kind: 54,912 (2.1128%)
Straight: 10,200 (0.3925%)
Flush: 5,108 (0.1965%)
Full House: 3,744 (0.1441%)
Four of a Kind: 624 (0.0240%)
Straight Flush: 36 (0.0014%)
Royal Flush: 4 (0.0002%)
@bennuttall
bennuttall / img.py
Created March 29, 2023 11:36
Scripts for organising photos
from pathlib import Path
from structlog import get_logger
from PIL import Image
logger = get_logger()
dir = Path.cwd()
import json
import argparse
with open("words.json") as f:
WORDS = json.load(f)
def starts_with(chars):
return {
word
for word in WORDS
from pathlib import Path
from collections import defaultdict
missing_wheels = defaultdict(set)
extra_wheels = defaultdict(set)
rewrites = set()
total_missing = 0
total_extra = 0
with open('missing.txt') as f:
from string import ascii_lowercase
import argparse
import random
LINUX_SYSTEM_DICT = '/usr/share/dict/american-english'
MAC_SYSTEM_DICT = '/usr/share/dict/words'
BIG_WORDLIST = 'words.txt'
# wordlist = LINUX_SYSTEM_DICT
wordlist = MAC_SYSTEM_DICT
package=$1
mapfile -t versions < versions.txt
for v in "${versions[@]}"
do
echo $v
date
/usr/bin/time -f "piw-import $package-$v-*.whl -y --duration 00:%E" -ao imports.sh pip3 wheel $package==$v -q --no-deps --no-binary $package --extra-index-url https://www.piwheels.org/simple --prefer-binary
done
from pathlib import Path
from piwheels.slave.builder import Builder, Wheel
b = Builder(None, None)
w = Wheel(Path('awkward-1.0.0-cp37-cp37m-linux_armv7l.whl'))
with open('dependencies.txt', 'w') as f:
for pkg in w.dependencies['apt']:
f.write(pkg + '\n')