Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Advent of Code CLI (github.com/tobias-walle)
40 points by ttobi 11 months ago | hide | past | favorite | 23 comments



I'd recommend setting the user agent to avoid getting blacklisted, info here: https://www.reddit.com/r/adventofcode/wiki/faqs/automation#w...


Thank you! I will do that.


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.


Do we really need a CLI to replace Cmd-S and a copy/paste command?


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


Author here. I am actually participating pretty causally at advent of code and don't try to get into the global leaderboards (I wouldn't be able to, even if I would try).

I build the tool for myself last year because I like the comfort of not having to switch between terminal and browser. As I wanted to use it this year again so I decided to put it into a separate repo and to share it here.

But I see the point that this a special kind of laziness not everyone can relate to :)


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?


Clever, I've automated input fetching years ago but never considered automating submission too, thanks for the idea.


I wonder why these are not available from the project directly and why input data is not in some standard format like JSON. Parsing the input for speed is the dirtiest part. If it was always in JSON, then at least that part would have been prettier!

Last nights task I did with stinky code string-splitting for speed.


I think the first (or first couple) AOC relied on JSON input more.

I assumed Eric (the creator) moved away from JSON to have a level playing field and simplify parsing (and potentially build dependencies) across various programming languages.


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.


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 ()


> 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 <my-solution>` 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 solving if against the spirit of AoC, so I will add a note to the readme to discourage it.


Nice job scratching your own itch!


This won't really make a difference in that regard. If you wanted to use AI, you could copy the input/output or just use their API directly.

I personally use a solution like this because I'm just plain and simply lazy.


the first usecase I thought about was the tryhards that want to save every second :D ... idk there could be a legitimate usecase


That's exactly what it's. Anyone trying to rank (and even if not) had a tool such as this built since AoC's origins years before AI coding solutions. Seems nowadays for many people any kind of automation implies AI assistance.


I guess they could just ditch the competetive rankings altogether now with AI coding assistants. Keep the star system to keep track of what you did yourself, at most.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: