Our great sponsors
-
AdventOfCode2021
Solutions to all 25 AoC 2021 problems in Rust :crab: Less than 100 lines per day and under 1 second total execution time! :christmas_tree:
-
adventofcode
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 and 2023 in Scala (by sim642)
-
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.
-
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.
From u/SuperSmurfen (full solution): use num::signum to easily get the delta for iteration, e.g. let dx = (x2 - x1).signum().
Advent of Code is a daily set of programming puzzles. After each puzzle is released some solvers post their solutions in the r/adventofcode subreddit. At the start of the month the puzzles are somewhat simple, but even so the solutions tend to look very different, and I learn some cool rust expressions nearly every time. I thought I'd list out some nuggets here for folks who aren't following the event directly. To set expectations: these won't be solutions to the daily problem, just very tiny bits of rust code that used a library or technique that I thought was interesting.
From u/ritobanrc (full solution): use nalgebra::Matrix5 and you can use column_iter() and row_iterator() on your board.
From u/rossmacarthur (full solution): use vectrix::Matrix for similar row/col access convenience.
I'm using the sscanf crate - makes parsing these kinds of input trivial. Here's my Day 5 code: Day 5 Rust.