+1
.envrc
+1
.envrc
···
1
+
use flake
+1
.zed/settings.json
+1
.zed/settings.json
···
1
+
{ "disable_ai": true, "edit_predictions": { "disabled_globs": ["*"] } }
+20
2015/1/gleam/gleam.toml
+20
2015/1/gleam/gleam.toml
···
1
+
name = "main"
2
+
version = "1.0.0"
3
+
4
+
# Fill out these fields if you intend to generate HTML documentation or publish
5
+
# your project to the Hex package manager.
6
+
#
7
+
# description = ""
8
+
# licences = ["Apache-2.0"]
9
+
# repository = { type = "github", user = "", repo = "" }
10
+
# links = [{ title = "Website", href = "" }]
11
+
#
12
+
# For a full reference of all the available options, you can have a look at
13
+
# https://gleam.run/writing-gleam/gleam-toml/.
14
+
15
+
[dependencies]
16
+
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
17
+
simplifile = ">= 2.3.0 and < 3.0.0"
18
+
19
+
[dev-dependencies]
20
+
gleeunit = ">= 1.0.0 and < 2.0.0"
+14
2015/1/gleam/manifest.toml
+14
2015/1/gleam/manifest.toml
···
1
+
# This file was generated by Gleam
2
+
# You typically do not need to edit this file
3
+
4
+
packages = [
5
+
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
6
+
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
7
+
{ name = "gleeunit", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "CD701726CBCE5588B375D157B4391CFD0F2F134CD12D9B6998A395484DE05C58" },
8
+
{ name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
9
+
]
10
+
11
+
[requirements]
12
+
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
13
+
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
14
+
simplifile = { version = ">= 2.3.0 and < 3.0.0" }
+45
2015/1/gleam/src/main.gleam
+45
2015/1/gleam/src/main.gleam
···
1
+
import gleam/int.{to_string}
2
+
import gleam/io.{println}
3
+
import gleam/list.{Continue, Stop, fold, fold_until}
4
+
import gleam/result.{unwrap}
5
+
import gleam/string.{split, trim}
6
+
import simplifile.{read}
7
+
8
+
pub type FloorIndex {
9
+
FloorIndex(floor: Int, index: Int)
10
+
}
11
+
12
+
pub fn main() {
13
+
let input = read(from: "../input.txt") |> unwrap("") |> trim() |> split("")
14
+
15
+
// part 1 - get final floor
16
+
println(
17
+
fold(input, 0, fn(fl, cur) {
18
+
case cur {
19
+
"(" -> fl + 1
20
+
")" -> fl - 1
21
+
___ -> 0
22
+
}
23
+
})
24
+
|> to_string,
25
+
)
26
+
27
+
// part 2 - get first time in the basement
28
+
println(
29
+
{
30
+
input
31
+
|> fold_until(FloorIndex(0, 1), fn(fi, cur) {
32
+
let new = case cur {
33
+
"(" -> fi.floor + 1
34
+
")" -> fi.floor - 1
35
+
___ -> 0
36
+
}
37
+
case new < 0 {
38
+
True -> Stop(FloorIndex(new, fi.index))
39
+
False -> Continue(FloorIndex(new, fi.index + 1))
40
+
}
41
+
})
42
+
}.index
43
+
|> to_string,
44
+
)
45
+
}
+29
2015/1/ts/bun.lock
+29
2015/1/ts/bun.lock
···
1
+
{
2
+
"lockfileVersion": 1,
3
+
"workspaces": {
4
+
"": {
5
+
"name": "ts",
6
+
"devDependencies": {
7
+
"@types/bun": "latest",
8
+
},
9
+
"peerDependencies": {
10
+
"typescript": "^5",
11
+
},
12
+
},
13
+
},
14
+
"packages": {
15
+
"@types/bun": ["@types/bun@1.3.1", "", { "dependencies": { "bun-types": "1.3.1" } }, "sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="],
16
+
17
+
"@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
18
+
19
+
"@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
20
+
21
+
"bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
22
+
23
+
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
24
+
25
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
26
+
27
+
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
28
+
}
29
+
}
+3
2015/1/ts/index.ts
+3
2015/1/ts/index.ts
+15
2015/1/ts/package.json
+15
2015/1/ts/package.json
+29
2015/1/ts/tsconfig.json
+29
2015/1/ts/tsconfig.json
···
1
+
{
2
+
"compilerOptions": {
3
+
// Environment setup & latest features
4
+
"lib": ["ESNext"],
5
+
"target": "ESNext",
6
+
"module": "Preserve",
7
+
"moduleDetection": "force",
8
+
"jsx": "react-jsx",
9
+
"allowJs": true,
10
+
11
+
// Bundler mode
12
+
"moduleResolution": "bundler",
13
+
"allowImportingTsExtensions": true,
14
+
"verbatimModuleSyntax": true,
15
+
"noEmit": true,
16
+
17
+
// Best practices
18
+
"strict": true,
19
+
"skipLibCheck": true,
20
+
"noFallthroughCasesInSwitch": true,
21
+
"noUncheckedIndexedAccess": true,
22
+
"noImplicitOverride": true,
23
+
24
+
// Some stricter flags (disabled by default)
25
+
"noUnusedLocals": false,
26
+
"noUnusedParameters": false,
27
+
"noPropertyAccessFromIndexSignature": false
28
+
}
29
+
}
+21
2015/2/gleam/gleam.toml
+21
2015/2/gleam/gleam.toml
···
1
+
name = "main"
2
+
version = "1.0.0"
3
+
4
+
# Fill out these fields if you intend to generate HTML documentation or publish
5
+
# your project to the Hex package manager.
6
+
#
7
+
# description = ""
8
+
# licences = ["Apache-2.0"]
9
+
# repository = { type = "github", user = "", repo = "" }
10
+
# links = [{ title = "Website", href = "" }]
11
+
#
12
+
# For a full reference of all the available options, you can have a look at
13
+
# https://gleam.run/writing-gleam/gleam-toml/.
14
+
15
+
[dependencies]
16
+
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
17
+
simplifile = ">= 2.3.0 and < 3.0.0"
18
+
gleam_json = ">= 3.0.2 and < 4.0.0"
19
+
20
+
[dev-dependencies]
21
+
gleeunit = ">= 1.0.0 and < 2.0.0"
+16
2015/2/gleam/manifest.toml
+16
2015/2/gleam/manifest.toml
···
1
+
# This file was generated by Gleam
2
+
# You typically do not need to edit this file
3
+
4
+
packages = [
5
+
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
6
+
{ name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" },
7
+
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
8
+
{ name = "gleeunit", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "CD701726CBCE5588B375D157B4391CFD0F2F134CD12D9B6998A395484DE05C58" },
9
+
{ name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
10
+
]
11
+
12
+
[requirements]
13
+
gleam_json = { version = ">= 3.0.2 and < 4.0.0" }
14
+
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
15
+
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
16
+
simplifile = { version = ">= 2.3.0 and < 3.0.0" }
+52
2015/2/gleam/src/main.gleam
+52
2015/2/gleam/src/main.gleam
···
1
+
import gleam/dynamic/decode
2
+
import gleam/int.{add, min, multiply, to_string}
3
+
import gleam/io.{println}
4
+
import gleam/json
5
+
import gleam/list.{combinations, fold, map, reduce}
6
+
import gleam/result.{unwrap}
7
+
import gleam/string.{trim}
8
+
import simplifile.{read}
9
+
10
+
pub fn main() {
11
+
let input =
12
+
read(from: "../input.json")
13
+
|> unwrap("")
14
+
|> trim()
15
+
|> json.parse(decode.list(decode.list(decode.int)))
16
+
|> unwrap([])
17
+
18
+
// part 1
19
+
println(
20
+
input
21
+
|> fold(0, fn(prev, cur) {
22
+
let sides =
23
+
cur
24
+
|> combinations(2)
25
+
|> map(fn(v) { fold(v, 1, multiply) })
26
+
27
+
prev
28
+
+ fold(sides, 0, fn(prev, cur) { prev + 2 * cur })
29
+
+ { reduce(sides, min) |> unwrap(0) }
30
+
})
31
+
|> to_string,
32
+
)
33
+
34
+
// part 2
35
+
println(
36
+
input
37
+
|> fold(0, fn(prev, cur) {
38
+
let smallest_perimeter =
39
+
reduce(
40
+
cur
41
+
|> map(fn(v) { multiply(v, 2) })
42
+
|> combinations(2)
43
+
|> map(fn(v) { fold(v, 0, add) }),
44
+
min,
45
+
)
46
+
|> unwrap(0)
47
+
48
+
prev + smallest_perimeter + fold(cur, 1, multiply)
49
+
})
50
+
|> to_string,
51
+
)
52
+
}
+29
2015/2/ts/bun.lock
+29
2015/2/ts/bun.lock
···
1
+
{
2
+
"lockfileVersion": 1,
3
+
"workspaces": {
4
+
"": {
5
+
"name": "ts",
6
+
"devDependencies": {
7
+
"@types/bun": "latest",
8
+
},
9
+
"peerDependencies": {
10
+
"typescript": "^5",
11
+
},
12
+
},
13
+
},
14
+
"packages": {
15
+
"@types/bun": ["@types/bun@1.3.1", "", { "dependencies": { "bun-types": "1.3.1" } }, "sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="],
16
+
17
+
"@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
18
+
19
+
"@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
20
+
21
+
"bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
22
+
23
+
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
24
+
25
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
26
+
27
+
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
28
+
}
29
+
}
+27
2015/2/ts/index.ts
+27
2015/2/ts/index.ts
···
1
+
const input = (await Bun.file("../input.json").json()) as [
2
+
number,
3
+
number,
4
+
number,
5
+
][];
6
+
7
+
// part 1
8
+
console.log(
9
+
input.reduce((prev, cur) => {
10
+
const sides = [cur[0] * cur[1], cur[1] * cur[2], cur[0] * cur[2]] as const;
11
+
return (
12
+
prev + (2 * sides[0] + 2 * sides[1] + 2 * sides[2] + Math.min(...sides))
13
+
);
14
+
}, 0),
15
+
);
16
+
17
+
// part 2
18
+
console.log(
19
+
input.reduce((prev, cur) => {
20
+
const smallestPerimeter = Math.min(
21
+
2 * cur[0] + 2 * cur[1],
22
+
2 * cur[1] + 2 * cur[2],
23
+
2 * cur[2] + 2 * cur[0],
24
+
);
25
+
return prev + (smallestPerimeter + cur[0] * cur[1] * cur[2]);
26
+
}, 0),
27
+
);
+15
2015/2/ts/package.json
+15
2015/2/ts/package.json
+29
2015/2/ts/tsconfig.json
+29
2015/2/ts/tsconfig.json
···
1
+
{
2
+
"compilerOptions": {
3
+
// Environment setup & latest features
4
+
"lib": ["ESNext"],
5
+
"target": "ESNext",
6
+
"module": "Preserve",
7
+
"moduleDetection": "force",
8
+
"jsx": "react-jsx",
9
+
"allowJs": true,
10
+
11
+
// Bundler mode
12
+
"moduleResolution": "bundler",
13
+
"allowImportingTsExtensions": true,
14
+
"verbatimModuleSyntax": true,
15
+
"noEmit": true,
16
+
17
+
// Best practices
18
+
"strict": true,
19
+
"skipLibCheck": true,
20
+
"noFallthroughCasesInSwitch": true,
21
+
"noUncheckedIndexedAccess": true,
22
+
"noImplicitOverride": true,
23
+
24
+
// Some stricter flags (disabled by default)
25
+
"noUnusedLocals": false,
26
+
"noUnusedParameters": false,
27
+
"noPropertyAccessFromIndexSignature": false
28
+
}
29
+
}
+20
2015/3/gleam/gleam.toml
+20
2015/3/gleam/gleam.toml
···
1
+
name = "main"
2
+
version = "1.0.0"
3
+
4
+
# Fill out these fields if you intend to generate HTML documentation or publish
5
+
# your project to the Hex package manager.
6
+
#
7
+
# description = ""
8
+
# licences = ["Apache-2.0"]
9
+
# repository = { type = "github", user = "", repo = "" }
10
+
# links = [{ title = "Website", href = "" }]
11
+
#
12
+
# For a full reference of all the available options, you can have a look at
13
+
# https://gleam.run/writing-gleam/gleam-toml/.
14
+
15
+
[dependencies]
16
+
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
17
+
simplifile = ">= 2.3.0 and < 3.0.0"
18
+
19
+
[dev-dependencies]
20
+
gleeunit = ">= 1.0.0 and < 2.0.0"
+14
2015/3/gleam/manifest.toml
+14
2015/3/gleam/manifest.toml
···
1
+
# This file was generated by Gleam
2
+
# You typically do not need to edit this file
3
+
4
+
packages = [
5
+
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
6
+
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
7
+
{ name = "gleeunit", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "CD701726CBCE5588B375D157B4391CFD0F2F134CD12D9B6998A395484DE05C58" },
8
+
{ name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
9
+
]
10
+
11
+
[requirements]
12
+
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
13
+
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
14
+
simplifile = { version = ">= 2.3.0 and < 3.0.0" }
+95
2015/3/gleam/src/main.gleam
+95
2015/3/gleam/src/main.gleam
···
1
+
import gleam/dict.{type Dict}
2
+
import gleam/int.{to_string}
3
+
import gleam/io.{println}
4
+
import gleam/list.{fold}
5
+
import gleam/result.{unwrap}
6
+
import gleam/string.{split, trim}
7
+
import simplifile.{read}
8
+
9
+
pub type Location {
10
+
Location(x: Int, y: Int)
11
+
}
12
+
13
+
pub type World =
14
+
Dict(Location, Int)
15
+
16
+
pub type State {
17
+
State(location: Location, world: World)
18
+
}
19
+
20
+
pub type Turn {
21
+
Santa
22
+
Robo
23
+
}
24
+
25
+
pub type RoboState {
26
+
RoboState(
27
+
turn: Turn,
28
+
santa_location: Location,
29
+
robo_location: Location,
30
+
world: World,
31
+
)
32
+
}
33
+
34
+
pub fn give_gift(world: World, location: Location) {
35
+
dict.insert(world, location, { dict.get(world, location) |> unwrap(0) } + 1)
36
+
}
37
+
38
+
pub fn move_to(location: Location, direction: String) {
39
+
case direction {
40
+
"^" -> Location(location.x, location.y - 1)
41
+
"v" -> Location(location.x, location.y + 1)
42
+
"<" -> Location(location.x - 1, location.y)
43
+
">" -> Location(location.x + 1, location.y)
44
+
___ -> Location(location.x, location.y)
45
+
}
46
+
}
47
+
48
+
pub fn main() {
49
+
let input = read(from: "../input.txt") |> unwrap("") |> trim() |> split("")
50
+
51
+
// part 1
52
+
println(
53
+
{
54
+
input
55
+
|> fold(State(Location(0, 0), dict.new()), fn(state, direction) {
56
+
let loc = state.location
57
+
State(move_to(loc, direction), give_gift(state.world, loc))
58
+
})
59
+
}.world
60
+
|> dict.size()
61
+
|> to_string(),
62
+
)
63
+
64
+
// part 2
65
+
println(
66
+
{
67
+
input
68
+
|> fold(
69
+
RoboState(Santa, Location(0, 0), Location(0, 0), dict.new()),
70
+
fn(state, direction) {
71
+
let sloc = state.santa_location
72
+
let rloc = state.robo_location
73
+
case state.turn {
74
+
Santa ->
75
+
RoboState(
76
+
Robo,
77
+
move_to(sloc, direction),
78
+
Location(rloc.x, rloc.y),
79
+
give_gift(state.world, sloc),
80
+
)
81
+
Robo ->
82
+
RoboState(
83
+
Santa,
84
+
Location(sloc.x, sloc.y),
85
+
move_to(rloc, direction),
86
+
give_gift(state.world, rloc),
87
+
)
88
+
}
89
+
},
90
+
)
91
+
}.world
92
+
|> dict.size()
93
+
|> to_string(),
94
+
)
95
+
}
+29
2015/3/ts/bun.lock
+29
2015/3/ts/bun.lock
···
1
+
{
2
+
"lockfileVersion": 1,
3
+
"workspaces": {
4
+
"": {
5
+
"name": "ts",
6
+
"devDependencies": {
7
+
"@types/bun": "latest",
8
+
},
9
+
"peerDependencies": {
10
+
"typescript": "^5",
11
+
},
12
+
},
13
+
},
14
+
"packages": {
15
+
"@types/bun": ["@types/bun@1.3.1", "", { "dependencies": { "bun-types": "1.3.1" } }, "sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="],
16
+
17
+
"@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
18
+
19
+
"@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
20
+
21
+
"bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
22
+
23
+
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
24
+
25
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
26
+
27
+
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
28
+
}
29
+
}
+56
2015/3/ts/index.ts
+56
2015/3/ts/index.ts
···
1
+
type Direction = "^" | "v" | "<" | ">";
2
+
interface Location {
3
+
x: number;
4
+
y: number;
5
+
}
6
+
type World = Map<string, number>;
7
+
type Turn = "Santa" | "Robo";
8
+
9
+
function giveGift(world: World, location: Location) {
10
+
const locationString = JSON.stringify(location);
11
+
return world.set(locationString, (world.get(locationString) ?? 0) + 1);
12
+
}
13
+
14
+
function moveTo(location: Location, direction: Direction) {
15
+
if (direction === "^") {
16
+
location.y -= 1;
17
+
} else if (direction === "v") {
18
+
location.y += 1;
19
+
} else if (direction === "<") {
20
+
location.x -= 1;
21
+
} else if (direction === ">") {
22
+
location.x += 1;
23
+
}
24
+
return location;
25
+
}
26
+
27
+
const input = (await Bun.file("../input.txt").text())
28
+
.trim()
29
+
.split("") as Direction[];
30
+
31
+
// the gleam one is so much better...
32
+
// part 1
33
+
{
34
+
const location: Location = { x: 0, y: 0 };
35
+
const world: World = new Map();
36
+
input.forEach((direction) => {
37
+
giveGift(world, location);
38
+
moveTo(location, direction);
39
+
});
40
+
console.log(world.size);
41
+
}
42
+
43
+
// part 2
44
+
{
45
+
const santa_location: Location = { x: 0, y: 0 };
46
+
const robo_location: Location = { x: 0, y: 0 };
47
+
const world: World = new Map();
48
+
let turn: Turn = "Santa";
49
+
const location = () => (turn === "Santa" ? santa_location : robo_location);
50
+
input.forEach((direction) => {
51
+
giveGift(world, location());
52
+
moveTo(location(), direction);
53
+
turn = turn === "Santa" ? "Robo" : "Santa";
54
+
});
55
+
console.log(world.size);
56
+
}
+15
2015/3/ts/package.json
+15
2015/3/ts/package.json
+29
2015/3/ts/tsconfig.json
+29
2015/3/ts/tsconfig.json
···
1
+
{
2
+
"compilerOptions": {
3
+
// Environment setup & latest features
4
+
"lib": ["ESNext"],
5
+
"target": "ESNext",
6
+
"module": "Preserve",
7
+
"moduleDetection": "force",
8
+
"jsx": "react-jsx",
9
+
"allowJs": true,
10
+
11
+
// Bundler mode
12
+
"moduleResolution": "bundler",
13
+
"allowImportingTsExtensions": true,
14
+
"verbatimModuleSyntax": true,
15
+
"noEmit": true,
16
+
17
+
// Best practices
18
+
"strict": true,
19
+
"skipLibCheck": true,
20
+
"noFallthroughCasesInSwitch": true,
21
+
"noUncheckedIndexedAccess": true,
22
+
"noImplicitOverride": true,
23
+
24
+
// Some stricter flags (disabled by default)
25
+
"noUnusedLocals": false,
26
+
"noUnusedParameters": false,
27
+
"noPropertyAccessFromIndexSignature": false
28
+
}
29
+
}
+27
flake.lock
+27
flake.lock
···
1
+
{
2
+
"nodes": {
3
+
"nixpkgs": {
4
+
"locked": {
5
+
"lastModified": 1761880412,
6
+
"narHash": "sha256-QoJjGd4NstnyOG4mm4KXF+weBzA2AH/7gn1Pmpfcb0A=",
7
+
"owner": "nixos",
8
+
"repo": "nixpkgs",
9
+
"rev": "a7fc11be66bdfb5cdde611ee5ce381c183da8386",
10
+
"type": "github"
11
+
},
12
+
"original": {
13
+
"owner": "nixos",
14
+
"ref": "nixpkgs-unstable",
15
+
"repo": "nixpkgs",
16
+
"type": "github"
17
+
}
18
+
},
19
+
"root": {
20
+
"inputs": {
21
+
"nixpkgs": "nixpkgs"
22
+
}
23
+
}
24
+
},
25
+
"root": "root",
26
+
"version": 7
27
+
}
+28
flake.nix
+28
flake.nix
···
1
+
{
2
+
description = "advent_of_code";
3
+
4
+
inputs = {
5
+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
6
+
};
7
+
8
+
outputs = {
9
+
self,
10
+
nixpkgs,
11
+
}: let
12
+
forAllSystems = function:
13
+
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
14
+
system: function nixpkgs.legacyPackages.${system}
15
+
);
16
+
in {
17
+
#packages = forAllSystems (pkgs: {
18
+
# example = pkgs.callPackage ./default.nix { };
19
+
# default = self.packages.${pkgs.stdenv.hostPlatform.system}.example;
20
+
#});
21
+
22
+
devShells = forAllSystems (pkgs: {
23
+
default = pkgs.callPackage ./shell.nix {inherit pkgs;};
24
+
});
25
+
26
+
#overlays.default = final: _: {example = final.callPackage ./default.nix {};};
27
+
};
28
+
}
+15
shell.nix
+15
shell.nix
+20
template/gleam/gleam.toml
+20
template/gleam/gleam.toml
···
1
+
name = "main"
2
+
version = "1.0.0"
3
+
4
+
# Fill out these fields if you intend to generate HTML documentation or publish
5
+
# your project to the Hex package manager.
6
+
#
7
+
# description = ""
8
+
# licences = ["Apache-2.0"]
9
+
# repository = { type = "github", user = "", repo = "" }
10
+
# links = [{ title = "Website", href = "" }]
11
+
#
12
+
# For a full reference of all the available options, you can have a look at
13
+
# https://gleam.run/writing-gleam/gleam-toml/.
14
+
15
+
[dependencies]
16
+
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
17
+
simplifile = ">= 2.3.0 and < 3.0.0"
18
+
19
+
[dev-dependencies]
20
+
gleeunit = ">= 1.0.0 and < 2.0.0"
+14
template/gleam/manifest.toml
+14
template/gleam/manifest.toml
···
1
+
# This file was generated by Gleam
2
+
# You typically do not need to edit this file
3
+
4
+
packages = [
5
+
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
6
+
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
7
+
{ name = "gleeunit", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "CD701726CBCE5588B375D157B4391CFD0F2F134CD12D9B6998A395484DE05C58" },
8
+
{ name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
9
+
]
10
+
11
+
[requirements]
12
+
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
13
+
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
14
+
simplifile = { version = ">= 2.3.0 and < 3.0.0" }
+8
template/gleam/src/main.gleam
+8
template/gleam/src/main.gleam
+29
template/ts/bun.lock
+29
template/ts/bun.lock
···
1
+
{
2
+
"lockfileVersion": 1,
3
+
"workspaces": {
4
+
"": {
5
+
"name": "ts",
6
+
"devDependencies": {
7
+
"@types/bun": "latest",
8
+
},
9
+
"peerDependencies": {
10
+
"typescript": "^5",
11
+
},
12
+
},
13
+
},
14
+
"packages": {
15
+
"@types/bun": ["@types/bun@1.3.1", "", { "dependencies": { "bun-types": "1.3.1" } }, "sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="],
16
+
17
+
"@types/node": ["@types/node@24.9.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA=="],
18
+
19
+
"@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
20
+
21
+
"bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
22
+
23
+
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
24
+
25
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
26
+
27
+
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
28
+
}
29
+
}
+1
template/ts/index.ts
+1
template/ts/index.ts
···
1
+
const input = (await Bun.file("../input.txt").text()).trim();
+15
template/ts/package.json
+15
template/ts/package.json
+29
template/ts/tsconfig.json
+29
template/ts/tsconfig.json
···
1
+
{
2
+
"compilerOptions": {
3
+
// Environment setup & latest features
4
+
"lib": ["ESNext"],
5
+
"target": "ESNext",
6
+
"module": "Preserve",
7
+
"moduleDetection": "force",
8
+
"jsx": "react-jsx",
9
+
"allowJs": true,
10
+
11
+
// Bundler mode
12
+
"moduleResolution": "bundler",
13
+
"allowImportingTsExtensions": true,
14
+
"verbatimModuleSyntax": true,
15
+
"noEmit": true,
16
+
17
+
// Best practices
18
+
"strict": true,
19
+
"skipLibCheck": true,
20
+
"noFallthroughCasesInSwitch": true,
21
+
"noUncheckedIndexedAccess": true,
22
+
"noImplicitOverride": true,
23
+
24
+
// Some stricter flags (disabled by default)
25
+
"noUnusedLocals": false,
26
+
"noUnusedParameters": false,
27
+
"noPropertyAccessFromIndexSignature": false
28
+
}
29
+
}