This file contains hidden or 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
// | |
// i32_vec.c | |
// vector_idea | |
// | |
// Created by Nikolaj Lepka on 2018-09-19. | |
// Copyright © 2018 wausoft.eu. All rights reserved. | |
// | |
#include "i32_vec.h" | |
/** |
This file contains hidden or 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::marker::PhantomData; | |
use std::convert::From; | |
// Define the empty temperature markers | |
#[derive(Debug, Copy, Clone)] struct C; | |
#[derive(Debug, Copy, Clone)] struct F; | |
// Temperature Struct with Phantom Data | |
#[derive(Debug, Copy, Clone)] | |
struct Temp<T> { |
This file contains hidden or 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::marker::PhantomData; | |
use std::convert::From; | |
#[derive(Debug, Clone, Copy)] | |
struct H; | |
#[derive(Debug, Clone, Copy)] | |
struct L; | |
#[derive(Debug, Clone, Copy)] | |
struct Sec<S, A> { |
This file contains hidden or 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::io::{self, Write}; | |
fn prompt(input: &str) -> io::Result<String> { | |
let mut output = String::new(); | |
print!("{}", input); | |
io::stdout().flush()?; | |
io::stdin().read_line(&mut output)?; | |
Ok(output) | |
} |
This file contains hidden or 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::f32; | |
#[derive(Debug, Clone, PartialEq, PartialOrd)] | |
pub struct Vector2D { | |
pub x: f32, | |
pub y: f32, | |
} | |
impl Default for Vector2D { | |
fn default() -> Self { |
This file contains hidden or 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
/** Python-style range function */ | |
function range(n) { | |
let arr = new Array(n); | |
let result = [...arr.keys()].map(m => Number(m)); | |
return result; | |
} |
This file contains hidden or 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
//! Chapter 1: Introduction to Algorithms. Binary Search. | |
// NB: input must be sorted | |
fn binary_search<T>(lst: &[T], item: &T) -> Option<usize> | |
where T: PartialEq + PartialOrd | |
{ | |
let mut low = 0; | |
let mut high = lst.len() - 1; | |
while low <= high { |
This file contains hidden or 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/ruby | |
# Somewhat counter-intuitively, Ruby's ARGV doesn't include the file name, | |
# so the vector is 1 shorter than normal. | |
# Typically writing ./mkcpp.rb foo would give a vector like ARGV = ["mkcpp.rb", "foo"], but not here. | |
if ARGV.length < 1 then | |
puts "Please provide a sufficient number of arguments" | |
exit | |
end |
This file contains hidden or 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/ruby | |
require './prompt' | |
# Exit early if a file name hasn't been provided | |
if ARGV.length < 1 then | |
puts "Please provide an identifier" | |
exit | |
end | |
# Gets all the strings that include the provided identifier |
This file contains hidden or 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
# Inspired by the Razzle Dazzle scam on YouTube: https://www.youtube.com/watch?v=527F51qTcTg | |
# Note that this always assumes fair play | |
## | |
# Keeps track of the outcome of any given dice roll | |
# +points+ is how many points a given field is worth | |
# +prize+ is how many prizes are being added to your current pool of prizes | |
# +cost_mult+ is the cost multiplier of a given spot | |
class Outcome | |
attr_reader :points, :prize, :cost_mult |