Skip to content

Instantly share code, notes, and snippets.

app "day01"
packages {
cli: "https://github.com/roc-lang/basic-cli/releases/download/0.7.0/bkGby8jb0tmZYsy2hg1E_B2QrCgcSTxdUlHtETwm5m4.tar.br",
parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.2.0/dJQSsSmorujhiPNIvJKlQoI92RFIG_JQwUfIxZsCSwE.tar.br",
}
imports [
cli.Stdout,
cli.Task,
parser.Core.{ Parser, between, sepBy1, map, chompWhile, flatten, oneOf, oneOrMore, skip, const, keep, buildPrimitiveParser },
parser.String.{ parseStr, codeunit, digit, codeunitSatisfies, anyCodeunit, RawStr },
@mulias
mulias / Life.roc
Created November 27, 2023 22:27
Game of Life in Roc
interface Life exposes [
Grid,
Cell,
new,
step,
addTemplate,
]
imports [
array2d.Array2D.{ Array2D, Index },
]
@mulias
mulias / Array2D.roc
Last active October 25, 2023 14:20
Roc optional record field issues
interface Array2D exposes [
Shape,
Index,
init,
initWithList,
initWithLists,
repeat,
fromList,
fromLists,
fromExactList,
@mulias
mulias / example.txt
Created October 6, 2023 16:50
AoC 2022 day 6 in Roc
mjqjpqmgbljsphdztnvjfqwrcgsmlb
@mulias
mulias / Sort.roc
Created June 23, 2023 23:15
Implementing sorting algorithms in Roc
interface Sort
exposes [slowQuicksort, fastQuicksort]
imports []
slowQuicksort : List a, (a, a -> [LT, EQ, GT]) -> List a
slowQuicksort = \list, compare ->
when list is
[] -> list
[_singleElem] -> list
[pivot, ..] ->
@mulias
mulias / day11.rb
Created December 13, 2022 23:05
Advent of Code day 11
require 'json'
def get_monkeys
JSON.parse(File.read("./input.json"), object_class: Monkey)
end
monkey_fields = [
:id,
:items,
:inspect_left,
@mulias
mulias / day09.pl
Created December 11, 2022 00:48
Advent of Code day 9
:- use_module(library(clpfd)).
:- use_module(library(dcg/basics)).
:- initialization(main, main).
main :-
part_1(Part1),
format("Part 1: ~d~n", Part1),
part_2(Part2),
format("Part 2: ~d~n", Part2),
@mulias
mulias / day_07.js
Last active December 7, 2022 20:21
AoC 2022 day 7
const SMALL_DIR_SIZE = 100000
const REQUIRED_SIZE = 30000000
const FILESYSTEM_SIZE = 70000000
const add = (a, b) => a + b
const dirSizes = (dir) => {
let sizes = []
const loadSizes = (d) => {
const filesTotal = d.files.map(f => f.size).reduce(add, 0)
@mulias
mulias / day_05.ml
Last active December 6, 2022 13:41
AoC 2022 day 5
open! Base
type crane_spec =
| CrateMover9000
| CrateMover9001
type stack = string list [@@deriving yojson]
type stacks = (int * stack) list [@@deriving yojson]
Application.put_env(:phoenix, :json_library, Jason)
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([