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
""" | |
https://en.wikipedia.org/wiki/Monty_Hall_problem | |
""" | |
import random | |
def do_game(change_selection): | |
# Initial door | |
doors = [1, 0, 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
from pyquery import PyQuery as pq | |
import requests | |
open('./video.mp4', 'wb').write(requests.get(pq(url=pq(url='http://dogvideos.tumblr.com/post/93519938318/videohall-how-dogs-react-to-human-barking')('iframe').attr('src'))('video source').attr('src')).content) |
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
""" | |
Merge sort | |
""" | |
first = lambda l: l[0] if len(l) else None | |
last = lambda l: l[-1] if len(l) else None | |
first_half = lambda l: l[:len(l)/2] | |
last_half = lambda l: l[len(l)/2:] | |
merge = lambda a, b: ( | |
[first(a)] + merge(a[1:], b) if first(a) < first(b) else [first(b)] + merge(a, b[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
from collections import Counter, defaultdict | |
from subprocess import check_output | |
import sys | |
import re | |
name_extractor=re.compile(r"\(.+?\)") | |
e=defaultdict(set) | |
try: | |
while True: |
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
""" | |
Slack coverage.py notifier. | |
Stewart Park <stewartpark92@gmail.com> | |
It reports test coverage to a Slack channel as a Jenkins bot. | |
Add this as a post-build/build step once coverage.py generates the html report. | |
Once everything is properly set up, you can add a badge on your README like below: | |
[![Coverage.py](http://<jenkins-host>/job/<job-name>/coveragepy/badge.svg)](http://<jenkins-host>/job/<job-name>/coveragepy/) |
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
#!/usr/bin/env python3 | |
from functools import lru_cache | |
""" | |
The encryption equation is given as: | |
D_i = (129M_i) XOR (M_(i-1)) (mod 256) | |
where D denotes a encrypted string, M is the message. | |
Thus, the message equation derived from the original equation should be: |
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 keras.models import Sequential | |
from keras.layers.core import Dense, Dropout, Activation | |
from keras.optimizers import SGD | |
import numpy as np | |
X = np.array([[0,0],[0,1],[1,0],[1,1]]) | |
y = np.array([[0],[1],[1],[0]]) | |
model = Sequential() | |
model.add(Dense(8, input_dim=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
from __future__ import print_function | |
from collections import OrderedDict | |
N = input() | |
raw_records = map(lambda x: raw_input(), xrange(N)) | |
records = OrderedDict() | |
# Since the syntactic correctness is given in the example, and also the order of the names can be simplified to the length of the name, | |
occurence = lambda x, y: len(x) - len(x.replace(y, '')) | |
order = lambda x: (10 * len(x.split())) - occurence(x, '.') |
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
#!/usr/bin/env python | |
def memoize(f): | |
memo = {} | |
def helper(*args): | |
x = str(args) | |
if x not in memo: | |
memo[x] = f(*args) | |
return memo[x] | |
return helper |
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
Ezpz. :D | |
https://taco-spolsky.github.io/?____valueOf#|checksum=9284326|Stewart Park= |