Skip to content

Instantly share code, notes, and snippets.

@suyash
suyash / mixture_density_nets_2d.ipynb
Last active October 6, 2019 04:56
Mixture Density Nets 2D
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@suyash
suyash / segment_tree.rs
Created July 8, 2020 07:49
Generic Segment Tree implemented for custom comparator and min functions.
//! Generic Segment Tree implemented for custom comparator and min functions.
//!
//! See Chapters 15, 16 in Blandy and Orendorff
/// Segment Tree allows for querying information over ranges in a continuous data stream.
pub struct SegmentTree<T, Comparator, Minimum> {
tree: Vec<T>,
n: usize,
f: Comparator,
d: Minimum,
@suyash
suyash / kmp.rs
Created July 8, 2020 13:26
Knuth-Morris-Pratt implementation
//! Knuth-Morris-Pratt implementation
//!
//! See Chapter 17 in Blandy + Orendorff
/// computes the KMP longest prefix-suffix function
pub fn kmp<T: AsRef<[u8]>>(pattern: T) -> Vec<usize> {
let pattern = pattern.as_ref();
let n = pattern.len();
let mut ans = vec![0; n + 1];