Skip to content

Instantly share code, notes, and snippets.

@paralysedforce
paralysedforce / markov.py
Created July 9, 2015 18:18
Markov Text Generator
#!/usr/bin/env python
"""
Implements a simple Markov text generator
"""
from __future__ import print_function
from collections import Counter
from string import ascii_uppercase as AU
from sys import argv
@paralysedforce
paralysedforce / quantum_rw.py
Last active January 3, 2017 03:50
Discrete Quantum Random Walk Implementation
"""
Implementation of a discrete quantum random walk
Inspired by "Quantum Walks and their Algorithmic Applications" by Andris
Ambainis, which you can find here: https://arxiv.org/abs/quant-ph/0403120
"""
import numpy as np
import matplotlib.pyplot as plt
def flip(state, parameters):
@paralysedforce
paralysedforce / .vimrc
Created August 8, 2017 02:05
My vimrc
"Vundle Setup
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'christoomey/vim-tmux-navigator'
call vundle#end()
filetype plugin indent on
set autoread
"""""""""""""""""""""
@paralysedforce
paralysedforce / mandelbrot.py
Created July 28, 2019 15:27
Generates a png of the Mandelbrot set
import numpy as np
import matplotlib.pyplot as plt
import numba
MAX_ITER = 32
x_min, x_max = -2, 1
y_min, y_max = -2, 2
resolution_along_axis = 2 ** 13
# Note that the final image size will be resolution_along_axis ** 2
@paralysedforce
paralysedforce / npuzzle.py
Created October 20, 2020 04:08
A 3x3 Jeu-de-tacquin puzzle solver
"""
A 3x3 Jeu-de-tacquin puzzle solver
"""
import sys
import heapq
WINNING_POS = "123456780"
@paralysedforce
paralysedforce / fizzbuzz.py
Created December 2, 2020 00:27
Python3 Fizzbuzz, golfed down to 59 characters
n=0
while n<101:n+=1;print('FizzBuzz'[n%-3&4:12&8-n%5]or n)
@paralysedforce
paralysedforce / helloworld.py
Created November 17, 2021 03:52
Finally! A Hello World Python Script That Fully Conforms To Object Orientation Patterns!
from __future__ import print_function
class Word(object):
def __init__(self, word):
self.word = word
def __str__(self):
return str(self.word)