Our great sponsors
-
-
TS - Took some time to think, but simple optimized solution without any set or dict.
-
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.
-
Swift. containsOnlyUniqueElements is not in the standard library; it relies on this Set initializer.
-
github
-
AdventOfCode
My Advent of Code solutions. I also upload videos of my solves: https://www.youtube.com/channel/UCuWLIm0l4sDpEe28t41WITA
Python3 19/24. Video. Code. Quick one today!
-
Python 3 243/195
-
https://github.com/betaveros/advent-of-code-2022/blob/main/p6.noul or, in brief:
-
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.
-
Impressive how fast everyone was with this one today
-
-
Repo link
-
Kotlin - Live Stream on YouTube - GitHub
-
-
-
-
-
Part 1
-
Github
-
Github
-
day6.rb on GitHub
-
-
-
2022 Day 06 in Golang
-
Language: C
-
Part 1 was solved using brute force - for each starting point, I checked if the next four bytes were distinct. Part 1 ran in under 1 millisecond and was 10544 bytes long.
-
Elixir GitHub
-
GitHub link for more readable version
-
Here's the solution in PHP: https://github.com/drupol/aoc2022/blob/main/aoc2022-6-part1.php
-
-
Yes. Barely an inconvenience. https://github.com/UnicycleBloke/aoc2022/blob/main/day06/day06.cpp. I realised after that std::set has a range constructor that should make life even simpler. Next time...
-
-
-
adventofcode
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 and 2023 in Scala (by sim642)
My Scala solution.
-
My solution is here
-
AdventOfCode
Hacky solutions for [Advent of Code](https://adventofcode.com), working on past problems (by AllanTaylor314)
Python (and a slightly tidier version), then Google Sheets
-
AdventOfCode2022
My C# solutions to Advent of Code 22. Trying to one-liner as many as possible but I've already failed at Day 5. (by joel-heath)
GitHub
-
-
Refactored solution: https://github.com/nithinbekal/advent-of-code/blob/c3788728010d8bcacd1d622996ef56226ba0370a/lib/06.rb
-
-
-
github
-
On GitHub
-
Here's a very efficient sliding window approach in Rust:
-
Github
-
Python
-
Julia using the same solution for both problem.
-
Wow, almost identical to mine: https://github.com/MichalMarsalek/Advent-of-code/blob/master/2022/Nim/day6.nim
-
A less clever Rust solution which maintains a vector of "last few chars". At each iteration, that vector is cast to a set to check for uniqueness. Technically still O(N):
-
Elixir, 5251/15635 🤦♂️, code, Reflections, with two bonus implementations
-
Immutable sets I used in previous days were too slow for part 2 so I've spent most of my time on this puzzle coding a more efficient MultiSet data structure. Overkill? Probably, yes. Fun? Also yes.
-
AOCx2022
This repository contains my solutions for the Advent of Code 2022 event. Learn more about the event here - https://adventofcode.com/2022/about
Part 1 and Part2
-
COBOL - Source Despite not having sets, it's still a somewhat elegant solution. My love for this language is growing.
-
-
-
-
-
Solution
-
Typescript.
-
-
COBOL - Part 1 & Part 2
-
Go https://github.com/ashishjh-bst/aoc2022/blob/master/day6/solution.go
-
F# - yet another day made trivial by Seq and Set modules.
-
Nice solution. I'm aiming for the shortest run time (here's mine, runs in 40µs), your algorithm has a lower big O, but I think using a hashset is detrimental to performance here. Have you tried using the fnv crate ? It provides hashset and hashmap implementation with a faster hashing algorithm.
-
-
Clojure: https://github.com/motform/advent-of-clojure/blob/master/src/advent_of_clojure/2022/06.clj
-
-
-
-
-
Rust (repo). Didn't use a set even though it might have been more idiomatic. I think this was the simplest one so far this year for me.
-
Python3, 33/190 (don't ask me about the part 2 fail). Code on GitHub
-
-
Source
-
Today's seems suspiciously quite "easy", I'm feeling tomo's gonna be harsh. Javascript solution
-
Kotlin
-
-
C, the index handling in findMarker feels a little gross but if that's the worst code I write during AOC2022 I'll be pretty happy. [Github]
-
Instead of using Itertools::all_unique I wrote my own and gained a huge performance improvement. Part 2 runs in ~25 us on my machine. I would make it even faster since the input doesn't use the whole byte range, but that's ok. The whole code
-
-
Erlang - gotta love the ten-line solutions
-
Rust: code
-
-
V
-
Python3 using queue
-
-
I love how simple this was in Rust <3 here's my code :3
-
Haskell (likely very suboptimal, but does the job):
-
advent_of_code_2022
Discontinued My solutions to Advent of Code 2022 https://adventofcode.com/2022 [Moved to: https://github.com/PetchyAL/AoC2022] (by PetchyAL)
Python, nice and easy one today
-
Github
-
aoc2022
Trying to solve Advent of Code 2022 in 25 different languages (1 day = 1 language) (by GoldsteinE)
-
Rust
-
-
-
Source
-
-
I coded it up in C++ here. Hot runs take ~5 µs on a Core i9-12900K (both parts, including I/O).
-
-
-
-
Tried my best, i think the solution is quite nice :)
-
I have completed years 2015 and 2020 in bash. Gave up halfway through last year, might do that one day. https://github.com/einarjon/adventofcode.sh
-
JavaScript / NodeJS / TypeScript solution
-
rust with windows and basic loops
-
Go solutions here
-
TypeScript
-
-
-
-
Code: https://github.com/MrRobb/advent-of-code-2022/blob/main/src/day06.rs
-
-
C# Repository (3 Solutions)
-
Part 2 is just a longer regexp, see my solution on GitHub
-
Day 6 in Go: https://github.com/nicl/advent-of-code-2022/blob/main/day6/main.go
-
-
Without sets in C, I resorted to comparing the characters in every window, but skipping ahead where possible. So, if the last 2 chars of the window are the same, you can immediately slide the window along by its size-1, or else if there is a duplicate in the last 3 chars, slide by size-2, etc. etc. I also made sure to start the search for the 14-char header after the one of length 4. Run time is 1 ms on a Raspberry Pi 4. Code at https://github.com/ednl/aoc2022/blob/main/06.c or the relevant bits:
-
The rest of the code is here
-
Code in rust for both parts:
-
This would've been much much nicer if count(distinct char) was supported in the window function, oh well. Source here
-
I did Bash for day 2 because it was easier to setup as a language beginning with B over B or Bracmat or Befunge or something :) https://github.com/Starwort/advent-of-golf-2022/blob/master/bash/day2.sh
-
You can use indexOfFirst: https://github.com/PaulWoitaschek/AdventOfCode/blob/main/src/main/kotlin/de/woitaschek/aoc/year2022/Day6.kt
-
END { print(i); } ``` github
-
-
Common Lisp
-
So using my PHP Advent of Code Framework I started last year to take care of some boiler plate and reading of files, etc. The overall approach I'm taking is to make it handle the raw input from the AoC puzzles and to be maintainable/easy to follow and read.
-
RegExr
RegExr is a HTML/JS based tool for creating, testing, and learning about Regular Expressions.
Regular expression (using https://regexr.com )
-
C#
-
advent-of-code-2022
Solutions to Advent of Code 2022 puzzles https://adventofcode.com/2022 (by Lysander6)
Rust🦀 solution with no HashMap/Set or any bit counting ¯\(ツ)/¯ github (raw)
-
Livebook Version
-
-
-
Annotated code for both parts
-
-
Atari FastBasic
-
Code on Github
-
This on Github My solutions on Github
-
Haskell, 15 ms. Probably my shortest AoC solution ever.
-
Python 3: Code
-
My original solution checked every character against every other character, which performed perfectly fine even for 14 chars, but it felt wrong.
-
Python
-
I ended up seeing if I could save time by using an array and tracking the set in a mutable way. It worked but much less concise: https://github.com/Japanuspus/adventofcode/blob/master/2022/day06/src/main.rs
-
My solution in readable bash script. I solved part 1 in a simpler way, but after reading part 2, I created this universal solution for both parts. It's slow but it works. All my solutions are on my Github.
-
-
Python
-
-
-
Solution here
-
My solution grows a sliding window over the input while scanning it. At any point, it ensures this window to be the largest possible with no repeating symbols. The underlying algorithm is:
-
Python 3 using more_itertools.sliding_window and more_itertools.all_unique. No set building, no nested for loops. https://github.com/colematt/advent-code/blob/main/2022/p6.py the two key functions are below:
-
Day 6 ``` data = open("data.txt").read()
-
-
-
Swift. containsOnlyUniqueElements is not in the standard library; it relies on this Set initializer.
-
-
GitHub Day6
-
{ Python solution working on indices }
-
github
-
I used Rust Part 1 Part 2 These work almost the same as the two parts are very similar. I go through every character in the given string and store the last 4/14 chars in an array. If the array contains only unique chars then I break and "return" the index of the current position.
-
-
-
Kotlin: Code on my Gitlab
-
-
advent-of-code-2022
Joel Eisner's completed TypeScript code challenges for "Advent of Code" 2022 (by joeleisner)
-
GitHub: https://github.com/PanJohnny/AoC2022/blob/master/src/main/java/com/panjohnny/advent/days/Day6.java
-
part 1 and part 2 also added some cool benchmarking using cryterion to track the execution times.
-
AdventOfCode-Day6-TuningTrouble
C# .NET Core console app that solves the puzzles for AdventOfCode Day 6 - TuningTrouble
C# Solution using LINQ - repo ``` Console.WriteLine("Scanning signal...");
-
Github
-
Day 6 github
-
C .... This is calm, too calm .... You know what's coming now, prepare for the storm !
-
Very happy with my solution which boils down to:
-
GitHub
-
advent-2022
Discontinued Advent of Code 2022 in Rust [Moved to: https://github.com/whiteand/advent-of-code] (by whiteand)
Full code is here: https://github.com/whiteand/advent-2022/blob/main/src/y22d6.rs
-
Managed to make an extension function finding all duplicates in an array:
-
I just turned the string into a vector of chars with `.chars().collect()` https://github.com/DAlperin/aoc-2022/blob/main/day-6/src/main.rs
-
Still learning F#, quite proud of today's solution: https://github.com/Nicolas-Ding/adventofcode2022/blob/main/Day06-FS/Program.fs
-
Python solution to part 1 and 2
-
I wrote up a tutorial for it here: https://github.com/maxrothman/advent-of-code-2022/blob/main/apl-aoc/day6/day6.ipynb. If you're interested in learning more about these funny squiggles, I also solved some of the other days in there as well. Check it out!
-
Python - 9 LOC. Quite a pleasing solution...
-
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)
-
#!/usr/bin/env swift sh import Algorithms // https://github.com/apple/swift-algorithms struct StandardInput: Sequence, IteratorProtocol { func next() -> String? { return readLine() } } func markerEnd(for signal: String, markerLength: Int) -> Int { return Array(signal.windows(ofCount: markerLength)) .firstIndex { Set($0).count == markerLength }! + markerLength } let signals = StandardInput().compactMap { $0 } let part1 = signals.map { markerEnd(for: $0, markerLength: 4)}.reduce(0, +) let part2 = signals.map { markerEnd(for: $0, markerLength: 14)}.reduce(0, +) print("part 1 : \(part1)") print("part 2 : \(part2)")
-
Typescript there : https://github.com/Gabattal/Advent-Of-Code-2022/blob/main/day06/index.ts
-
Rust
-
Used a 32bit Integer as a set, otherwise it would have probably been way more expensive. Glad that I've done this before on Day 6 in 2020. As a result these were the fastest solves so far.
-
original BS file
-
Concise solution in Rust using some bit tricks.
-
Kotlin: Part 1 and 2
-
Full thing on github; here's the interesting part:
-
-
AdventofCode_Day6_Part1
Part 1 of Day 6 of Advent of Code Challenge - https://adventofcode.com/2022/day/6
Part 1
-
-
Tried a new thing, first uploaded data to disk (errrr I mean floppy) using a stupid read first write after ingester (that doesn't work with more than 6kB data).
-
Python 3.11 solution quite simple, basic list manipulation
-
-
Kotlin solution using sliding window ⏱ O(N), 💾 O(M), where N - number of chars in input, M - window size
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives