https://codesandbox.io/dashboard/home
Video Course: https://www.tocode.co.il/bundles/es6
| # App port to run on | |
| PORT=3000 | |
| # The name of the site where Kutt is hosted | |
| SITE_NAME=Kutt | |
| # The domain that this website is on | |
| DEFAULT_DOMAIN=localhost:3000 | |
| # Generated link length |
| defmodule Day22_2 do | |
| def read_input do | |
| File.read!("input/day22.txt") | |
| |> String.split("\n\n", trim: true) | |
| |> Enum.map(fn deck_str -> | |
| deck_str | |
| |> String.split("\n", trim: true) | |
| |> Enum.drop(1) | |
| |> Enum.map(&String.to_integer/1) | |
| end) |
| defmodule Day21 do | |
| def read_input do | |
| File.read!("input/day21.txt") | |
| |> String.split("\n", trim: true) | |
| end | |
| def ingredients_list(line) do | |
| [ingredients_str, _alergens_str] = String.split(line, [" (contains ", ")"], trim: true) | |
| String.split(ingredients_str, " ", trim: true) | |
| end |
| defmodule Day18 do | |
| def read_input do | |
| File.read!("input/day18.txt") | |
| |> String.split("\n", trim: true) | |
| end | |
| def solve_part2(expr) do | |
| cond do | |
| String.contains?(expr, "(") -> | |
| Regex.replace(~r/\(([^()]+)\)/, expr, fn _, expr -> solve_part2(expr) end) |
| defmodule Day17 do | |
| def read_input do | |
| File.read!("input/day17.txt") | |
| |> String.split("\n", trim: true) | |
| |> Enum.map(&String.graphemes/1) | |
| |> Enum.map(&Enum.with_index/1) | |
| |> Enum.with_index | |
| |> Enum.flat_map(fn {line, row} -> Enum.map(line, fn {el, col} -> {{row, col, 0}, el } end) end) | |
| |> Enum.into(%{}) | |
| end |
| defmodule Day15 do | |
| def play(%{ :history => history, :last_value => value, :last_index => index }) do | |
| next_history = seen(history, value, index) | |
| next_value = get_value(next_history, value) | |
| %{ | |
| :history => next_history, | |
| :last_index => index + 1, | |
| :last_value => next_value, |
| defmodule VM14 do | |
| use Bitwise | |
| defstruct [:memory, :mask_bits_for_and, :mask_values_for_or] | |
| def new do | |
| %VM14{memory: %{}, mask_bits_for_and: 0, mask_values_for_or: 0, mask_str: "0"} | |
| end | |
| def update_mask(vm, mask_str) do | |
| mask_bits_for_and = mask_str |
| defmodule Day13 do | |
| def read_input do | |
| [start_time, bus_times] = File.read!("input/day13.txt") | |
| |> String.split("\n", trim: true) | |
| times = String.split(bus_times, ",", trim: true) | |
| |> Enum.reject(&(&1 == "x")) | |
| |> Enum.map(&String.to_integer/1) | |
| [String.to_integer(start_time), times] |
| defmodule Ship do | |
| defstruct heading: 90, pos: { 0, 0 } | |
| def distance(ship) do | |
| Tuple.to_list(ship.pos) | |
| |> Enum.map(&(abs(&1))) | |
| |> Enum.sum | |
| end | |
| def move(ship, %{ "dir" => "L", "steps" => degrees}) do |