Skip to content

Instantly share code, notes, and snippets.

View alsuren's full-sized avatar

David Laban alsuren

View GitHub Profile
anonymous
anonymous / playground.rs
Created December 26, 2016 00:20
Shared via Rust Playground
#![feature(try_from)]
use std::convert::TryFrom;
fn do_add<'a>(state : &mut std::collections::HashMap<&'a str, i32>, thing_one : &'a str, thing_two : &'a str){
let one = state.get(thing_one).unwrap().clone();
let two = state.get(thing_two).unwrap().clone();
state.insert(thing_one, 0);
state.insert(thing_two, one + two);
}
anonymous
anonymous / playground.rs
Created December 16, 2016 20:56
Shared via Rust Playground
#![feature(try_from)]
use std::convert::TryFrom;
fn do_add<'a>(state : &mut std::collections::HashMap<&'a str, i32>, thing_one : &'a str, thing_two : &'a str){
let one = state.get(thing_one).unwrap().clone();
let two = state.get(thing_two).unwrap().clone();
state.insert(thing_one, 0);
state.insert(thing_two, one + two);
}
anonymous
anonymous / playground.rs
Created December 11, 2016 16:39
Shared via Rust Playground
#[derive(Debug)]
struct Floor {
micros : std::collections::HashSet<char>,
gens : std::collections::HashSet<char>,
}
fn parsefloor(room: &str) -> Floor {
let mut floor = Floor{
micros: std::collections::HashSet::<char>::new(),
gens: std::collections::HashSet::<char>::new()};
anonymous
anonymous / playground.rs
Created December 9, 2016 00:01
Shared via Rust Playground
fn is_real(encrypted: &str, sum: &str) -> bool {
let mut counts : std::collections::HashMap<char, i32> = std::collections::HashMap::new();
for c in encrypted.chars() {
counts.insert(c, 0);
}
for c in encrypted.chars() {
match c {
'-' => {},
_ => {
let count = counts.get(&c).unwrap() + 1;
anonymous
anonymous / playground.rs
Created December 8, 2016 22:53
Shared via Rust Playground
fn main (){
let input = " 566 477 376
575 488 365
50 18 156
558 673 498
133 112 510
670 613 25
84 197 643
910 265 611
anonymous
anonymous / playground.rs
Created December 8, 2016 22:28
Shared via Rust Playground
fn main (){
let input = "DUURRDRRURUUUDLRUDDLLLURULRRLDULDRDUULULLUUUDRDUDDURRULDRDDDUDDURLDLLDDRRURRUUUDDRUDDLLDDDURLRDDDULRDUDDRDRLRDUULDLDRDLUDDDLRDRLDLUUUDLRDLRUUUDDLUURRLLLUUUUDDLDRRDRDRLDRLUUDUDLDRUDDUDLLUUURUUDLULRDRULURURDLDLLDLLDUDLDRDULLDUDDURRDDLLRLLLLDLDRLDDUULRDRURUDRRRDDDUULRULDDLRLLLLRLLLLRLURRRLRLRDLULRRLDRULDRRLRURDDLDDRLRDLDRLULLRRUDUURRULLLRLRLRRUDLRDDLLRRUDUDUURRRDRDLDRUDLDRDLUUULDLRLLDRULRULLRLRDRRLRLULLRURUULRLLRRRDRLULUDDUUULDULDUDDDUDLRLLRDRDLUDLRLRRDDDURUUUDULDLDDLDRDDDLURLDRLDURUDRURDDDDDDULLDLDLU
LURLRUURDDLDDDLDDLULRLUUUDRDUUDDUDLDLDDLLUDURDRDRULULLRLDDUDRRDRUDLRLDDDURDUURLUURRLLDRURDRLDURUDLRLLDDLLRDRRLURLRRUULLLDRLULURULRRDLLLDLDLRDRRURUUUDUDRUULDLUDLURLRDRRLDRUDRUDURLDLDDRUULDURDUURLLUDRUUUUUURRLRULUDRDUDRLLDUDUDUULURUURURULLUUURDRLDDRLUURDLRULDRRRRLRULRDLURRUULURDRRLDLRUURUDRRRDRURRLDDURLUDLDRRLDRLLLLRDUDLULUDRLLLDULUDUULLULLRLURURURDRRDRUURDULRDDLRULLLLLLDLLURLRLLRDLLRLUDLRUDDRLLLDDUDRLDLRLDUDU
RRDDLDLRRUULRDLLURLRURDLUURLLLUUDDULLDRURDUDRLRDRDDUUUULDLUDDLRDULDDRDDDDDLRRD
anonymous
anonymous / playground.rs
Created December 8, 2016 21:51
Shared via Rust Playground
fn rotate(direction: &mut Vec<i32>, turn: &str){
let x = direction[0];
let y = direction[1];
if turn == "L" {
direction[1] = x;
direction[0] = -y;
} else {
direction[1] = -x;
direction[0] = y;
}