Skip to content

Instantly share code, notes, and snippets.

@archer884
archer884 / main.rs
Created December 5, 2017 06:03
AOC/5 (Rust)
static INPUT: &str = include_str!("../input.txt");
struct ProgramWithOffset<F> {
instructions: Vec<i32>,
offset: F,
}
impl<F: Fn(i32) -> i32> ProgramWithOffset<F> {
fn new<T: IntoIterator<Item = i32>>(instructions: T, offset: F) -> Self {
Self {
@archer884
archer884 / main.rs
Last active December 4, 2017 22:06
AOC/4 (Rust)
#![feature(test)]
#[cfg(test)]
extern crate test;
extern crate fxhash;
extern crate rayon;
static INPUT: &str = include_str!("../input.txt");
@archer884
archer884 / Program.cs
Last active December 4, 2017 19:53
AOC/4 (C#)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace cs_day_4
{
class Program
{
static void Main(string[] args)
@archer884
archer884 / main.rs
Created December 3, 2017 06:47
AOC/Day 3
#![feature(universal_impl_trait)]
// DO NOT FORGET:
// Y == VERTICAL
// X == HORIZONTAL
const TARGET: i32 = 325489;
fn main() {
println!("{}", first_larger(TARGET));
@archer884
archer884 / iter.rs
Created December 1, 2017 21:52
aoc-1 (Rust)
pub(crate) struct CaptchaIter<T> {
state: IterState,
source: T,
}
impl<T: Iterator<Item = u8>> CaptchaIter<T> {
pub fn new<S>(source: S) -> Self
where
S: IntoIterator<Item = u8, IntoIter = T>,
{
1. type Foo = struct { X | Int, Float, Array[X]}
2. type Foo = struct {X ; Int, Float, Array[X]}
3. type Foo = Struct[X; Int, Float, Array[X]]
4. type Foo = struct [X; Int, Float, Array[X]]
5. type Foo = struct X, Y { Int, Y, Array[X] }
1. type Foo = struct {
X |
Int,
Float,
@archer884
archer884 / blackmagic.rs
Created August 19, 2016 20:51 — forked from huonw/blackmagic.rs
do-while loops in Rust
while {
let x = foo();
bar(x);
x != 0
} {}
@archer884
archer884 / playground.rs
Created August 17, 2016 04:07 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::io::{self};
use std::result;
type KKResults <T> = Result <T, KKError>;
#[derive(Debug)]
enum KKError {
Io(io::Error),
}
@archer884
archer884 / Airports.cs
Created February 6, 2016 12:22
Airport delays
using CsvHelper;
using CsvHelper.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AirlineDelays
{
class FlightRecord
@archer884
archer884 / main.rs
Created February 7, 2016 11:53
Rust Live Hack: Airports!
#![feature(slice_patterns)]
extern crate csv;
extern crate itertools;
extern crate rustc_serialize;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::path::Path;