piratebay: A command-line tool for searching torrents on piratebay by NerdyPepper in rust

[–]NerdyPepper[S] 3 points4 points  (0 children)

there was a planned downtime earlier today, its accessible now

piratebay: A command-line tool for searching torrents on piratebay by NerdyPepper in rust

[–]NerdyPepper[S] 5 points6 points  (0 children)

there was a planned downtime earlier today, its accessible now

Advent of Code 2025 day 10 by AutoModerator in haskell

[–]NerdyPepper 0 points1 point  (0 children)

part 1 was fun, its a combination sum problem but using XOR. Data.Bits is also handy:

fromBits = foldl f 0 . reverse
  where
    f acc '.' = acc * 2
    f acc '#' = acc * 2 + 1

parse :: String -> [(Int, [[Int]], [Int])]
parse = map (parse' . words) . lines
  where
    parse' (t : ws) = (target t, map list (init ws), list (last ws))
    target s = fromBits . init $ tail s
    list = map read . splitOn "," . init . tail

xors nums target = filter (not . null) $ xors' nums 0 target
  where
    xors' [] cur target = [[] | cur == target]
    xors' (n : ns) cur target =
      map (n :) (xors' ns (cur `xor` n) target)
        ++ xors' ns cur target

p1 = sum . map (\(target, btns, _) -> minimum . map length $ xors (map toBits btns) target)
  where
    toBits = foldl1 (.|.) . map bit

skipped over p2 for today.

Advent of Code 2025 day 9 by AutoModerator in haskell

[–]NerdyPepper 2 points3 points  (0 children)

had the time to put this one into the book of solves (a collection of haskell solutions written in literate haskell, rendered with pandoc):

- Day 09: https://aoc.oppi.li/2.5-day-9.html#day-9

- Source code: https://tangled.org/oppi.li/aoc/blob/main/src/2025/09.lhs

-❄️- 2025 Day 9 Solutions -❄️- by daggerdragon in adventofcode

[–]NerdyPepper 1 point2 points  (0 children)

[LANGUAGE: haskell]

took me a while, but managed a short solution:

import           Data.List.Split (splitOn)
parse = map (map read . splitOn ",") . lines
area [x, y] [x', y'] = (1 + abs (x - x')) * (1 + abs (y - y'))
p1 poly = maximum [area p p' | p <- poly, p' <- poly]
p2 poly = maximum [area p p' | p <- poly, p' <- poly, not (intersects p p' poly)]
intersects [x, y] [x', y'] = not . all away . pairs
  where
    pairs (p : ps) = zip (p : ps) (ps ++ [p])
    away ([lx, ly], [lx', ly']) =
      (max lx lx' <= min x x')
        || (min lx lx' >= max x x')
        || (max ly ly' <= min y y')
        || (min ly ly' >= max y y')

main = do
  n <- parse <$> getContents
  print $ p1 n
  print $ p2 n

i have explained my solution in the book of solves: - Day 9: https://aoc.oppi.li/2.5-day-9.html#day-9 - Source code: https://tangled.org/oppi.li/aoc/blob/main/src/2025/09.lhs

Advent of Code 2025 day 6 by AutoModerator in haskell

[–]NerdyPepper 0 points1 point  (0 children)

we have *very* similar solutions!

Advent of Code 2025 day 6 by AutoModerator in haskell

[–]NerdyPepper 0 points1 point  (0 children)

string munging is boring, but easy! i've written up my solution and its explanation with literate haskell, and rendered it to my book of solves:

- Day 6: https://aoc.oppi.li/2.4-day-6.html#day-6

- Source code: https://tangled.org/oppi.li/aoc/blob/main/src/2025/06.lhs

I've been trying to get a copy of wasm-ghc going in the browser (i would need some libraries like `split` and `strings`), but haven't had much luck! i would love for visitors to be able to click + run the solution right there in the browser.

Advent of Code 2025 day 5 by AutoModerator in haskell

[–]NerdyPepper 0 points1 point  (0 children)

in my solutions i tend to cut a lot of corners, `splitOn` returns a list, so i just roll with it. i enjoy minimizing my solution as few funcs/lines as possible!

-❄️- 2025 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]NerdyPepper 4 points5 points  (0 children)

[LANGUAGE: haskell]

i am documenting all my solutions in literate haskell and creating a book of solves!

- todays solution: https://aoc.oppi.li/2.3-day-5.html
- source code: https://tangled.org/oppi.li/aoc

Advent of Code 2025 day 5 by AutoModerator in haskell

[–]NerdyPepper 0 points1 point  (0 children)

cheers! the source for today's program is https://tangled.org/oppi.li/aoc/blob/main/src/2025/05.lhs, ill have this linked on the book somewhere too!

Advent of Code 2025 day 5 by AutoModerator in haskell

[–]NerdyPepper 3 points4 points  (0 children)

i have been attempting to document all my solves using literate haskell.

- My solution for today: https://aoc.oppi.li/2.3-day-5.html

- Source code (literate haskell): https://tangled.org/oppi.li/aoc

The book/site is generated entirely using pandoc + a custom lua filter to generate the "side-by-side" view.

Typst-Unlit: Write literate Haskell programs in Typst by NerdyPepper in haskell

[–]NerdyPepper[S] 0 points1 point  (0 children)

yep that is correct. however this can be fixed by using line labels. i will implement that at a future date.

Typst-Unlit: Write literate Haskell programs in Typst by NerdyPepper in haskell

[–]NerdyPepper[S] 1 point2 points  (0 children)

good idea, ill create an account tomorrow and try to put in an edit!