Skip to content

Instantly share code, notes, and snippets.

View fulmicoton's full-sized avatar
🤪

Paul Masurel fulmicoton

🤪
View GitHub Profile
def fibo_dynamic(n):
cur = 0 # F_i
next = 1 # F_i+1
while True:
yield cur
(cur, next) = (next, cur+next)
def fibo_dynamic(n):
cur = 0 # F_i
next = 1 # F_i+1
while True:
yield cur
(cur, next) = (next, cur+next)
template<typename TFloat>
bool _Field::to_float(TFloat* dest) const {
/* */
if (length == 0) {
return false;
}
int offset=0;
int sign = 1;
import csv
from contextlib import contextmanager
import sys
@contextmanager
def getstdin():
try:
yield sys.stdin # process.stdout
print "a"
app.directive('bzColorPicker', function() {
var evtFakeDom = $("<div>");
return {
restrict: 'E',
template: "<div class='bz-color-picker' ng-click='toggle($event)'>\
<div class='iris' style='background-color: {{ color }}'></div>\
<i class='icon-caret-down'></i>\
<div class='bz-color-picker-palette'>\
<input type='radio' class='color' ng-model='color' value='#f06548' style='background-color: #f06548'>\
<input type='radio' class='color' ng-model='color' value='#fdc766' style='background-color: #fdc766'>\
def find_permutations_range(w):
if len(w) == 0:
yield ""
else:
for rank in range(len(w)):
w_without_rank = [l for (i, l) in enumerate(w) if i != rank]
for perm in find_permutations_range(w_without_rank):
yield w[rank] + perm
for w in find_permutations_range("jambon"):
from collections import defaultdict
class Trie(object):
__slots__ = ('terminal', 'children')
def __init__(self,):
self.terminal = False
from collections import defaultdict
import heapq
ENGLISH = defaultdict(list)
for w in open("/usr/share/dict/american-english"):
w_stripped = w.strip()
ENGLISH[tuple(sorted(w_stripped))].append(w_stripped)
print heapq.nlargest(1, ENGLISH.itervalues(), key=len)[0]
from collections import defaultdict
import heapq
ENGLISH = defaultdict(list)
for w in open("/usr/share/dict/american-english"):
w_stripped = w.strip()
ENGLISH[tuple(sorted(w_stripped))].append(w_stripped)
print heapq.nlargest(1, ENGLISH.itervalues(), key=len)[0]
import numpy as np
import cProfile
def bits_to_int(bits,):
n = 0
for b in bits[::-1]:
n *= 2
n += b
return n