Skip to content

Instantly share code, notes, and snippets.

View davidmarek's full-sized avatar

David Marek davidmarek

  • Microsoft
  • Prague
View GitHub Profile
@davidmarek
davidmarek / main.rs
Created February 18, 2019 21:36
Solved tree serialization
use std::vec::Vec;
#[derive(Debug)]
struct Node {
value: i32,
left: Option<Box<Node>>,
right: Option<Box<Node>>,
}
impl Node {
#define MAX 1000000007
#define FACT_MAX 250
int add(int a, int b){
return (a + b) % MAX;
}
int mul(int a, in b){
return ((long long)a * b) % MAX;
}
@davidmarek
davidmarek / directions.py
Created April 3, 2013 19:04
Example of google directions search.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import urllib
import datetime
import time
def main():
@davidmarek
davidmarek / test_backprop.py
Created June 20, 2012 13:01
Gradient checking
import numpy as np
def check_grad(f, fprime, x0):
eps = 1e-5
approx = np.zeros(len(x0))
for i in xrange(len(x0)):
x0_ = x0.copy()
x0_[i] += eps
approx[i] = (f(x0_) - f(x0)) / eps