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/python | |
# A solution to N-Queens using the Min-Conflicts local search algorithm | |
# Vedant Kumar <vminch@gmail.com> | |
import random | |
def nqueens(nr): | |
show(min_conflicts(list(range(nr)), nr), nr) | |
def show(soln, nr): |
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::mem; | |
use std::ops::{Deref, DerefMut}; | |
#[derive(Copy, Clone, Debug)] | |
struct Tagged<'a, T: 'a> { | |
pointer: &'a T | |
} | |
impl<'a, T> Tagged<'a, T> { | |
fn tag(&'a mut self) -> &'a mut Tagged<'a, T> { |
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
from __future__ import print_function | |
import lldb | |
def doit(dbg, cmd): | |
print('::', cmd) | |
dbg.HandleCommand(cmd) | |
def should_stop_stepping(process): | |
state = process.GetState() |
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
=== Really doing llvm handler registration === | |
0 lldb 0x0000000107b0fe98 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40 | |
1 lldb 0x0000000107b0f858 RegisterHandlers() + 328 | |
2 lldb 0x0000000107b04d3e llvm::EnablePrettyStackTrace() + 46 | |
3 lldb 0x0000000107b04103 llvm::InitLLVM::InitLLVM(int&, char const**&) + 147 | |
4 lldb 0x0000000107aeaa9f main + 47 | |
5 libdyld.dylib 0x00007fff722ba3d5 start + 1 | |
6 libdyld.dylib 0x000000000000000e start + 18446603338600700986 | |
=== (in lldb) Should have installed llvm handlers ^ === | |
=== (in lldb) Blocking SIGPIPE === |
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
#!/bin/bash | |
OPT=$1 | |
shift 1 | |
TEST_FILE=$1 | |
shift 1 | |
strip_cmd() { | |
$OPT -disable-verify -strip -strip-dead-prototypes -strip-named-metadata -o - $* |
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
-module(bst). | |
-export([bst_create/0, bst_insert/2, bst_search/2]). | |
bst_create() -> []. | |
bst_insert(Bst, N) -> | |
case Bst of | |
[] -> [N, [], []]; | |
[Root, Lhs, Rhs] -> | |
if |
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
// Test driver for https://reviews.llvm.org/D41149 | |
#include <cstdint> | |
#include <limits> | |
#include <iostream> | |
#include <vector> | |
// Instructions: | |
// - Compile this program with a baseline compiler and a patched compiler. | |
// - Check that the output of the two executables is the same. |
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
(require plot) | |
(define (factorial n) | |
(if (< n 2) 1 (* n (factorial (- n 1))))) | |
(define (taylor-poly func n c) | |
(define (calc-coeff dfn level) | |
(/ (dfn c) (factorial level))) | |
(define (find-coeff fn level coeffs) | |
(if (= level (+ n 1)) |
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 trigPin 13 | |
#define echoPin 12 | |
#define delayMilis 100 | |
/* 0: Noisy state. | |
* 1: You went below the low threshold. | |
* 2: You went above the low threshold. | |
* 3: You went above the high threshold. | |
* 4: You went below the high threshold, pushup done. | |
*/ |
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
static void escape(void *p) { | |
asm volatile("" : : "g"(p) : "memory"); | |
} | |
static void clobber() { | |
asm volatile("" : : : "memory"); | |
} |
NewerOlder