Skip to content

Instantly share code, notes, and snippets.

@archer884
archer884 / main.rs
Last active Dec 4, 2017
AOC/4 (Rust)
View main.rs
#![feature(test)]
#[cfg(test)]
extern crate test;
extern crate fxhash;
extern crate rayon;
static INPUT: &str = include_str!("../input.txt");
View main.rs
#![feature(universal_impl_trait)]
// DO NOT FORGET:
// Y == VERTICAL
// X == HORIZONTAL
const TARGET: i32 = 325489;
fn main() {
println!("{}", first_larger(TARGET));
View iter.rs
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>,
{
View gist:e0ab2d186eb9066eb2fb70e6f9fe82b2
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 Aug 19, 2016 — forked from huonw/blackmagic.rs
do-while loops in Rust
View blackmagic.rs
while {
let x = foo();
bar(x);
x != 0
} {}
@archer884
archer884 / playground.rs
Created Aug 17, 2016 — forked from anonymous/playground.rs
Rust code shared from the playground
View playground.rs
use std::io::{self};
use std::result;
type KKResults <T> = Result <T, KKError>;
#[derive(Debug)]
enum KKError {
Io(io::Error),
}
@archer884
archer884 / main.rs
Created Feb 7, 2016
Rust Live Hack: Airports!
View main.rs
#![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;
View Airports.cs
using CsvHelper;
using CsvHelper.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AirlineDelays
{
class FlightRecord
@archer884
archer884 / CryptoRandom.cs
Last active Nov 23, 2015
For posterity...
View CryptoRandom.cs
using System;
using System.Security.Cryptography;
namespace JA
{
// Credit for CryptoRandom goes to Stephen Toub & Shawn Farkas, original
// authors of the code included below, which appeared in September 2007
// in MSDN Magazine.
//
// http://blogs.msdn.com/b/msdnmagazine/archive/2007/08/31/4653696.aspx
@archer884
archer884 / read.rs
Created Sep 14, 2015
Read function that doesn't return newline characters
View read.rs
fn read() -> String {
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).ok();
if buffer.ends_with("\n") {
buffer.pop();
}
if buffer.ends_with("\r") {
buffer.pop();