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
fn _main?() | |
{ | |
x = -10 | |
y = +20 | |
} |
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
#![feature(conservative_impl_trait)] | |
fn take<'a>(take: &'a str) -> impl Fn(&'a str) -> (&'a str, &'a str) { | |
move |input| { | |
let len = input.chars().zip(take.chars()).take_while(|&(i, t)| i == t).count(); | |
(&input[0..len], &input[len..]) | |
} | |
} | |
fn chain<'a, F1, F2>(first: F1, second: F2) -> impl Fn(&'a str) -> ((&'a str, &'a str), &'a str) |
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
/* | |
#[yields] | |
fn foo(multi: i32) -> i32 { | |
let mut counter = 0i32; | |
yield 100; | |
println!("After yield 100!"); | |
counter += 1; | |
yield 200; | |
let aeiou = "Hello!"; |
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
enum MouseButton { | |
Left, | |
Middle, | |
Right, | |
} | |
enum UiEvent { | |
MouseMove(i32, i32), | |
MouseClicked(i32, i32, MouseButton), | |
} |
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
struct Event<'a> { | |
handlers: Vec<Box<FnMut() + 'a>>, | |
} | |
impl<'a> Event<'a> { | |
fn new() -> Self { | |
Self { | |
handlers: Vec::new(), | |
} | |
} |
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
#![feature(conservative_impl_trait)] | |
use std::cmp::PartialEq; | |
type ParseResult<T, I: Iterator<Item = T>> = Result<ParseStatus<T, I>, ParseError>; | |
#[derive(Debug)] | |
enum ParseStatus<T, I: Iterator<Item = T>> { | |
Ok(Vec<T>, I), | |
NeedMoreData(usize), // # of units needed |
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
#[derive(Debug, PartialEq, Copy, Clone)] | |
enum Dir { | |
Up, | |
Down, | |
Left, | |
Right, | |
} | |
#[derive(Clone, Copy, PartialEq)] | |
struct Point { |
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
fn main() { | |
let input = r#"pphsv ojtou brvhsj cer ntfhlra udeh ccgtyzc zoyzmh jum lugbnk | |
vxjnf fzqitnj uyfck blnl impo kxoow nngd worcm bdesehw | |
caibh nfuk kfnu llfdbz uxjty yxjut jcea | |
qiho qif eupwww avyglnj nxzotsu hio lws | |
xjty usocjsh pivk qnknunc yjcgh bwya djw zpyr | |
ycfmfe mgq sjiomg nfzjul bjwkmgu yvsnvgj dcjupu wzz blmn | |
rdowgbt vpwfdoi blzl laghnk gsa vhnpo cztxzlb rtz hvwonhb eciju pfjtbo | |
bqs bqs dbutvgf mmzb izpyud rap izpyud xlzeb mnj hjncs | |
xpu vwp nujcos piu irindir tpmfd umtvlm gznu |
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
fn main() { | |
let digits: Vec<_> = INPUT.chars().map(|c| char::to_digit(c, 10).unwrap()).collect(); | |
let step = digits.len() / 2; | |
let mut acc = 0; | |
for (i, d) in digits.iter().enumerate() { | |
if let Some(x) = digits.iter().cycle().skip(i).nth(step) { | |
if d == x { | |
acc += d; | |
} |
OlderNewer