Skip to content

Instantly share code, notes, and snippets.

@jay3686
jay3686 / challenge1.py
Created February 13, 2012 04:41
Python Answer to Embedly's Challenge 1
def badr(n):
return 1 if n is 1 else n * badr(n - 1)
n = 1;
while(reduce(lambda x, y: int(x) + int(y), str(badr(n))) != 8001):
n = n + 1
print n;
@jay3686
jay3686 / challenge2.py
Created February 13, 2012 04:42
Python Answer to Embedly's Challenge 2
import math;
import urllib
from xml.dom import minidom
def std(n):
return math.sqrt(sum(map(lambda x: (x - float(sum(n))/ len(n))** 2, n))/len(n))
article = minidom.parse(urllib.urlopen("http://apply.embed.ly/static/data/2.html")).getElementsByTagName("article")[0]
tags = ();
@jay3686
jay3686 / challenge3.py
Created February 13, 2012 04:43
Python Answer to Embedly's Challenge 3
freqWords = map(lambda x : 2520.0 / x, range(1,901))
wordTotal = 0;
wordHalfTotal = sum(freqWords)/2
for wordCount in range(1,901):
wordTotal += freqWords[wordCount - 1];
if wordTotal >= wordHalfTotal:
print wordCount;
break;
# distance units
Mile
Meter
Kilometer
Foot
Laps (25 meters)
Laps (50 meters)
Yard
Inch
@jay3686
jay3686 / exercises.jayson
Last active December 21, 2015 07:58
Exercise JSON
[{
"inputs": [{
"effort_max": 600.0,
"display_name": "weight",
"effort_min": 0.0,
"allowed_units": ["kg", "lb"],
"hidden_by_default": false,
"type": "weight",
"id": 0
@jay3686
jay3686 / workout.jayson
Created August 21, 2013 01:21
workout json
{
"date": "2011-11-11",
"timestamp": "2011-11-11T12:00:00",
"id": 1429543,
"root_group": {
"children": [{
"type": "exercise",
"id": 2783919,
"sets": [{
@jay3686
jay3686 / gist:9376565
Created March 5, 2014 21:05
flatting list of lists or non lists
"""
In [56]: a = [1,[2,3,4], 4,5,6, [7,8], 9, 10]
In [57]: normalize = lambda x : x if type(x) == list else [x]
In [58]: list(itertools.chain(*map(normalize, a)))
Out[58]: [1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10]
In [59]: a
ROMANS = (('M', 1000),
('CM', 900),
('D', 500),
('CD', 400),
('C', 100),
('XC', 90),
('L', 50),
('XL', 40),
('X', 10),
import time
def rate_limited(num_calls, interval):
minInterval = float(interval) / float(num_calls)
def decorate(func):
lastTimeCalled = [0.0]
def rate_limited_function(*args, **kargs):
1. Sky temple. I was Morales. Lost game because only warrior decided to go solo jungle all game and only responded to chat in curses or insults (same during draft)
2. cursed hollow. I was Zag. Won game - our team was waaay better than theirs. their lili took dragon?? Got cocky and died some, but still had 2x their kills. Only won 50 points.
3. Dragon Shire. I was Morales. Major loss with 4 level lead for other team. Hero raynor liked to charge in solo and focus tanks. 0 death Lili with 107k heals because of it. Asked Raynor multiple times to focus Lili, but he told me to shut up because he's top damage. 80k hero damage against mostly diablo and artanis.
4. Spider Queen. I was Muradin. Hero gaz solo all game. talked trash to rest of team because he was top damage, lost every team fight.
5. Dragonshire. I was DPS Tass. Won game. Close match until I got the dragon (other 3 times we got dragon our team would full wipe with dragon push). Got all dragons tho.