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 random | |
import math | |
real_weights = {} | |
for w in "+-*/": | |
real_weights[w] = random.random() | |
s = sum(real_weights[w] for w in real_weights) | |
for w in real_weights: |
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 queue import PriorityQueue | |
import sys | |
class Element: | |
def __init__(self, score, val): | |
self.score = score | |
self.val = val | |
def __str__(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
import itertools | |
import random | |
gram = { | |
"T": [ | |
["0"], | |
["1"], | |
["x"], | |
["y"], | |
["+", "T", "T"], |
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 PIL import Image | |
import sys | |
datas = [] | |
for name in range(3): | |
im = Image.open("imgs/img-%d.png" % name) | |
data = im.getdata() | |
bits = [] | |
for i in range(26): | |
for j in range(16): |
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 PIL import Image | |
import sys | |
datas = [] | |
for name in range(3): | |
im = Image.open("imgs/img-%d.png" % name) | |
data = im.getdata() | |
bits = [] | |
for i in range(26): | |
for j in range(16): |
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
#include <cstdio> | |
int is_big(int j) { | |
// Check the condition many times to be sure ;) | |
while (1) { | |
if (j >= 100) { | |
return 1; | |
} | |
} | |
return 0; |
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
# Performance impact: | |
# - no tracing: fibo_recursive 2.02ms, silly_loop 85.33ms | |
# - hand-rolled dbg: 222.72ms, 173.75ms | |
# - default traceback dbg2: 1215.88ms, 173.64ms | |
# In other words, there's ~100% cost during execution even | |
# when no trace (i.e. calls and returns) actually happen. | |
# When tracing, the slowdown is ~600 times for default | |
# traceback (with pretty printing and stuff), or ~100 times | |
# for handwritten basic traceback. |
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
0eNrsvV1vZsmxpfdXjL60qxo7vzMFjAED59Y2MFcDGAdCS11npuBWSyi1Bj4e8L+bfIsssZgfEU++EnNvn7yZwaHEEndGZESstTIi/scPf/jlb5/+8uXzr7/9/g9//vP//cPv/sfff/LXH373f736P5/+s89//POvX3/818//9deffnn62W///pdPP/zuh8+/ffrTDx9++PWnPz39Xz99+fzbf/vTp98+//HjH//8pz98/vWn3/785YeHDz98/vXnT//PD78zD//64YdPv/72+bfPn77+g7f/499//+vf/vSHT18e/wvCP/Xhh7/8+a+Pv/3nX5/+hsd/8aP98MO/P/1/P4bH/5mfP3/59Mev/6n/8MPjX/3blz//8vs/fPpvP/33z4+//fgrf/9nf//4H/98+6f++vQf/NvnL3/97ffV9/33z19++9vjT779XV//Gx//y9NXPR3Lbz89nZGx+cMPf/7Lpy8/ff1f/+F/+z/+5fF3/vy33/7yN/avPnz9d3/9+h23P808/T//9cunT7++PrLPP//wO/f43/385Y9/+/zb7f80Dx+++4/Dw78+/mu2++vp8T9/ePU7L1aw1ArHKYzg7Alt4N/+x2OTmKNjE4dvhjmFUaJfYRQzNoqFRjEdo3hqlHPYxMQVNrFjmxgrWcF3rBC+/WV/+vTz57/96eOnXx7/oC+PpvjLn3/51LgZ7qsVzD/Qo0yoXar1t8a/n+Kffvrll4+//PSnv3Sz2vHQdouX/6FvPnG/SxxP/8ef/vLTl5vf/u6H//UHdt/efL7tfH4in/9ioCt8v+7zs+rzj6sZP+q+vuiMb672+Un3+eYA1r+Q71vl5xti/gt9v1N+v4Vpyk5kKS9kqazLUsapbHW5m5qVpvLg8y/kqV75+WEShZtbWfuOhewS0B3eXqrE0ETsHXucg93vfupLYHZ9ynJoG1kh96yQJoH2u5thDbCOHAeNzFB6Zshz0PrdrWCWWMG+PfYIGQ13O/d//fCVwP3dK773ww+//PS |
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, glob, subprocess, threading | |
from colored import fg, bg, attr | |
if len(sys.argv)!=6: | |
print "Usage:" | |
print sys.argv[0]+" ./a.out ./tests/ in out 2.0" | |
sys.exit(-1) | |
exe=sys.argv[1] | |
testFolder=sys.argv[2] |
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 BeautifulSoup as bs | |
import requests, sys, errno, os, subprocess | |
base=sys.argv[1] | |
def mkdir_p(path): | |
try: | |
os.makedirs(path) | |
except OSError as exc: # Python >2.5 | |
if exc.errno == errno.EEXIST and os.path.isdir(path): |
NewerOlder