[HN Gopher] Show HN: Advent of Code CLI
       ___________________________________________________________________
        
       Show HN: Advent of Code CLI
        
       Author : ttobi
       Score  : 38 points
       Date   : 2023-12-02 08:52 UTC (14 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | isoprophlex wrote:
       | > 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.
        
         | TDiblik wrote:
         | the first usecase I thought about was the tryhards that want to
         | save every second :D ... idk there could be a legitimate
         | usecase
        
           | isoprophlex wrote:
           | 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.
        
           | forgotpwd16 wrote:
           | 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.
        
         | cybrox wrote:
         | 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.
        
         | ttobi wrote:
         | 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.
        
       | riffraff wrote:
       | Clever, I've automated input fetching years ago but never
       | considered automating submission too, thanks for the idea.
        
       | sk11001 wrote:
       | Do we really need a CLI to replace Cmd-S and a copy/paste
       | command?
        
         | vulcan01 wrote:
         | This is probably for people who are trying to get on the
         | leaderboard.
        
           | ttobi wrote:
           | 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 :)
        
           | BaculumMeumEst wrote:
           | 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.
        
       | rileymichael wrote:
       | I'd recommend setting the user agent to avoid getting
       | blacklisted, info here:
       | https://www.reddit.com/r/adventofcode/wiki/faqs/automation#w...
        
         | ttobi wrote:
         | Thank you! I will do that.
        
       | nikolay wrote:
       | 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.
        
         | lloydatkinson wrote:
         | 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.
        
           | pitched wrote:
           | The task of parsing the input is the only transferable skill
           | in the whole thing.
        
             | nikolay wrote:
             | 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.
        
               | lloydatkinson wrote:
               | 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 ()
        
         | tienshiao wrote:
         | 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.
        
       | BugsJustFindMe wrote:
       | 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.
        
       ___________________________________________________________________
       (page generated 2023-12-02 23:01 UTC)