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
(ns aoc2022.day-3 | |
(:gen-class) | |
(:require [clojure.set :as set]) | |
(:import (java.lang Character) | |
(java.io BufferedReader))) | |
(defn letter->priority | |
"Get the priority of a letter" | |
[letter] | |
(let [ord (int letter)] |
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
use std::time::Instant; | |
use std::thread; | |
use std::sync::mpsc::channel; | |
use async_std::task; | |
use async_std::channel::unbounded; | |
const NUM_ITERATIONS: u32 = 5000; | |
#[allow(unused_variables)] | |
async fn async_pi(n: u32) -> f64 { |
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
// Compile with: rustc -L dependency=fastrand/target/release/deps --extern fastrand=fastrand/target/release/deps/libfastrand-0ce9eb3dc1d79119.rlib text.rs | |
extern crate fastrand; | |
use std::{env, io}; | |
/// Given a string slice, return a string where each character in the given slice has a 60% chance | |
/// of being upper case, regardless of the case of the corresponding character in the original | |
/// string. Otherwise, the character is lower case. | |
/// |
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
// Compile with: rustc --test angle.rs | |
/// This module explores the idea of using Rust's enums-as-algebraic-data-types to model | |
/// dimensional analysis. For a given quantity, each of the possible units is a variant of that | |
/// enum. Methods can convert between the different units, so a function expecting a certain unit | |
/// can just accept that quantity and call one of the unit-converting methods. | |
/// | |
/// The inspiration for this module was [F#'s units of measure][fsuom], which is built into F#'s | |
/// type system. A unique feature of that implementation of dimensional analysis is that it can | |
/// understand multiplication and division of units, something that this implementation cannot. For |
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
//! Together we will build a Slack bot that makes a simple exchange between the user and the | |
//! bot. The user will first mention the bot, and then the bot will tell a knock-knock joke. | |
//! | |
//! Here is how the exchange will look. | |
//! 🙋♂️ *User:* `@bot` Tell me a joke | |
//! 🤖 *Bot:* Knock, knock. | |
//! 🙋♂️ *User:* Who's there? | |
//! 🤖 *Bot:* Underwear | |
//! 🙋♂️ *User:* Underwear who? | |
//! 🤖 *Bot:* Ever underwear you're going? |