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::collections::LinkedList; | |
use std::iter::IntoIterator; | |
fn main() { | |
for (n, s) in NQueens::new(8).enumerate() { | |
println!("Solution #{}:\n{}\n", n + 1, s.to_string()); | |
} | |
} | |
fn permutations<'a, T, I>(collection: I) -> Box<Iterator<Item=LinkedList<T>> + '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
#[macro_use] | |
extern crate rspc; | |
use std::fmt::{Display, Formatter}; | |
use rspc::parsers::{Parser, ParserOps, ws, character, alphanumeric}; | |
use rspc::parsers::combinators::many1; | |
use rspc::context::StringSource; | |
#[derive(PartialEq, Debug)] | |
enum Tree<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
#[macro_use] | |
extern crate rspc; | |
extern crate chrono; | |
use rspc::parsers::{Parser, ParserOps, number, string, ws, letter, not_of, character}; | |
use rspc::parsers::combinators::many1; | |
use rspc::context::StringSource; | |
use std::fs::File; | |
use std::io::Read; |
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
const START: usize = 1; | |
const END: usize = 5; | |
fn main() { | |
/*let mut edges = [ | |
(1, 3, 6, 6), | |
(1, 2, 5, 5), | |
(1, 4, 5, 5), | |
(2, 5, 3, 3), |
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
fn main() { | |
let vec = vec![23,6,2,7,8,43,3,7,9,2]; | |
println!("Shellsort: {:?}", vec.clone().shellsort()); | |
println!("Quicksort: {:?}", vec.clone().quicksort()); | |
println!("Heapsort : {:?}", vec.clone().heapsort()); | |
} | |
trait MultiSort { | |
fn shellsort(&mut self) -> &mut Self; | |
fn quicksort(&mut self) -> &mut 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
use std::collections::HashMap; | |
trait Resolver { | |
type Input; | |
fn resolve<'a, T: FromInput<Self::Input>>(&self, name: &'a str) -> T; | |
} | |
trait FromInput<T> { | |
fn from(s: T) -> 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
#[derive(PartialEq, Eq)] | |
struct Person { | |
id: u32, | |
name: String, | |
last_name: String | |
} | |
fn main() { | |
let p1 = Person { | |
id: 1, |
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
extern crate bincode; | |
extern crate rustc_serialize; | |
#[macro_use] | |
extern crate bytevec; | |
use bincode::SizeLimit; | |
use bincode::rustc_serialize::{encode, decode}; | |
use bytevec::{ByteDecodable, ByteEncodable}; | |
bytevec_impls! { |
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
import Html exposing (..) | |
import Html.App as Html | |
import Html.Attributes exposing (href, style, target) | |
import WebSocket | |
import Json.Decode exposing (..) | |
import Time exposing (Time) | |
import Date exposing (..) | |
import List exposing (append, sortBy, reverse) | |
import String exposing (pad) |
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::sync::{Arc, Mutex}; | |
use std::thread; | |
//use std::alloc::arc::Weak; | |
#[derive(Debug)] | |
enum Promise<O> { | |
Awaiting, | |
ResultValue(Arc<Mutex<O>>) | |
} |