Skip to content

Instantly share code, notes, and snippets.

View jorendorff's full-sized avatar

Jason Orendorff jorendorff

View GitHub Profile
# Some more privileged methods, with some private data.
class Availability:
def __init__(self):
self._is_open = False
def open(self):
self._is_open = True
def close(self):
self._is_open = False
@jorendorff
jorendorff / editor.rs
Last active July 20, 2017 17:59 — forked from levicole/editor.rs
extern crate termion;
use std::io::{Write, Stdout, stdout, stdin};
use termion::event::{Key, Event};
use termion::input::TermRead;
use termion::raw::{IntoRawMode, RawTerminal};
use termion::screen::AlternateScreen;
pub struct Editor {
screen: AlternateScreen<Stdout>,
@jorendorff
jorendorff / heads.py
Created August 4, 2017 04:21 — forked from jimblandy/heads.py
There must be a better way to compute this...
import random
random.seed()
def flip():
return random.choice([True, False])
def run():
b = flip()
n = 1
@jorendorff
jorendorff / playground.rs
Created October 11, 2017 19:19 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::fmt::Debug;
struct Reader<'a> {
buf: &'a [u8],
}
impl<'a> Reader<'a> {
fn read<'b>(&'b mut self, len: usize) -> Result<&'a [u8], ()> {
if len <= self.buf.len() {
let (read, remains) = self.buf.split_at(len);

This was written in response to: https://twitter.com/hillelogram/status/1227118562373963776


People mix the predicate "If a directed graph is a tree, it's a DAG" with the proposition "For all directed graphs, if a directed graph is a tree, it's a DAG".

First, for simplification: let's assume we're talking here about all graphs in the world with up to 10 nodes to be able to enumerate them. Also, note that we're talking about directed, not undirected, graphs.

To prove the proposition "For all..." is true, which is "(For graph G1, if it's a tree, it's a DAG) AND (For graph G2, if it's a tree, it's a DAG) AND...", since it's ANDs, we need to prove (For graph G1, if...) is true and we need to prove (For graph G2, if...) is true, ... etc.