☃️ Learning Rust with AoC 2021 🎄https://adventofcode.com/2021/

Overview

🎄 Andrei's 2021 Advent of Code 🎄

Learning Goals

  • Rust basics (vectors, arrays, math, etc.)
  • Rust basic CLI
  • Rust linear algebra and ndarrays (e.g., https://github.com/rust-ndarray/ndarray)
  • Rust <> C++ interop
  • Simple GitHub Actions set up (just linting initially)
  • Automatic linting and formatting (trunk?)
  • Finish all AoC problems (hints are OK from Dec 12 on, in the second half)
  • Basic unit testing

Bonus Goals

  • Call PyTorch from Rust

Running the Code

Assuming Cargo has been set up, to run a problem, simply use the following:

cargo run --release --bin <XX_problem>

The above should automatically build the code with its dependencies, and run the appropriate problem.

Learnings

  • Powerful type-safe, efficient, support for ndarrays, but still at times much more verbose than numpy. For instance, computing the median of an array is unnecessarily complicated.
  • Same for dealing with NaNs. Very rigorous but kind of annoying for simple data science or ML workloads.
  • Keep the naive implementation arround ALWAYS. Do not simply rewrite it - you can use it to debug your fast implementation. For instance, your fast implementation may work for the demo input in Part 2 but not for the puzzle input.
    • Often you can debug parts of the internal state from your fast implementation using your naive one!
    • Example: Problem 14 - Polymerization, where you used your naive implementation to fix the fast one by looking at the character histograms produced by the two to identify a counting bug in the letter counting function of the fast implementation.
You might also like...
My solutions to Advent of Code 2021 (mostly in rust)

Advent of Code 2021 Small code to solve problems at https://adventofcode.com/2021. Most of the code are written in Rust. How to run solutions For exam

🎄My Advent of Code 2021 solutions in the Rust programming language

Advent of Code 2021 in Rust My Advent of Code 2021 solutions in the Rust programming language. This repository holds a separate Rust project for each

My solutions for the Advent of Code 2021 in Scala, Python, Haskell and Rust.

Advent of Code 2021 These are my Advent of Code 2021 solutions written in Scala 3, Haskell, Python and Rust. Day Title L1 L2 L3 L4 01 Sonar Sweep Scal

Advent of Code 2021, in rust this year

Advent of Code 2021 🎄 Solutions for the 2021 edition of Advent of Code. This year, I try to do this in Rust 🦀 . I discover the language, so do not t

My solutions for Advent of Code 2021, in Rust

Advent of Code 2021 These are my solutions. I have decided to use Rust for now. I'm new to Rust, so it might be some of the worst Rust code you've see

My solution for the advent of code 2021, mainly written in Rust

Advent-of-Code-2021 My solution for the advent of code 2021, written in Rust Error Handle NOPE!!! unwrap() everything everywhere Use To run all of the

My solutions for the 2021 edition of the Advent of Code, using Rust and SOM (Simple Object Machine)

Advent of Code 2021 These are my solutions for the 2021 edition of the Advent of Code. The solutions are all implemented using both Rust and SOM (Simp

Solutions to Advent of Code 2021, coded in rust

Advent of Code 2021 (aoc-2021-rust) Solutions to Advent of Code 2021 (https://adventofcode.com/2021), coded as part of my efforts to learn Rust Run co

Repository with my Advent of Code 2021 puzzle solutions 🎄
Repository with my Advent of Code 2021 puzzle solutions 🎄

🎄 Advent of Code 2021 🎄 I decided to stick with Rust this year and try to improve a bit on it, I basically haven't used it since last year's AoC, so

Comments
  • Bump crossbeam-utils from 0.8.5 to 0.8.8 in /practice/general/rust

    Bump crossbeam-utils from 0.8.5 to 0.8.8 in /practice/general/rust

    Bumps crossbeam-utils from 0.8.5 to 0.8.8.

    Release notes

    Sourced from crossbeam-utils's releases.

    crossbeam-utils 0.8.8

    • Fix a bug when unstable loom support is enabled. (#787)

    crossbeam-utils 0.8.7

    • Add AtomicCell<{i*,u*}>::{fetch_max,fetch_min}. (#785)
    • Add AtomicCell<{i*,u*,bool}>::fetch_nand. (#785)
    • Fix unsoundness of AtomicCell<{i,u}64> arithmetics on 32-bit targets that support Atomic{I,U}64 (#781)

    crossbeam-utils 0.8.6

    • Re-add AtomicCell<{i,u}64>::{fetch_add,fetch_sub,fetch_and,fetch_or,fetch_xor} that were accidentally removed in 0.8.0 0.7.1 on targets that do not support Atomic{I,U}64. (#767)
    • Re-add AtomicCell<{i,u}128>::{fetch_add,fetch_sub,fetch_and,fetch_or,fetch_xor} that were accidentally removed in 0.8.0 0.7.1. (#767)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump nalgebra from 0.17.3 to 0.27.1

    Bump nalgebra from 0.17.3 to 0.27.1

    Bumps nalgebra from 0.17.3 to 0.27.1.

    Changelog

    Sourced from nalgebra's changelog.

    [0.27.1]

    Fixed

    • Fixed a bug in the conversion from glam::Vec2 or glam::DVec2 to Isometry2.

    [0.27.0]

    This removes the convert-glam and convert-glam-unchecked optional features. Instead, this adds the convert-glam013, convert-glam014, and convert-glam015 optional features for conversions targeting the versions 0.13, 0.14, and 0.15 of glam.

    Added

    • Add macros matrix!, dmatrix!, vector!, dvector!, point! for constructing matrices/vectors/points in a more convenient way. See #886 and #899.
    • Add CooMatrix::reserve to nalgebra-sparse.
    • Add basic support for serialization using rkyv. Can be enabled with the features rkyv-serialize or rkyv-serialize-no-std.

    Fixed

    • Fixed a potential unsoundness issue after deserializing an invalid DVector using serde.

    [0.26.2]

    Added

    • Conversion from an array [T; D] to an isometry Isometry<T, _, D> (as a translation).
    • Conversion from a static vector SVector<T; D> to an isometry Isometry<T, _, D> (as a translation).
    • Conversion from a point Point<T; D> to an isometry Isometry<T, _, D> (as a translation).
    • Conversion of an array [T; D] from/to a translation Translation<T, D>.
    • Conversion of a point Point<T, D> to a translation Translation<T, D>.
    • Conversion of the tuple of glam types (Vec3, Quat) from/to an Isometry2 or Isometry3.
    • Conversion of a glam type Vec2/3/4 from/to a Translation2/3/4.

    [0.26.1]

    Fix a regression introduced in 0.26.0 preventing DVector from being serialized with serde.

    [0.26.0]

    This release integrates min-const-generics to nalgebra. See our blog post for details about this release.

    Added

    • Add type aliases for unit vector, e.g., UnitVector3.
    • Add a pow and pow_mut function to square matrices.
    • Add Cholesky::determinant to compute the determinant of a matrix decomposed with Cholesky.
    • Add the serde-serialize-no-std feature to enable serialization of static matrices/vectors with serde, but without requiring std.

    Modified

    • The serde crate isn't enabled by default now. Enable the serde-serialize or the serde-serialize-no-std features instead.

    ... (truncated)

    Commits
    • d7288bf Release v0.27.1
    • 51312d1 Merge pull request #903 from dimforge/glam-conversion-bug
    • 7acd4ec Fix bug in the glam conversion Vec2 -> Isometry2
    • dfc8ad3 Release v0.27.0
    • de705a8 Merge pull request #900 from dimforge/glam-multiversion
    • 47a4f52 Replace unchecked glam conversion by TryFrom or checks
    • 4af979c Support multiple version of the optional glam conversion
    • ef3257b Merge pull request #899 from dimforge/point_macro
    • 0490a84 Fix typo
    • d6d2a3e Fix macros tests.
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump regex from 1.5.4 to 1.5.5

    Bump regex from 1.5.4 to 1.5.5

    Bumps regex from 1.5.4 to 1.5.5.

    Changelog

    Sourced from regex's changelog.

    1.5.5 (2022-03-08)

    This releases fixes a security bug in the regex compiler. This bug permits a vector for a denial-of-service attack in cases where the regex being compiled is untrusted. There are no known problems where the regex is itself trusted, including in cases of untrusted haystacks.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Owner
Andrei Bârsan
PhD student @ University of Toronto Research Scientist @ waabi.ai
Andrei Bârsan
Code and Development environment for adventofcode.com - 2021 edition

aoc-2021 Warning Spoiler Alert! If you want to solve the aoc problems on your own, do not read any further. This repository contains solutions for the

docToolchain 11 Oct 22, 2022
https://adventofcode.com/2022/

Advent of Code 2022 This repository contains my solutions for Advent of Code 2022. Goal is readable, simple and mostly clean. Each day is solved in it

Guillaume P. 3 Dec 15, 2022
🎄 My Advent of Code solutions in Rust. http://adventofcode.com/2022

Advent of Code 2022 in Rust My Advent of Code 2022 solutions in the Rust programming language. This repository holds a separate Rust project for each

Tim Visée 98 Jan 4, 2023
Repository for solving adventofcode.com puzzles

Advent Of Code ?? This is a repository for any Otovista that wants to participate in the advent of code christmas calendar challenges. Advent of Code

Otovo 4 Dec 20, 2022
Code and Development environment for adventofcode.com - 2022 edition

aoc-2022 Warning Spoiler Alert! If you want to solve the aoc problems on your own, do not read any further. This repository contains solutions for the

docToolchain 8 Dec 26, 2022
Learning Rust through Advent of Code 2021 - probably not very clean!

AoC 2021 ======== I'm using AoC2021 as an excuse to learn Rust (and maybe some other languages). Please do *not* use this repository as a good source

Andrew Zhu 0 Dec 8, 2021
⭐ Advent of Code 2021: Мade with Rust

Advent of Code 2021: Мade with Rust When I was solving puzzles, my goal was to practice writing idiomatic Rust. My solutions do not claim to be the fa

Sergey Grishakov 13 Dec 2, 2021
Advent of Code 2021 puzzles & solutions in Rust

Advent of Code 2021 These are puzzles for the Advent of Code 2021 challenge, written and solved in the Rust programming language. The puzzle for each

Chevy Ray Johnston 8 Dec 19, 2021
Advent of Code 2021 (Rust)

aoc-2021 Advent of Code 2021 with Rust. To build and run the project This project uses cargo-aoc. More detailed instructions can be found at that proj

Belén Albeza 13 Dec 23, 2021
Advent of Code 2021, also an attempt to practice a bit of Rust.

Advent of Code 2021 Advent of Code 2021 (my first one!), also an attempt to practice a bit of Rust. Running (Assuming that the respective inputs are i

Edoardo Debenedetti 1 Dec 3, 2021