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::{collections::BTreeSet, fmt::Display, str::FromStr}; | |
/// Write a function that can do the 4 basic operations (add, subtract, multiply | |
/// and divide) on two fractions. Return the most simplified form of the result. | |
/// You can assume a non-zero denominator in the input, and don’t use any | |
/// built-in implementations in your language of choice, if you can! | |
/// | |
/// Example: | |
/// | |
/// ``` |
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 rand::seq::SliceRandom; | |
/// If you mix up the order of letters in a word, many people can slitl raed and urenadnstd tehm. Write a function that | |
/// takes an input sentence, and mixes up the insides of words (anything longer than 3 letters). | |
/// | |
/// Example: | |
/// | |
/// ``` | |
/// > scramble(["A quick brown fox jumped over the lazy dog."]) | |
/// > "A qciuk bwron fox jmepud oevr the lzay dog." |
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
/// Given a list of numbers, return all groups of repeating consecutive numbers. | |
/// | |
/// Examples: | |
/// | |
/// ``` | |
/// > repeatedGroups([1, 2, 2, 4, 5]) | |
/// [[2, 2]] | |
/// | |
/// > repeatedGroups([1, 1, 0, 0, 8, 4, 4, 4, 3, 2, 1, 9, 9]) | |
/// [[1, 1], [0, 0], [4, 4, 4], [9, 9]] |
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
/// Given a string of parenthesis, return the number of parenthesis you need to add to the string in order for it to be balanced. | |
/// | |
/// Examples: | |
/// | |
/// ```bash | |
/// > numBalanced(`()`) | |
/// > 0 | |
/// | |
/// > numBalanced(`(()`) | |
/// > 1 |
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() { | |
println!("{}", capitalize_post_vowels("Hello, World!".to_string())); | |
} | |
/// Given a string, make every consonant after a vowel uppercase. | |
fn capitalize_post_vowels(s: String) -> String { | |
let mut prev = false; | |
s.chars() | |
.into_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
[package] | |
name = "tokio-lifetime" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
opentelemetry = { version = "0.18.0", features = ["rt-tokio"] } | |
opentelemetry-otlp = "0.11.0" |
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::{io::stdout, io::Write}; | |
fn main() { | |
indent_slashes(&mut stdout(), "\\\\\\\\//\\\\\\////").unwrap(); | |
} | |
/// takes a string of slashes (\ and /) and returns all of those slashes drawn | |
/// downwards in a line connecting them. | |
/// | |
/// Example: |
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
# frozen_string_literal: true | |
source "https://rubygems.org" | |
gem "faraday", "~> 0.16.1" | |
gem "opentelemetry-api" | |
gem "opentelemetry-common" | |
gem "opentelemetry-sdk-experimental", path: '../../sdk_experimental' | |
gem "sinatra", "~> 2.0" | |
gem "puma" |
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::io::{self, Write}; | |
fn main() { | |
write_ascii(std::io::stdout()).unwrap(); | |
} | |
fn write_ascii<W: Write>(mut w: W) -> Result<(), io::Error> { | |
let chars = (0x20 as u8..0x7e + 1 as u8) | |
.into_iter() | |
.map(|b| char::from(b)) |
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() { | |
println!("Hello, world!"); | |
} | |
pub fn ordinal(num: isize) -> String { | |
let one = num % 10; | |
let ten = (num / 10) % 10; | |
match (one, ten) { | |
(o, t) if t == 1 && o > 0 && 0 <= 3 => format!("{}th", num), |