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
export class LaunchControl { | |
private serverUrl: string; | |
private lastSessionState: "start" | "end" | null; | |
private trackingId: string; | |
constructor(serverUrl: string, trackingId: string) { | |
this.serverUrl = serverUrl; | |
this.lastSessionState = null; | |
this.trackingId = trackingId; | |
} |
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
let sum = List.fold_left (fun acc x -> acc + x) 0 | |
type result = { pies : int; uneaten_pieces : int } | |
let pies pieces piece_per_pie = | |
let total_pieces = sum pieces in | |
let pies = | |
if total_pieces mod piece_per_pie == 0 then total_pieces / piece_per_pie | |
else (total_pieces / piece_per_pie) + 1 | |
in |
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
module KeyToRowMap = Map.Make (Char) | |
let qwertyKeyToRowMap = | |
let firstRow = ['q'; 'w'; 'e'; 'r'; 't'; 'y'; 'u'; 'i'; 'o'; 'p'] in | |
let secondRow = ['a'; 's'; 'd'; 'f'; 'g'; 'h'; 'j'; 'k'; 'l'] in | |
let thirdRow = ['z'; 'x'; 'c'; 'v'; 'b'; 'n'; 'm'] in | |
KeyToRowMap.empty | |
|> (fun m -> List.fold_left (fun acc key -> KeyToRowMap.add key 1 acc) m firstRow) | |
|> (fun m -> List.fold_left (fun acc key -> KeyToRowMap.add key 2 acc) m secondRow) | |
|> (fun m -> List.fold_left (fun acc key -> KeyToRowMap.add key 3 acc) m thirdRow) |
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
let int_sqrt x = x |> float_of_int |> sqrt |> int_of_float | |
(** | |
* [oddSquareNumber n] | |
* returns the sum of all odd square numbers less than [n] | |
* | |
* it does this by going through all the odd numbers from [1] to [sqrt(n)] | |
* and adding the square of each number to the sum if the square is less | |
* than [n]. | |
*) |
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
type Point = [number, number]; | |
const slope = ([x1, y1]: Point, [x2, y2]: Point) => (y2 - y1) / (x2 - x1); | |
const makeKey = ([x1, y1]: Point, [x2, y2]: Point) => | |
`(${x1},${y1}) -> (${x2},${y2})`; | |
const splitKey = (key: string): [string, string] => | |
key.split(" -> ") as [string, string]; | |
function maxPointsOnLine(points: Point[]) { | |
const slopes = new Map<string, number>(); |
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::str::FromStr; | |
#[derive(Debug)] | |
struct Rgb { | |
r: u8, | |
g: u8, | |
b: u8, | |
} | |
impl FromStr for Rgb { |
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 anyhow::{anyhow, Error, Result}; | |
use std::{fmt::Display, str::FromStr}; | |
#[derive(Debug, PartialEq, Eq)] | |
struct Fraction { | |
top: isize, | |
bottom: isize, | |
} | |
impl FromStr for Fraction { |
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
function scramble(sentences: string[]): string { | |
return sentences | |
.map((sentence) => | |
sentence | |
.split(" ") | |
.map((word) => { | |
if (word.length <= 3) { | |
return word; | |
} |
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
pub fn repeated_groups(numbers: &[u32]) -> Vec<Vec<u32>> { | |
numbers | |
.iter() | |
.fold::<Vec<Vec<u32>>, _>(vec![], |mut acc, &n| { | |
if let Some(last) = acc.last_mut() { | |
if last[0] == n { | |
last.push(n); | |
} else { | |
acc.push(vec![n]); | |
} |
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
type Query { | |
hello: String! | |
allPosts(query: PostsQuery): [Post!]! | |
featuredPosts(query: PostsQuery): [Post!]! | |
postsInCategory(categoryId: Int!, query: PostsQuery): [Post!]! | |
allTags(query: TagsQuery): [Tag] | |
viewer: User! | |
} | |
type Post { |