This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
#An attempt at finding a solution to the challenge #219 of /r/DailyProgrammer | |
#(http://www.reddit.com/r/dailyprogrammer/comments/3aewlg/) | |
#I am using a genetic algorithm to find an (usually approximate) solution. | |
from __future__ import print_function, division | |
import genetic_algorithm as ga | |
import sys, random, argparse | |
if sys.version_info.major < 3: | |
input = raw_input |
This file contains hidden or 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
N,L="0123456789","ABCDEFGHIJKLMNOPQRSTUVWXYZ";A=N+L;D="! %')-/135! %')-/135\"$24+#&(,.0*6987";P=" !\"#$%&'() !\"#$%&'()*+,-./0123456789";p=lambda l,i:l.split("\t")[i].strip() | |
def G(s,f=0): | |
C,V="","" | |
for c in s.upper(): | |
if c in "AEIOU":V+=c | |
else:C+=c | |
C=[C,C[0]+C[2:]][f and len(C)>3];return(C+V+"X"*3)[:3] | |
C=lambda n,c,s,g,m,a,C:(lambda c:c+L[sum(ord(([D,P][i%2])[A.index(x)])-32 for i,x in enumerate(c))%26])(G(c)+G(n,1)+str(a)[-2:]+"ABCDEHLMPRST"[m-1]+"%02d"%(g+40*s)+{p(l,1):p(l,0)for l in open("belfiore.txt").read().splitlines()}[C.upper()]) |
This file contains hidden or 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
#pCalc - Nimrod version7 | |
import strutils, math, tables, logging | |
type | |
EProgramError = object of E_Base | |
EStackError = object of EProgramError | |
EStackUnderflowError = object of EStackError | |
ESyntaxError = object of EProgramError | |
ERuntimeError = object of EProgramError | |
EDivisionByZeroError = object of ERuntimeError | |
TSymbol = enum |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function, division | |
import sys, re | |
if sys.version_info.major < 3: | |
input = raw_input | |
#I wonder... how difficult would be writing a parser that takes well-formed | |
#BNF in input and outputs a recursive descent parser based on that grammar? | |
#I'd have to recognize, name and put into an enum tokens ('...'), create a | |
#dictionary of identifiers (<...>), and each identifier will be assigned |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function, division | |
from contextlib import contextmanager | |
import sys | |
if sys.version_info.major < 3: | |
input = raw_input | |
class CodeGenerator(object): | |
def __init__(self, tab=" "): |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function, division | |
import sys | |
from time import sleep | |
if sys.version_info.major < 3: | |
input = raw_input | |
#THIS! IS! A! FUCKING! MESS! |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
#by fbWright | |
from __future__ import print_function, division | |
import sys, bs4, requests, os, os.path, json | |
from urllib.parse import urlparse, urljoin | |
from unidecode import unidecode | |
if sys.version_info.major < 3: | |
input = raw_input |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
#Finally finished! 2014-07-26T16:25, 768 bytes - with interactive prompt | |
# and reading from file | |
#TODO: exception-checking, maybe continuation | |
#Brainfuck in python | |
#Brainfuck instructions: | |
# > increment the data pointer (to point to the next cell to the right). | |
# < decrement the data pointer (to point to the next cell to the left). | |
# + increment (increase by one) the byte at the data pointer. |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function, division | |
import sys, time | |
if sys.version_info.major < 3: | |
input = raw_input | |
def compress(data): | |
freq = {} | |
for line in data.splitlines(): |
This file contains hidden or 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
( frogue.fs 2015-02-23T09.05 by fbwright ) | |
( A [simple] roguelike in gforth; move the @, collide with # ) | |
( And [comments excluded] fits into a block [1000/1024 B] ) | |
variable &i 64 constant W 16 constant H create _M W H * chars | |
allot 6 constant MS 32 constant MM create _O MS MM * chars allot | |
: U 0 -1 ; : D 0 1 ; : R 1 0 ; : L -1 0 ; : # W * + _M + ; : & | |
MS * _O + ; : b? H 1- mod 0= swap W 1- mod 0= or ; : p? c@ '# <> | |
; : #d 2dup at-xy # c@ emit ; : #n 2dup # -rot b? if '# else bl | |
then swap c! ; : &xy@ & 1+ dup c@ swap 1+ c@ ; : &xy! & 1+ rot | |
over c! 1+ c! ; : &d dup &xy@ at-xy & c@ emit ; : &n &i @ & swap |
NewerOlder