Skip to content

Instantly share code, notes, and snippets.

View WitherOrNot's full-sized avatar
🤠
yeehaw

WitherOrNot

🤠
yeehaw
View GitHub Profile
@WitherOrNot
WitherOrNot / pfactor.py
Created June 14, 2019 05:05
Polynomial factorizer using Rational Root Theorem
from __future__ import division
def gcd(a, b):
if a == 0:
return 1
while b != 0:
t = b
b = a % b
a = t
@WitherOrNot
WitherOrNot / helloworld_obf.py
Created June 14, 2019 05:04
Hello World obfuscated to only 8 characters, aside from one pre-defined function
def _(s=None,a=0):
if isinstance(s, str):
try:
if a == 0:
exec(s)
elif a == 1:
return eval(s)
except Exception as e:
return repr(e)
elif s == 0:
@WitherOrNot
WitherOrNot / onefunc.py
Created June 14, 2019 05:03
obfuscates python code to only use 8 characters, aside from one pre-defined function
# 8 characters: _ ~ + , ( ) [ ] and 1 function
# code.py is the original code
# obf.py is the obfuscated code
def _(s=None,a=0):
if isinstance(s, str):
try:
if a == 0:
exec(s)
elif a == 1:
@WitherOrNot
WitherOrNot / hanoi.py
Last active August 30, 2020 19:46
Towers of Hanoi solver without recursion
import sys
import itertools
no_of_disks = int(raw_input("No. of disks: ")) if len(sys.argv) < 2 else int(sys.argv[1])
def disk_to_move(move_number):
diff = move_number ^ (move_number + 1)
return bin(diff)[2:].count("1") - 1
def generate_move(disk_to_move, disk_states):
@WitherOrNot
WitherOrNot / bf.py
Last active July 25, 2019 00:43
BrainFuck Interpreter
import sys
import time
import os
class _Getch:
"""Gets a single character from standard input. Does not echo to the
screen."""
def __init__(self):
try:
self.impl = _GetchWindows()
@WitherOrNot
WitherOrNot / lsystems.py
Last active January 9, 2020 20:02
Turtle that draws L-Systems
import turtle
t = turtle.Turtle()
s = turtle.Screen()
t.pu()
t.goto(0,0)
t.pd()
t.speed(0)
# mod here
@WitherOrNot
WitherOrNot / eca.py
Created June 14, 2019 04:56
Elementary Cellular Automaton Image Generator
from PIL import Image
import random
raw_input = input
rule = int(raw_input("Rule: "))
itn = int(raw_input("Number of rows: "))
w = (2*itn)-1
print("")
@WitherOrNot
WitherOrNot / base64_cg.py
Created June 14, 2019 04:55
Code golf for base64 encoder/decoder
#"""
#Encoder
c=[chr(x) for x in range(65,91)+range(97,123)+range(48,58)+[43,47]];a=raw_input();p=(3-(len(a)%3))%3;a+="\x00"*p;a=''.join(["0"*(8-len(x))+x for x in [bin(ord(x)).replace("0b","") for x in a]]);a=[c[int(x,2)] for x in [a[i:i+6] for i in range(0,len(a),6)]];a=''.join(a[:(len(a)-p)])+"="*p;print(a)
#"""
"""
#Decoder
c=[chr(x) for x in range(65,91)+range(97,123)+range(48,58)+[43,47,61]];a=raw_input();a=''.join(["0"*(6-len(x))+x for x in [bin(c.index(x)%64).replace("0b","") for x in a]]);a=''.join([chr(int(a[i:i+8],2)) for i in range(0,len(a),8)]);print(a)
#"""
from PIL import Image
from fractions import gcd
from math import sqrt
w = 2048
img = Image.new("RGB", (w, w), color=(255,255,255))
for i in range(1,w):
for j in range(1,w):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.