Mix.install([
{:benchee,
git: "https://github.com/madlep/benchee.git",
branch: "include-input_name-in-table",
override: true},
{:kino_benchee,
git: "https://github.com/madlep/kino_benchee.git", branch: "facet-charts-by-input_name"}
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
| Mix.install([{:req, "~> 0.5"}]) | |
| defmodule OrdersParser do | |
| defmacrop drop(input, str) do | |
| quote do | |
| <<unquote(str), rest::binary>> = unquote(input) | |
| rest | |
| end | |
| end |
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
| defmodule Fib do | |
| defmodule MLibby do | |
| def number(n) do | |
| [head | _] = _sequence(n) | |
| head | |
| end | |
| def sequence(n), do: Enum.reverse(_sequence(n)) | |
| defp _sequence(0), do: [0] | |
| defp _sequence(1), do: [1, 0] |
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
| # example input | |
| ["+3", "+3", "+4", "-2", "-4"] | |
| |> Enum.map(&String.to_integer/1) | |
| |> Stream.cycle() | |
| |> Enum.reduce_while({0, MapSet.new([0])}, fn n, {sum, seen} -> | |
| new_sum = sum + n | |
| if MapSet.member?(seen, new_sum) do | |
| {:halt, new_sum} | |
| else |
Solution to 105. Construct Binary Tree from Preorder and Inorder Traversal problem on LeetCode.
Given a Fibonacci number, give the previous Fibonacci number. If the number given is not a Fibonacci number, return -1.
From rendezvous with cassidoo, April 4 2022 "Interview Question Of The Week"
Given two strings n and m, return true if they are equal when both are entered into text editors. But: a # means a backspace character (deleting backwards), and a % means a delete character (deleting forwards).
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
| class Either | |
| def self.pure(value) | |
| Right.new(value) | |
| end | |
| class Left | |
| def initialize(left) | |
| @left = left | |
| end |
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
| POINTS = { | |
| "A" => 1, "B" => 3, "C" => 3, "D" => 2, | |
| "E" => 1, "F" => 4, "G" => 2, "H" => 4, | |
| "I" => 1, "J" => 8, "K" => 5, "L" => 1, | |
| "M" => 3, "N" => 1, "O" => 1, "P" => 3, | |
| "Q" => 10, "R" => 1, "S" => 1, "T" => 1, | |
| "U" => 1, "V" => 4, "W" => 4, "X" => 8, | |
| "Y" => 4, "Z" => 10 | |
| } |
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
| require "sequel" | |
| DB = Sequel.postgres("sequel_test") | |
| DB.create_table? :items do | |
| primary_key :id | |
| String :name | |
| Float :price | |
| end |
NewerOlder