Skip to content

Instantly share code, notes, and snippets.

View mkeeter's full-sized avatar

Matt Keeter mkeeter

View GitHub Profile
import ctypes
libfive = ctypes.cdll.LoadLibrary('build/libfive/src/libfive.dylib')
libfive.libfive_tree_x.restype = ctypes.c_void_p
libfive.libfive_tree_y.restype = ctypes.c_void_p
libfive.libfive_tree_delete.argtypes = [ctypes.c_void_p]
libfive.libfive_tree_binary.argtypes = [ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p]
use std::str::FromStr;
#[macro_use] extern crate nom;
use nom::types::CompleteByteSlice;
#[macro_use] extern crate itertools;
use std::collections::HashMap;
/*
#[derive(Debug)]
struct Tree {
nodes: Vec<Tree>,
metadata: Vec<usize>,
}
impl Tree {
fn from_iter<I>(s: &mut I) -> Self
where I: Iterator<Item=usize>
{
@mkeeter
mkeeter / elves.rs
Last active December 15, 2018 20:35
use std::io::{self, Read};
use std::iter;
use std::collections::VecDeque;
use std::collections::HashSet;
#[derive(PartialEq, Copy, Clone, Debug)]
enum Race {
Elf,
Goblin
}
; ModuleID = 'main.cpp'
source_filename = "main.cpp"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.13.0"
%"class.std::__1::unordered_set" = type { %"class.std::__1::__hash_table" }
%"class.std::__1::__hash_table" = type <{ %"class.std::__1::unique_ptr", %"class.std::__1::__compressed_pair.4", %"class.std::__1::__compressed_pair.9", %"class.std::__1::__compressed_pair.11", [4 x i8] }>
%"class.std::__1::unique_ptr" = type { %"class.std::__1::__compressed_pair" }
%"class.std::__1::__compressed_pair" = type { %"struct.std::__1::__compressed_pair_elem", %"struct.std::__1::__compressed_pair_elem.0" }
%"struct.std::__1::__compressed_pair_elem" = type { %"struct.std::__1::__hash_node_base"** }
DEPTH = 15
a, b = 'X', 'Y'
for i in range(DEPTH):
a, b = ('(pow(%s,2) - pow(%s,2) + X)' % (a, b),
'(2*%s*%s + Y)' % (a, b))
# Render boundaries
cad.xmin = -2.2
# Sage code to generate NACA airfoil equations
import operator
var('x, y, xc, m, p')
def run(y_chord):
g_chord = vector([1, derivative(y_chord(xc), xc)])
pos_pt = vector([x, y])
pos_chord = vector([xc, y_chord(xc)])
delta = pos_pt - pos_chord
Minimize in: ore_in
Subject to
KHKGT: - 5 eqn2 + 8 eqn8 >= 0
NZVS: + 5 eqn0 - 29 eqn2 - 7 eqn8 >= 0
ORE: - 157 eqn0 - 165 eqn1 - 179 eqn4 - 177 eqn5 - 165 eqn7 + ore_in >= 0
DCFZ: + 6 eqn1 - 7 eqn6 - 3 eqn8 >= 0
HKGWZ: - 48 eqn2 - 12 eqn3 + 5 eqn5 - 5 eqn8 >= 0
GPVTF: - 9 eqn2 - 1 eqn3 + 2 eqn7 >= 0
QDVJ: - 1 eqn2 + 9 eqn3 >= 0
Maximize out: fuel_out
Subject to
KHKGT: - 5 eqn2 + 8 eqn8 >= 0
NZVS: + 5 eqn0 - 29 eqn2 - 7 eqn8 >= 0
ORE: - 157 eqn0 - 165 eqn1 - 179 eqn4 - 177 eqn5 - 165 eqn7 + ore_in >= 0
DCFZ: + 6 eqn1 - 7 eqn6 - 3 eqn8 >= 0
HKGWZ: - 48 eqn2 - 12 eqn3 + 5 eqn5 - 5 eqn8 >= 0
GPVTF: - 9 eqn2 - 1 eqn3 + 2 eqn7 >= 0
QDVJ: - 1 eqn2 + 9 eqn3 >= 0
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
--lp input.lp
Reading problem data from 'input.lp'...
11 rows, 11 columns, 32 non-zeros
11 integer variables, none of which are binary
29 lines were read
GLPK Integer Optimizer, v4.65
11 rows, 11 columns, 32 non-zeros
11 integer variables, none of which are binary