Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
advent-of-code
all my AoC solutions over the years (leaderboard: 66th place in 2022, 53rd place in 2020) (by kwshi)
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
AoC2022
A collection for my Advent of Code (https://adventofcode.com/) solutions using the Nim programming languages (https://nim-lang.org/) (by genius487)
-
advent-of-code-scala
Complete 2022 to 2015 entries for the annual Advent of Code challenge, written in concise idiomatic functional Scala.
-
AdventOfCode
Hacky solutions for [Advent of Code](https://adventofcode.com), working on past problems (by AllanTaylor314)
-
advent-of-code-2022
š Advent of Code 2022 - It's the Most Wonderful Time of the Year... (by MrRobb)
-
advent-of-code-2022
My solutions for the https://adventofcode.com puzzles (2022) šš (by ClouddJR)
-
adventofcode
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 and 2023 in Scala (by sim642)
-
AOC_2022
Advent of Code 2022 - the mediocre (mainly) python code of a self-taught amateur with too much time on her hands. (by pamdemonia)
-
aoc2022
Trying to solve Advent of Code 2022 in 25 different languages (1 day = 1 language) (by GoldsteinE)
-
Advent-of-Code
Advent of Code is an 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 (by SvetlanaM)
-
advent_of_code_2022
My daily solutions to the Advent of Code 2022 programming puzzles. (by szmate00)
-
advent-of-code-2022
Attempts at the Advent of Code Challenge for 2022 - see https://adventofcode.com/ (by djm4)
-
advent-of-code-2022
My solutions to the 2022 Advent of Code as shiny Jupyter notebooks. You can run and interact with the code and the solutions directly from your browser via Binder. (by markusschanta)
-
advent-of-code-2022
Solutions to Advent of Code 2022 puzzles https://adventofcode.com/2022 (by Lysander6)
-
AoC2020
Advent Of Code, yearly puzzle extravaganza in the days leading up to Christmas. (by GoldenQubicle)
-
aoc22_dart_code_golf
AdventOfCode 2022 in Dart focusing on code golf, making the solutions as small as possible
-
AdventOfCode
Discontinued My adventofcode.com solutions [Moved to: https://github.com/d-hain/advent_of_code] (by d-hain)
-
Advent-of-Code
This repo contains my solutions to the advent of code event. Learn more about advent of code at https://adventofcode.com (by AhmarTheRed)
-
Advent-Of-Code-2022
My solutions for Advent Of Code 2022. Every day is written in another language, chosen randomly. (by Jomy10)
-
AdventOfCode-Day4-CampCleanup
.NET Core console app that solves the AdventOfCode Day 3 puzzle - Camp Cleanup
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
Part1
Updated version using sets instead of ranges
No, I edited my comment. I was wrong in thinking that there was a proper overload. The one I'm using is just from `extension Collection where Self.Element : Equatable` in the new _StringProcessing section for Regex. It gives the correct result, but it's not as fast as it could be. (https://stackoverflow.com/questions/64066681/check-if-one-range-is-within-another)
I like it! I also did it using excel, exploding the calculation into separate columns for the last few days.
Julia 177/64 which is my first ever points! So satisfying after being top 1000 on most days last year.
Python, 30/40. GitHub
Common Lisp version: github
Day 04 Code
Very basic java solution
Misread part two at first and counted the number that didn't overlap at all T_T. Despite getting timed out for that, still finished both parts in just over 5 minutes
https://github.com/Lukeisun/AdventOfCode2022 once again abusing sets
Just solved using beginning and end comparisons
Repo: Python and Clojure solutions
Scala (445 / 575)
Rust
Python first (messed up < and <= for P2 which cost me a minute), then Google Sheets for sheets and giggles (cursed by automatic date formatting)
Part 1 was where I had to deal with the annoying input parsing. I once again did interprocedural optimizations to use some unused scratch registers to hold the parsed numbers. Then, I compared the numbers - if (start1 <= start2 && end2 <= start1) || (start2 <= start1 && end1 <= end2), then one contained the other. This involved some fairly tangled conditionals.
Part 1, Part 2
Day 4
Rust
Pretty new to elixir myself, here is my solution using ranges: https://github.com/starcraft66/aoc-2022/tree/master/day4
Python 3 (rankings so bad I don't dare share)
rewrote it as a pair of linq oneliners (sort of, if you ignore parsing, like that's the one thing I wish C# could do better: read ints from files) https://github.com/Bpendragon/AdventOfCodeCSharp/blob/0800b/AdventOfCode/Solutions/Year2022/Day04-Solution.cs
Elixir
Link: https://github.com/udoprog/aoc2022
Repository on Github
Golang
My Scala solution.
Rust: Solution
rust:
Clojure
day4 in c#
Haskell. My first implementation was pretty straightforward, and then I got the idea to try and make everything point-free. The result is a lot of uncurrying functions, &&& calls, and code that will be unreadable to me in the morning, but at least it works!
I am a noob trying out AoC in Haskell this year. Mine is such a normie solution lmaoHaskell_Day04
Source Code | View Online
Rust
C++17
Kotlin. I failed to find predefined range "contains", so implemented it myself (kind of bruteforce way, which still works fast for given inputs).
C + SIMD
Source here
Code
My Haskell solution. The trickiest part about today was honestly parsing.
C++
https://github.com/aleksandar-kinanov/advent2022/blob/master/src/day4-task1.rs
My F# for the day. Surprised that no other F# submissions for the day haven't used Sets.
https://github.com/Marterich/AoC/blob/main/2022/day04/solve.py ```
Part1: https://github.com/asutoshvariar/Day4/blob/main/part1.py
Dyalog APL a b c dāāāāāĀØĀØ'\d+'āS'&'ĀØāāNGET'p4.txt'1 +/0ā„(a-c)Ćb-d ā part 1 +/0ā„(a-d)Ćb-c ā part 2
here is a link to the original code on Github
- C -
Maybe check out the canonical page instead: https://github.com/derailed-dash/Advent-of-Code
My solution in julia.
Rust: https://github.com/mvduijn/aoc2022/blob/main/day4/src/main.rs
rust - started with hashsets, refactored to bitmasking. still new to rust, so feedback is appreciated!
Rust
Kotlin: code
Here's mine in Rust, which I'm posting to ask for advice.
GitHub Repository
Solution can be found here, it's really messy and was kinda a pain, but still fun. Definitely had to think a bit differently to try and solve everything on a stack.
Great solve! Mine ended up being much more complicated since I tired to predict the part 2... Can recommend using a template so you dont have to repeat the whole cargo things, I use this one that builds templates, test and downloads input etc https://github.com/fspoettel/advent-of-code-rust
Rust Tried to predict what the part 2 would so overcomplicated it a bit but overall happy with today and solved it pretty quick. Github
Rust. I'm using this opportunity to relearn Rust after a few years of not using it, so any advice is welcome!
My solution as self-taught amateur. This year also with a repo on github: takhadnotor/AoC2022 Comments are welcome!
My solution in Python
Link to solutions.
Full Game Boy repo can be found here
Rust Quite an annoying input to parse :D Otherwise quite easy.
code
Code README.
My solution in Kotlin:
GitHub here: https://github.com/djm4/advent-of-code-2022/blob/main/2022/day/04/
Elixir ([GH])(https://github.com/esteeele/advent-of-code-2022/blob/main/elixir/advent_of_code/lib/day4Pairs.ex)
github Another trivial day.
Julia (repo)
If you're on Ventura and Swift 5.7, check out the new RegexBuilder and Regex literals. Here's how I used them on today's puzzle.
My Python solution is at https://github.com/kupuguy/aoc2022/blob/main/day04_camp_cleanup.ipynb
Solved in rust (repo). Pattern matching makes input parsing so nice.
rust once again, more of an "I'm having fun" answer than a "I'm doing the best code ever" answer.
C, it's quiet... too quiet. Waiting for the monster to jump out of the closet in a few days. [Github]
My Rust solution for day 4.
Typescript: Github: Complete code
My first part looks basically the same, but for the second part I was too lazy to think of the proper conditions so I used a hash to store seen sections
š another jq'er here (though I've been doing a few years entirely as jq) - my version for comparion: https://github.com/remy/advent-of-code-solved/blob/main/2022/jq/4-b.jq (I love that there's more ways to solve a problem)
Part 1: https://github.com/hdf1986/advent-of-code/blob/master/2022/4/1.rb
Day 4 Go solution
Solution
Day 4
If I'd allowed myself a tiny bit of preprocessing to turn the input into a 4-column CSV, this is almost a one-liner. (Source here: https://github.com/mrwilson/advent-of-code-2022/blob/main/04/04.sql)
Golang - https://github.com/sonu27/advent-of-code/blob/main/2022/04/main.go
Full code
Link to the Jupyter notebook for day 4 | Repo with all solutions
Link to code: https://github.com/aarneng/AdventOfCode2022/blob/main/day4/main.go
JAVA
shell/awk, one line per task: https://github.com/gizlu/AoC2022/tree/master/day4
In Joy). Download the interpreter here.
Straightforward Rustš¦ solution: github
Excel https://github.com/pengi/adventofcode/blob/master/2022/day04.xlsx
Sorry about that, and thanks for bringing my attention thereupon :/ I tried my best to fix it but in doubt here is the repo. Cheers!
C#, Linq fun | Full code
Python: Day 4
Haskell, runs in 15 ms. First day this year it made sense to make a monadic parser. I really like to use Text.ParserCombinators.ReadP!
TypeScript
Most of the time is spent parsing, but this problem lends itself nicely to a SIMD formulation, which using vectorclass doesn't even require detailed knowledge of the intrinsics. Hot runs take ~14 Āµs on a Core i9-12900K, including I/O. Full code is (here)[https://github.com/ahans/aoc2022/blob/main/cpp/day04.cc], the interesting part is this, where we process 32 elements at once:
Most of the time is spent parsing, but this problem lends itself nicely to a SIMD formulation, which using vectorclass doesn't even require detailed knowledge of the intrinsics. Hot runs take ~14 Āµs on a Core i9-12900K, including I/O. Full code is (here)[https://github.com/ahans/aoc2022/blob/main/cpp/day04.cc], the interesting part is this, where we process 32 elements at once:
tried to golf it a bit in python, think it looks pretty elegant
Full solution on my repo: https://github.com/deivi-drg/advent-of-code-2022/blob/main/Day4/day4.rs
My repo.
Good job, but ClosedRange.contains and .overlaps are in the standard library.
c#, repo here
python solution for day 4
Part2
more here: https://github.com/puppetlabs/community/discussions/28
Solution in C#
Gtihub here, Tweet here.
I updated the solution to use the overlap standard library function and to implement a "fullyContains" function (impl. here: github)
Rust - 36 LOC, excluding unit tests. The code seems quite neat to me.
Rust solution: https://github.com/michael-long88/advent-of-code-2022/blob/main/src/bin/04.rs
I really prefer your parsing to mine! I am learning Haskell and my few attempts at parsing are not very elegant.
Language: Python
Rust solution using nom and bit math: https://github.com/post-rex/aoc22/blob/main/days/day4/src/main.rs
Github
I do C too and aim for speed. It's not perfect but I got ~90Āµs buffering input file and ~23Āµs part1 and ~17Āµs part2. https://github.com/ssm008/aoc22/blob/main/src/day4.c
Here's a Python solution using some logic on interval end points (nothing new).
Pretty much the same as my OCaml solution, but a bit more compact. GitHub.
Link to Github
day4.c
I'm trying out Kotlin this year: https://github.com/Janiczek/advent-of-code/blob/master/src/Year2022/Day04.kt
C# Solution with unnecessary tuples adding complexity : here
Rust solution which implements contains/overlaps extensions for the `Range` type: https://github.com/noahtallen/advent-of-code/blob/trunk/src/y2022/day4.rs
I've been writing solutions in C (C89 specifically) for Nintendo 64. Here's my repo that builds an N64 ROM that solves AoC with my input (you can change the input either by editing the text files in asm/aoc/inputs/ and compiling or by opening up the ROM in a hex editor and pasting in your inputs at the correct addresses): https://github.com/nim-ka/aoc_n64
Common Lisp [solution](https://gitlab.com/-/snippets/2467254).
simple C solution, repo: advent-of-code-2022
GitHub
Clojure solution
Java - when i knew the bigger interval it was straightforward condition (first timer)
Here's a late post of my Rust solution. Nothing fancy.
Solution
Iām writing every day in a different language, day 4 was C3: https://github.com/Jomy10/Advent-Of-Code-2022/tree/master/day4
C# solution using Ranges, nothing fancy :) https://github.com/hariharansubramanian/AdventOfCode-Day4-CampCleanup/blob/master/Program.cs
Code | Blog Walkthrough
Chapel: Serial and Parallel Versions
Part 1
The code for part 1 is really basic (no pun intended), for part 2 it's almost the same with two extra conditions.
C
GitHub
Kotlin using ranges