Skip to content

Instantly share code, notes, and snippets.

View katt64's full-sized avatar

Stephanie B. katt64

View GitHub Profile
@katt64
katt64 / swedishords.py
Last active January 31, 2018 16:09
Parses Swedish ordinals from right to left.
#!/usr/bin/env python3
"""
Parses Swedish ordinals from right to left and
determines if they are grammatically correct.
It kind of works! :P
Stephanie Björk (Katt) <katt16777216@gmail.com> <3
"""
@katt64
katt64 / fsm.py
Last active January 28, 2018 23:15
My first finite state machines on Python
#!/usr/bin/env python3
"""
A module-less python code that prints a line if it matches a certain regular
expression.
"""
# Our regular expression collections. These regular expressions have been
# hand-compiled into their finite state machine representations.
regex = {
r'[abc]+': (
@katt64
katt64 / unrot.py
Last active January 25, 2018 21:40
Cryptanalysis against the Caesar ciphers
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Cryptanalysis for any shifts of the Caesar ciphers in English.
Stephanie Björk (Katt) <katt16777216@gmail.com>
"""
import re
def freq(s: str) -> dict:
@katt64
katt64 / pythagorean.py
Last active January 25, 2018 19:18
I write shit. 😘😘
#!/usr/bin/env python3
"""
pythagorean.py Generate Pythagorean triples
Other people: sqrt(a**2 + b**2) == c
Me, an I N T E L L E C T U A L: abs(complex(a, b)) == c
"""
from math import sqrt, floor
def triples(n: int) -> list:
@katt64
katt64 / pn2.py
Created January 22, 2018 18:59
Polish Notation parsing algorithm based off Wikipedia
#!/usr/bin/env python3
def pn(tokens: (list, tuple)) -> (int, float):
"""Parses a Polish Notation expression using a different algorithm."""
operators = []
operands = []
pendingop = None
for token in tokens:
@katt64
katt64 / prac.py
Last active January 22, 2018 00:10
Password practice for stupid people like me :p https://imgur.com/a/y1TE2
#!/usr/bin/env python3
# -*- coding: utf8 -*-
"""
pracpass Password practice
Old woman yells at cloud
------------------------
The following paragraph explains why we need *Password practice*.
See, my memory is super horrible and my passwords aren't even that long.
@katt64
katt64 / pn.py
Last active January 21, 2018 22:51
Interactive Polish Notation calculator
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
pn.py Interactive Polish Notation calculator
So, I’ve realized that while there were many Reverse Polish cal‐
culators, there were not very many Polish Notation calculators.
That’s probably because Reverse Polish calculators are a bit eas‐
ier and more useful to make in the domains of computer science.
In the spirit of making weird fancy calculators, here goes a Pol‐
@katt64
katt64 / calc.py
Last active January 19, 2018 00:20
A simple interactive calculator in Python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
calc.py Simple calculator in Python.
S. Björk (Katt) <katt16777216@gmail.com>
"""
def rpn(tokens: (list, tuple)) -> (int, float):
"""Evaluates a reverse-polish notation expression given as a list of tokens.
@katt64
katt64 / friends.tmac
Last active January 5, 2018 12:01
When you just don't have friends and your ex- cheated on you. https://www.docdroid.net/mZp0wLZ/friends.pdf
.ig
friends.tmac I have no friends.
Stephanie B. (Katt) <katt16777216@gmail.com>
You are freely allowed to do whatever you want with this macro package and
the code in it, as long as you don't have friends.
Copyright \(co \n[year] a desolate gurl, no friends in reserves.
..