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
use std::vec::Vec; | |
#[derive(Debug)] | |
struct Node { | |
value: i32, | |
left: Option<Box<Node>>, | |
right: Option<Box<Node>>, | |
} | |
impl Node { |
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
#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; | |
} |
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 | |
# -*- coding: utf-8 -*- | |
import json | |
import urllib | |
import datetime | |
import time | |
def main(): |
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 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 |