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
| git status | tail -n +5 | head -n -8 | awk '{print $2}' | grep -v snarkyjs | xargs git add |
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
| #! /bin/sh | |
| for line in `echo add.txt | cat | awk '{print $2}'`; do | |
| git add "$line" | |
| done |
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 (>>) f g a = a |> f |> g | |
| let input_lines file = | |
| let rec loop chan = | |
| match input_line chan with | |
| | line -> line :: loop chan | |
| | exception End_of_file -> [] | |
| in | |
| let chan = open_in file in | |
| let result = loop chan in | |
| close_in chan; |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| namespace interview { | |
| class Program { | |
| // check if the last 2 chars with c are the same | |
| public static bool predicate (string s, char c) { | |
| if (s.Length < 2) { |
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 constr = Equal | Less | Greater | |
| let adjacents matrix (x,y) = | |
| matrix | |
| |> Array.mapi (fun ri row -> row |> Array.mapi (fun ci _col -> ri,ci)) | |
| |> Array.to_list | |
| |> Array.concat | |
| |> Array.to_list | |
| |> List.filter (fun (ri, ci) -> (ri = x) <> (ci = y)) |
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 rec range start stop = if start > stop then [] else start :: range (succ start) stop | |
| let sum xs = List.fold_left (+) 0 xs | |
| let (>>) f g a = a |> f |> g | |
| module type Excel = sig | |
| type t | |
| val create: int -> char -> unit | |
| val set: int -> char -> int -> unit | |
| val get: int -> char -> int | |
| val sum: int -> char -> string list -> int |
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 (>=>) p1 p2 input k = p1 input (fun input -> p2 input k) | |
| let (>=>>) p1 p2 input = p1 input (fun input -> p2 input List.isEmpty) | |
| let digit input k = | |
| let rec loop input = | |
| match input with | |
| | [] -> k [] | |
| | x :: input when Char.IsDigit x -> loop input | |
| | input -> k input | |
| match input with |
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
| #include <vector> | |
| #include <string> | |
| #include <iostream> | |
| struct Node { | |
| int element; | |
| Node* next; | |
| Node* prev; | |
| }; |
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 pattern = | |
| | Char of char * pattern | |
| | Any of pattern | |
| | Wildcard of pattern | |
| | End | |
| let parsePattern (str: string) = | |
| let str = [for s in str do s] | |
| let folder c pat = | |
| match c with |
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 rec min count counts = | |
| if count = 0 then 0 | |
| else if not (List.contains count counts) then | |
| 0 | |
| else | |
| 1 + min (count - 1) counts | |
| let minDeletions (str : string) = | |
| let step m elem = |