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
#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
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
#!/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 |
OlderNewer