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 num::traits::{Inv, One, Zero}; | |
use std::ops::*; | |
use super::F; | |
macro_rules! vector {($T:ident, $F:ident, $n:tt, [$($i:expr),*]) => { | |
#[derive(Clone, Copy, Debug, PartialEq)] | |
pub struct $T(pub [$F; $n]); | |
impl Deref for $T { type Target = [$F; $n]; fn deref(&self) -> &Self::Target { &self.0 } } |
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/sh | |
mpv "ytdl://ytsearch:$*" --no-video --loop |
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
<!doctype html> | |
<html> | |
<head> | |
<title>Results</title> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
margin: 0; | |
font-family: sans-serif; |
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 random | |
BLANK = 0 | |
P1 = 1 | |
P2 = 2 | |
TRANSLATE = { BLANK: '.', P1: 'O', P2: 'X' } | |
def main(): | |
'''Play noughts and crosses!''' |
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
#include <assert.h> | |
#include <stdlib.h> | |
#define T int | |
typedef struct heap { | |
T* data; | |
size_t cap, len; | |
} Heap; |
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
defn =_{ soi ~ variable ~ "=" ~ expr ~ eoi } | |
main =_{ soi ~ expr ~ eoi } | |
add = { "+" } | |
sub = { "-" } | |
mul = { "*" } | |
div = { "/" } | |
rem = { "%" } | |
exp = { "^" } |
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
// cargo-deps: scrap, x11cap | |
// Use cargo-script to run this benchmark! | |
extern crate scrap; | |
extern crate x11cap; | |
use std::time::{Duration, Instant}; | |
fn x11cap() { |
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
#include <stdio.h> | |
// Should run in O(1) space (ignoring output) and O(n^3) time, assuming TCO. | |
int solve(int n, int x, int y) { | |
int k = (n - 1) * (n + 3) / 2; | |
if (y == 0) { | |
// First Row | |
return k - x; |
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::fmt; | |
enum Op<'a> { | |
Base(f64), | |
Add(&'a Op<'a>, &'a Op<'a>), | |
Sub(&'a Op<'a>, &'a Op<'a>), | |
Mul(&'a Op<'a>, &'a Op<'a>), | |
Div(&'a Op<'a>, &'a Op<'a>), | |
Sbi(&'a Op<'a>, &'a Op<'a>), | |
Dvi(&'a Op<'a>, &'a Op<'a>), |
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
alphabet = "abcdefghijklmnopqrstuvwxyz" | |
def choose(question, options): | |
assert 1 < len(options) <= len(alphabet) | |
while True: | |
print(question) | |
for i, opt in enumerate(options): | |
print("{}) {}".format(alphabet[i], opt)) | |
inp = input("(a-{})> ".format(alphabet[i])) | |
if len(inp) == 1: |