Skip to content

Instantly share code, notes, and snippets.

match=0 #var for match brackets
i=0 #program counter
tape=[0]*30000 #"infinite" tape
t_cnt=15000 #tape counter
ops={'>':'p_cnt+=1', #map of chars to python code
'<':'t_cnt-=1',
'+':'tape[t_cnt]+=1',
'-':'tape[t_cnt]-=1',
'.':'print(chr(tape[t_cnt]),end="")',
#!/usr/bin/env python
'''
@author AlexHuleatt
Terminal-based Tron or Light-cycles remake.
Made just for fun.
Uses a breadth-first search for the enemy.
Can be pretty easily tricked into going down 1-cell wide sections, as long as end is open.
Game was sped up to make this slightly more challenging.
'''
Google deprecated their search api
Google results pages do not immediately contain result urls (I checked)
Here is a really bad script to get the first page of results and a bunch of other stupid irrelevant urls
You need selenium and firefox.
Works for me on OSX.
Suck it Google, you can't control me.
'''
Nice reasonably fast primality test. Certainly true for p < 2^64.
Uses conjectured (John Selfridge) primality test for numbers congruent to 2 or 3 mod 5, and deterministic miller-rabin otherwise.
modfib is modpow but with fibonacci instead. Uses recursive identities to get fib(x) in O(log(x)) (linear on the length of x)
millerRabin_small is going to be better for any n < 2**64
'''
@Alex-Huleatt
Alex-Huleatt / dungeon_maker.py
Last active June 19, 2018 15:29
Simple dungeon maker. Guaranteed connectedness.
'''
@author AlexHuleatt
Generate a simple, connected dungeon. Focus is on rooms, not maze-like features.
Output of get_dungeon is two sets:
1. A set of (y,x) tuples representing the position of walls
2. A set of (y,x) tuples representing the walls removed to make doors
'''
from random import randint, sample