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> | |
#include <stdbool.h> | |
#include <string.h> | |
void encode(unsigned char data[21]) | |
{ | |
unsigned char base[15]; | |
memcpy(base, data, 15); | |
for(int x = 0; x < 20; x++) { | |
unsigned char temp = 0b11111100; |
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
/** | |
* Implements red-black trees, the exposed functions are the ones with prefix | |
* `rd_` but without node i.e. `rd_node_` (these are internal functions) | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#define RED true |
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
nat: type. | |
z: nat. | |
s: nat -> nat. | |
0 = z. | |
1 = s 0. | |
2 = s 1. | |
3 = s 2. | |
4 = s 3. | |
5 = s 4. |
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::{env::args, fmt::Debug}; | |
struct Seq<'a, T> { | |
items: Vec<T>, | |
func: &'a dyn Fn(T) -> Option<T>, | |
place: usize, | |
} | |
impl<'a, T> Debug for Seq<'a, T> where T: Debug { | |
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
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
#![allow(arithmetic_overflow)] | |
use std::{ | |
collections::HashMap, | |
error::Error, | |
io::{stdin, stdout, Stdout}, | |
thread::sleep, | |
time::{Duration, Instant}, | |
}; | |
use crossterm::{ |
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 itertools import repeat | |
from functools import reduce | |
def get_dir_nodes(root): | |
match root["type"]: | |
case "anyof" | "oneof": | |
return [root["name"]] | |
case "dir": | |
return reduce(lambda a, b: a + b, map(get_dir_nodes, root["children"]), [root["name"]]) |
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 type Comparable = sig | |
type t | |
val compare: t -> t -> int | |
val to_string: t -> string | |
end;; | |
module Interval (IType: Comparable) = struct | |
type endpoint = IType.t | |
type interval = endpoint list | |
exception WrongInterval |
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
type natural = Z | S of natural;; | |
exception NoSolutionInNatural;; | |
let rec sum a b = | |
match b with | |
| Z -> a | |
| S x -> sum (S a) x | |
;; | |
let rec sub a b = |
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
arcs = { | |
"a": { | |
"b": lambda x, y: x != y, | |
#"c": lambda x, y: x != y, | |
}, | |
"b": { | |
"a": lambda x, y: x != y, | |
"c": lambda x, y: x != y, | |
}, | |
"c": { |
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::iter; | |
type Coordinates = (f64, f64, f64); | |
fn get_vector(a: Coordinates, b: Coordinates) -> Coordinates { | |
return (b.0 - a.0, b.1 - a.1, b.2 - a.2); | |
} | |
fn scale(point: Coordinates, scalar: f64) -> Coordinates { | |
return (point.0 * scalar, point.1 * scalar, point.2 * scalar); |
NewerOlder