Skip Navigation
advent_of_code

Advent Of Code

  • Day 25: Snowverload

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    6
  • Hey everyone! Thought I would do a post ahead of the event to cover the major topics that will probably come up

    ---

    What is Advent of Code?

    Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

    Each day will have two different puzzles that must be solved in order (you get access to the second after solving the first). Each puzzle has the same backstory but each person has different input they get for that puzzle.

    Puzzles are released every day at midnight ET and can be completed anytime after they are released (but people who solve them quicker after theyre been released get more points for the site leaderboard)

    (Puzzles are on https://adventofcode.com)

    ---

    What can I post here?

    Anything relating to the event! Whether that be a meme, asking for help, sharing solutions, etc.

    How should I format my post titles?

    Try to keep titles in this general format:

    > [help, etc. category if applicable] [YEAR Day # (Part X)] [programming language if applicable] Post Title

    For example:

    > [2023 Day #5 (Part 3)] [Rust] My attempt at a solution

    Another example:

    > [Help] [2023 Day #2] What does this sentence mean

    This helps people avoid spoilers and lets people use it as an archive by searching if they find out about the event in the middle and are starting from the beginning then

    Should I post in the solution thread or separately?

    If its just a solution try to keep it in the solution megathread so the community doesn't get spammed with solutions! If you add something onto that such as a doing a visualization, making it a meme, or etc. though feel free to post it separately

    What can I post in the solution megathread?

    The top level comments in the solution megathread should be solutions to that day. If you want to write something that is not a solution feel free to make a new post about it.

    Any replies to top level comments though can be whatever

    ---

    Lemmy-UI doesn't handle code blocks well, what do I do?

    I pushed an update to lemmy-ui that adds code block support that will be arriving to all instances in version 0.19. This is currently in release clients and I expect it to release in the middle of the event.

    For now though feel free to mirror any code you post onto some other site such as pastebin. if you can try to do both code blocks and pastebin to future proof it for when 0.19 eventually drops

    To make a code block make three backticks, make a new line and put the code on lines, then put a newline and do three backticks on that

    e.g.

    \\\ console.log('Hello World') \\\

    becomes

    console.log('Hello World')

    If your instance decided to beta test 0.19 you might be able to see code blocks already on the site, I put a code block above and in the sidebar so if one of those renders for you you have code block support

    If youre using an app instead of the site though this section does not apply to you and depends on whether the developer of your app has added code block support or not

    0
  • Hey everyone! I set up a private leaderboard for the programming.dev community so we can have one for the community in addition to the global one

    The leaderboard code is 3316962-6587d422

    Looking forward to seeing you guys there! Ill make a post at the end with the top people on the leaderboard and the version on the site will auto update as people complete challenges

    ---

    Full instructions on Joining the Leaderboard

    • Log in on https://adventofcode.com/ using one of the methods such as through GitHub
    • Go to the leaderboard section in the navbar
    • Click the private leaderboard button on the page
    • Enter 3316962-6587d422 into the text box for entering a leaderboard join code
    • Click join

    Update: Ive made a new leaderboard so that I could rename it to something that isnt just my username, the code there is updated to the new one that should be joined

    5
  • AoC has ended for the year! Congrats to everyone who participated

    Here are some stats from the instance leaderboard

    Top 10 Users

    1. SekoiaTree
    2. Leo Uino
    3. Michon van Dooren
    4. funnyboy-roks
    5. PhiliPdB
    6. jhuang97
    7. Alex Utter
    8. hades
    9. Jindล™ich Ivรกnek
    10. abclop99

    Misc Stats

    • 91 Users got at least 1 star
    • 14 Users got 50 stars
    3
  • Link to full results:

    https://jeroenheijmans.github.io/advent-of-code-surveys/

    3
  • 2
  • Day 24: Odds

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    3
  • Spoilers and explanation of solution:

    Each vertex here is one intersection in our hike. We don't actually care about the parts in-between, because there's only one way to go. The above is a visualisation of the final path, the red edges are the edges taken. Our graph looks "like that" because it's a hiking trail, not a maze, so there's no dead ends. This took about 2 seconds to generate, due to all the cloning needed to keep track of paths. The two veeery long edges on the ends are pretty obvious choices, but one might notice that pretty much every vertex takes the two maximum paths it has, given the restrictions of the path. There's still some mildly surprising paths, such as (99, 29) -> (89, 37) with a weight of 38. I'm wondering if there's a way to dismiss more paths... This graph is actually pretty free in terms of movement.

    My actual solution takes ~150 ms to run (and 8 microseconds for part one with barely any optimization, damnn)

    1
  • Day 22: A Long Walk

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    5
  • Day 22: Sand

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    5
  • Day 21: Step

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    7
  • Day 20: Pulse

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    4
  • Day 19: Aplenty

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    4
  • Day 18: Lavaduct Lagoon

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    16
  • Anybody got some ideas to optimize today? I've got it down to 65ms (total) on my desktop, using A* with a visitation map. Each cell in the visitation map contains (in part 2) 16 entries; 4 per direction of movement, 1 for each level of straightaway. In part 2, I use a map with 11 entries per direction.

    Optimizations I've implemented:

    • use a 2D array instead of a hashset/map. No idea how much this saves, I did it in the first place.
    • the minimum distance for a specific cell's direction + combo applies for higher combo levels as well for part 1. For part 2, if the current combo is greater than 4, we do the same*. Gains about 70(!!) ms
    • A* heuristic weighting optimization, a weight of about 1% with a manhattan distance heuristic seems to gain about 15 ms (might be my input only tho)

    *Correctness-wise: the reason we're splitting by direction is because there's a difference between being at a cell going up with a 3 combo but a really short path, and going right with a 0 combo but a long path. However, this is fine because a 3 combo in the same direction as a 0 combo is identical, just more restrictive.

    Optimizations that could be done but I need to ensure correctness:

    the same optimization for the combo, but for directions. If I'm on a specific combo+direction, does that imply something about the distance for another direction? Simply doing the same for every non-opposite direction isn't correct

    Code: https://codeberg.org/Sekoia/adventofcode/src/branch/main/src/y2023/day17.rs

    Warning: quite ugly, there's like 8 copy-pastes for adding to the queue

    4
  • Day 17: Clumsy Crucible

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    10
  • Day 16: The Floor Will Be Lava

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    12
  • Day 15: Lens Library

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465

    ---

    ๐Ÿ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

    Edit: ๐Ÿ”“ Unlocked

    18
  • Thought I'd share mine because most of the visualisations out there show the rocks sliding one cell at a time, all together. That looks nice but for my solution that's not how it works - I walk every row/col with two cursors.

    Code here: https://github.com/sjmulder/aoc/blob/master/2023/c/day14.c

    The visualisation is emitted right from the solution using a small library which dumps frames to ffmpeg.

    1
  • Day 14: Parabolic Reflector Dish

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465

    ---

    ๐Ÿ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

    Edit: ๐Ÿ”“ Unlocked

    17
  • Day 13: Point of Incidence

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465

    ---

    ๐Ÿ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

    ๐Ÿ”“ Unlocked

    17
  • https:// programming.dev /c/advent_of_code

    cross-posted from: https://programming.dev/post/7188393

    > This community still mostly has me running it and has 1 other mod but I typically like starting communities off with at least 2 mods. This community is a bit different in that theres the solution megathreads that need to be posted when a new day drops (and then unlocked when the global leaderboard fills up). When it has a dedicated mod team running it ill remove myself so its not admin run > > If youre interested feel free to say so below > > !advent_of_code@programming.dev > > Note: to be a mod its preferred if your account is within the instance since lemmy doesnt handle cross-instance modding that well and this makes it so you have access to features added to pangora that other instances may not have

    6
  • We all know and love (!) the leaderboard, but how about a different method?

    One can solve a problem with a simple, naive method resulting in a short program and long runtime, or put in lots of explicit optimizations for more code and shorter runtime. (Or if you're really good, a short, fast program!)

    I propose the line-second.

    Take the number of lines in your program (eg, 42 lines) and the runtime (eg 0.096 seconds). Multiply these together to get a score of 4.032 line-seconds.

    A smaller score is a shorter, faster program.

    Similarly, (for a particular solver), a larger score is a "harder" problem.

    8
  • So I managed to get part 1 of the day, but it took 2 seconds to run on the real input, which is a bad sign.

    I can't see any kind of optimisation that means I can skip checks and know how many combinations are in those skipped checks (aside from 0.) I can bail out of branches of combinations if the info so far won't fit, but that still leads me to visiting every valid combination which in one of the examples is 500k. (And probably way more in the input, since if I can't complete the example near instantly the input is not happening.)

    Right now I take the string, then replace the first instance of a ? with the two possible options. Check it matches the check digits so far then use recursion on those two strings.

    I can try to optimise the matching, but I don't think that solves the real problem of visiting every combination.

    I don't think (or hope) it's just bad code but this is my code so far (python.)

    edit:

    spoiler

    a cache was the solution!

    5
  • Day 12: Hot Springs

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465

    ---

    ๐Ÿ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

    ๐Ÿ”“ Unlocked after 25 mins

    14
  • I wanted to show how the maze follows from individual letters but it was way too large

    4
  • Day 11: Cosmic Expansion

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465

    ---

    ๐Ÿ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

    ๐Ÿ”“ Unlocked after 9 mins

    20
  • Day 10: Pipe Maze

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465

    ---

    ๐Ÿ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

    ๐Ÿ”“ Unlocked after 40 mins

    28
  • https://www.reddit.com/r/adventofcode/comments/18dry49/2023_day_8_part_2glsl_brute_forced_in_under_a/

    17
  • Day 9: Mirage Maintenance

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465

    ---

    ๐Ÿ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

    ๐Ÿ”“ Unlocked after 5 mins

    27
  • โ€ข 93%
    www.crunchydata.com Advent of Code in PostgreSQL: Tips and Tricks from 2022

    Thinking about solving the Advent of Code in Postgres? I did it last year and I have summary of how to get started and some tips and tricks for writing your own solutions.

    3
  • I had 6 parallel paths, and for all of them, the goal node was found at the point where the directions string repeated. So I actually only had to search each of the paths for the point where I was on the goal position and the first direction. This worked on the input data, but not the example. See the assert in the code, and note that the statement println!("Found non-repeat at {node} step {step} (num dirs {num_directions})"); is never executed.

    At the end there's also the first attempt of brute-forcing the solution which seems like it would have taken nearly forever.

    ```rust use std::collections::HashMap;

    use regex::Regex;

    use crate::input::Source;

    pub fn execute(source: Source) -> impl std::fmt::Debug { let lines = source.lines(); let ([directions], [empty, nodes @ ..]) = lines.split_at(1) else { panic!("Wrong format"); }; assert!(empty.is_empty());

    let node_re = Regex::new(r"(...) = \((...), (...)\)").unwrap(); let nodes: HashMap = nodes .iter() .map(|line| { let caps = node_re.captures(line).unwrap(); let name = caps[1].to_string(); let left = caps[2].to_string(); let right = caps[3].to_string(); (name, (left, right)) }) .collect();

    let start_nodes: Vec = nodes.keys().filter(|n| n.ends_with('A')).cloned().collect(); let repeat_lengths: Vec = start_nodes .iter() .map(|node| { let (repeat_length, goal_steps) = find_repeats(node, directions, &nodes); assert!(goal_steps.is_empty()); // not a given, but that's what the input looks like dbg!(node, repeat_length, goal_steps); repeat_length }) .collect();

    repeat_lengths.iter().cloned().reduce(num::integer::lcm) }

    /// (repeat length, steps to goal node within repeat) fn find_repeats( starting_node: &str, directions: &str, nodes: &HashMap, ) -> (usize, Vec) { let mut node = starting_node.to_string(); let num_directions = directions.chars().count(); let mut goals = Vec::new(); for (step, dir) in directions.chars().cycle().enumerate() { if node.ends_with('Z') { if step % num_directions == 0 { println!("Found repeat at {node} step {step} (num dirs {num_directions})"); return (step, goals); } println!("Found non-repeat at {node} step {step} (num dirs {num_directions})"); goals.push(step); } let (left, right) = &nodes[&node]; node = match dir { 'L' => left.clone(), 'R' => right.clone(), other => panic!("Unknown dir {other}"), } } unreachable!() }

    // too slow #[allow(dead_code)] fn find_parallel( start_nodes: &[String], directions: &str, nodes: &HashMap, ) -> usize { let mut current_nodes = start_nodes.to_vec(); for (step, dir) in directions.chars().cycle().enumerate() { if current_nodes.iter().all(|n| n.ends_with('Z')) { return step; } for node in current_nodes.iter_mut() { let (left, right) = nodes[node].clone(); *node = match dir { 'L' => left, 'R' => right, other => panic!("Unknown dir {other}"), } } } unreachable!() } ```

    3
  • Day 8: Haunted Wasteland

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
    27
  • The instructions for part 2 are missing info about how to handle the Four Of A Kind and a joker case. Wasted quite some time because I assumed that the remaining joker would remain unused, but turns out it turns your deck into Five Of A Kind.

    Did everybody else just expect this?

    5
  • Day 7: Camel Cards

    Megathread guidelines

    • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
    • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ , pastebin, or github (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

    FAQ

    • What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
    • Where do I participate?: https://adventofcode.com/
    • Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465

    ---

    ๐Ÿ”’ Thread is locked until there's at least 100 2 star entries on the global leaderboard

    ๐Ÿ”“ Thread has been unlocked after around 20 mins

    35
  • โ€ข 100%
    forms.gle Unofficial Advent of Code 2023 Survey

    This is a quick (unofficial / not affiliated with) Advent of Code 2023 anonymous (if you don't disclose your identity in "Other..." answers) participant survey. Note that your data will be shared as part of a (possibly sanitized and trimmed) data set to be published under the Open Database License 1...

    Survey by u/jeroenheijmans Closes Dec 22

    3
  • I messed around in desmos for like 20 mins trying to find an algebraic solution to day 6 and made this. I feel as if this is the best way to solve the problem by graphing f(x) = (x-max_time/2)^2. Finding its y-intercept, finding its vertex (max_time/2) and then finding the minimum x needed to get the max distance by solving for max_distance = f(x).

    ```rust fn main() { let mut raw_input = include_str!("input.txt") .lines() .map(|f| {

    f.split_ascii_whitespace() .skip(1) .collect::<String>() .parse::<usize>() .unwrap()

    //for part 1, first parse then collect to a Vec<&str>

    }) ;

    let max_time = raw_input.next().unwrap(); let max_distance = raw_input.next().unwrap();

    print!("{}", determine_range(max_time, max_distance));

    //let max_times = raw_input.next().unwrap(); //let max_distances = raw_input.next().unwrap();

    // let races = (0..max_times.len()).map(|i| { // determine_range(max_times[i], max_distances[i]) // });

    // let total = races.reduce(|acc,x| x*acc).unwrap(); }

    fn determine_range(max_time: usize, max_dist: usize) -> f64 { let vertex = max_time as f64/2.0; let min_y = vertex * vertex - max_dist as f64; let min_x = vertex - min_y.sqrt()+ 0.001;

    let mut res = 2.0 * ( (vertex-0.001).floor() - min_x.ceil() + 1.0); if vertex.fract() == 0.0 { res+=1.0; } res } ```

    1
1 Active user