Live data from Hacker News

Show HN: Advent of Code CLI

github.com

21–25 of 25 posts

Re: Show HN: Advent of Code CLI

#21
post #20

Earlier quoted context omitted.

I’ve often wondered why AOC and hackerrank and the like have you solving the required problem AND the implicit task of parsing the input.

The task of parsing the input is the only transferable skill in the whole thing.

But you can't do a decent job if you want to earn points. Parsing requires diligence and less assumption. Add one extra space, and the whole AOC parsing leads to unpredictable results.

Re: Show HN: Advent of Code CLI

#22
post #21
post #20

Earlier quoted context omitted.

The task of parsing the input is the only transferable skill in the whole thing.

But you can't do a decent job if you want to earn points. Parsing requires diligence and less assumption. Add one extra space, and the whole AOC parsing leads to unpredictable results.

One of my solutions last year, with F#, was very aware of bad input and was robust against it.

Here's a part of it:

        type Shape =
            | Rock
            | Paper
            | Scissors

        let parseCharacters (line: string) =
            let onlySingleCharacters (a: string, b: string) = a.Length = 1 && b.Length = 1

            match line.Split() with
            | [| a; b |] when onlySingleCharacters (a, b) ->
                match a[0], b[0] with
                | 'A', 'X' -> Some(Rock, Rock)
                | 'A', 'Y' -> Some(Rock, Paper)
                | 'A', 'Z' -> Some(Rock, Scissors)
                | 'B', 'X' -> Some(Paper, Rock)
                | 'B', 'Y' -> Some(Paper, Paper)
                | 'B', 'Z' -> Some(Paper, Scissors)
                | 'C', 'X' -> Some(Scissors, Rock)
                | 'C', 'Y' -> Some(Scissors, Paper)
                | 'C', 'Z' -> Some(Scissors, Scissors)
                | _ -> None
            | _ -> None

        let rec readLines () =
            let line = Console.ReadLine()

            match line with
            | null
            | "" -> []
            | _ ->
                match parseCharacters line with
                | Some parsedLine -> parsedLine :: readLines ()
                | None -> readLines ()

Re: Show HN: Advent of Code CLI

#23
post #9

Earlier quoted context omitted.

This is probably for people who are trying to get on the leaderboard.

i watch someone who consistently places top 5 on youtube. they code in vim on windows in the terminal, exit vim to run at the command line, and then copy and paste from the terminal into a browser.

Now the real question is, what does the top 1 person use? Emacs? VSCode?

Re: Show HN: Advent of Code CLI

#24
post #11

> Tool to automate downloading and submitting advent of code problems. Well... the biggest use case I can think of is automated, AI assisted, problem solving. Which isn't really aligned with the spirit of AOC. In fact they politely asked people not to, if I'm not mistaken.

I am actually using it to submit my solutions without leaving the editor (out of lazyness). I just need to run `aoc submit ` and immediately get feedback if I am correct. If that it the case, it automatically downloads the second problem so I can immediately continue. As explained in another comment I'm not participating competitively. I just really like automating things. I also think that AI assisted program solvin…

Nice job scratching your own itch!

Re: Show HN: Advent of Code CLI

#25

It's funny to me how much of the code is just replicating behavior you would already have for free if you just had a small shell script that used standard tools like curl and sed, and it wouldn't need to be compiled, and it would be one single file instead of four with a nested source directory, and it wouldn't have 2000 lines of cargo config.

Absolutely, the basic functionality could be easily hacked together with a small shell script. But parsing the html and converting it to markdown would be probably not possible without extra tooling (I wouldn’t feel comfortable doing it with sed). I also like that with the current implementation you are basically getting the “—help” argument for free.

Using Rust for a simple tool like this is, of course, a total overkill and something like Python or Go would do the same job with much less code. But I enjoy writing Rust and was already using it to solve the AoC problems :)

I also like the fact that the tool is now very easy to install with Cargo without me having to upload it to some package manager.

The 2000 lines are in the Cargo.lock file, which is generated. The actual config is 18 lines. Of course having that many dependencies is worth criticizing.

Post reply on HN