This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, re | |
globals_ = globals() | |
def setglobals(g): | |
global globals_ | |
globals_ = g | |
def goto(l): | |
global globals_ | |
with open(sys.argv[0], "rb") as f: | |
data = f.read() | |
data_ = data.split('\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import * | |
from struct import calcsize, pack | |
from PIL import Image | |
CreateDC = windll.gdi32.CreateDCA | |
CreateCompatibleDC = windll.gdi32.CreateCompatibleDC | |
GetDeviceCaps = windll.gdi32.GetDeviceCaps | |
CreateCompatibleBitmap = windll.gdi32.CreateCompatibleBitmap | |
BitBlt = windll.gdi32.BitBlt | |
SelectObject = windll.gdi32.SelectObject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import * | |
class Clipboard: | |
def __init__(self): | |
self.strcpy = cdll.msvcrt.strcpy | |
self.OpenClipboard = windll.user32.OpenClipboard | |
self.CloseClipboard = windll.user32.CloseClipboard | |
self.EmptyClipboard = windll.user32.EmptyClipboard | |
self.GetClipboardData = windll.user32.GetClipboardData | |
self.SetClipboardData = windll.user32.SetClipboardData | |
self.GlobalAlloc = windll.kernel32.GlobalAlloc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from operator import * | |
class Math(Exception): | |
pass | |
class InfixException(Math): | |
pass | |
re_float = re.compile(r'^(\d+\.\d*)|(\d*\.\d+)$') | |
re_int = re.compile(r'^\d+$') | |
class Infix: | |
def __init__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def swap(lst,a,b): | |
lst[a] = lst[a] ^ lst[b] | |
lst[b] = lst[a] ^ lst[b] | |
lst[a] = lst[a] ^ lst[b] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stoogesort(lst): | |
def recurse(lst,i,l): | |
if lst[l] < lst[i]: | |
lst[i], lst[l] = lst[l], lst[i] | |
if (l - i + 1) >= 3: | |
t = (l - i + 1) / 3 | |
recurse(lst, i, l-t) | |
recurse(lst, i+t, l) | |
recurse(lst, i, l-t) | |
recurse(lst,0,len(lst)-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def oddeven(lst): | |
sorted_ = False | |
while not sorted_: | |
sorted_ = True | |
for i in range(1,len(lst)-1,2): | |
if a[i] > a[i+1]: | |
a[i], a[i+1] = a[i+1], a[i] | |
sorted_ = False | |
for i in range(0,len(lst)-1,2): | |
if a[i] > a[i+1]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gnomesort(lst): | |
pos = 1 | |
while pos < len(lst): | |
if lst[pos] >= lst[pos-1]: | |
pos += 1 | |
else: | |
lst[pos], lst[pos-1] = lst[pos-1], lst[pos] | |
if pos > 1: | |
pos -= 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def combsort(lst): | |
gap = len(lst) | |
shrink = 1.3 | |
swapped = True | |
while not (gap == 1 and not swapped): | |
gap = int(gap/shrink) | |
if gap < 1: | |
gap = 1 | |
i = 0 | |
swapped = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Cocktail(lst): | |
swapped = True | |
while swapped: | |
swapped = False | |
for i in range(0,len(lst)-2): | |
if lst[i] > lst[i+1]: | |
lst[i], lst[i+1] = lst[i+1], lst[i] | |
swapped = True | |
if not swapped: | |
break |
NewerOlder