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
/// ```bash | |
/// cargo run --release | |
/// # in another term | |
/// flame -p 9953 | |
/// # in another term | |
/// flame -p 9953 | |
/// ``` | |
use std::sync::atomic::{AtomicUsize, Ordering}; |
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
#![no_std] | |
#![no_main] | |
// pick a panicking behavior | |
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics | |
// extern crate panic_abort; // requires nightly | |
// extern crate panic_itm; // logs messages over ITM; requires ITM support | |
// extern crate panic_semihosting; // logs messages to the host stderr; requires a debugger | |
use cortex_m_rt::{entry, exception, ExceptionFrame}; |
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
#[allow(unused_imports)] | |
use std::cmp::{min,max}; | |
use std::io::{BufWriter, stdin, stdout, Write}; | |
#[derive(Default)] | |
struct Scanner { | |
buffer: Vec<String> | |
} | |
impl Scanner { | |
fn next<T: std::str::FromStr>(&mut self) -> T { |
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
pub fn diff_ways_to_compute(input: String) -> Vec<i32> { | |
let chars: Vec<char> = input.chars().collect::<Vec<_>>(); | |
parse(&chars).into_iter().map(|tree| tree.eval()).collect() | |
} | |
fn parse(input: &[char]) -> Vec<AST> { | |
let mut res = vec![]; | |
if input.is_empty() { | |
return res; | |
} |
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
#[allow(unused_imports)] | |
use std::cmp::{max, min}; | |
use std::{ | |
error::Error, | |
io::{stdin, stdout, BufWriter, Write}, | |
}; | |
#[derive(Default)] | |
struct Scanner { | |
buffer: Vec<String>, |
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
module ArrayManipulation where | |
{-| | |
Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each of the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in your array. | |
For example, the length of your array of zeros | |
. Your list of queries is as follows: | |
a b k |
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
module Parse where | |
import Control.Monad | |
import Data.Char | |
import Control.Applicative | |
data Parsed = Digit Integer | Hex Integer | Word String deriving Show | |
parseHex :: Parsed -> Char -> [Parsed] |
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
extern crate rayon; | |
use rayon::prelude::*; | |
use std::{collections::HashSet, env, error::Error, fs}; | |
fn main() -> Result<(), Box<dyn Error>> { | |
let args: Vec<String> = env::args().collect(); | |
let final_diff: HashSet<String> = args[1..] | |
.par_iter() |
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
extern crate crossbeam_utils; | |
use std::{ | |
collections::HashSet, | |
env, | |
error::Error, | |
fs, | |
sync::{Arc, Mutex}, | |
}; |
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
fizzbuzz :: Int -> String | |
fizzbuzz n = fromMaybe (show n) (fizz <> buzz) | |
where | |
fizz, buzz :: Maybe String | |
fizz = "Fizz" <$ guard (n `mod` 3 == 0) | |
buzz = "Buzz" <$ guard (n `mod` 5 == 0) |
NewerOlder