Our great sponsors
- InfluxDB - Collect and Analyze Billions of Data Points in Real Time
- Onboard AI - Learn any GitHub repo in 59 seconds
- SaaSHub - Software Alternatives and Reviews
-
Is your code on github? Mine is at https://github.com/Praful/advent_of_code/
-
that is very similar to what i do https://github.com/Fadi88/AoC/blob/master/2021/day02/code.py
-
InfluxDB
Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.
-
My working [Scratch](https://scratch.mit.edu/) solution ;) :
-
-
Here's the entire file. If the printGood and printDebug looks weird, it's because I have a utils class that uses colorama to make my terminal output colourful. Another thing I added to make it nice but doesn't really do anything.
-
Rust version with a single function. I wonder if at this line I can parse the integer value directly. I didn't find a way to do it yet.
-
Yes. Also you don't have to do it twice like he did. YOu could it once, assign it to a variable and then use the index. See: https://github.com/djotaku/adventofcode/blob/779ff300bf793b6ef016059148c511e18fa7444a/2021/Day_02/Python/solution.py line 37
-
Onboard AI
Learn any GitHub repo in 59 seconds. Onboard AI learns any GitHub repo in minutes and lets you chat with it to locate functionality, understand different parts, and generate new code. Use it for free at www.getonboard.dev.
-
Should be
-
My solution for day 2: https://github.com/plebcity/adventOfCode/blob/advent-2021/src/main/kotlin/adventofcode/y2021/day2.kts
-
AdventOfCode
My Advent of Code solutions. I also upload videos of my solves: https://www.youtube.com/channel/UCuWLIm0l4sDpEe28t41WITA
Python 8/6th :) Video of me solving: https://youtu.be/e3_iiz_6bFw
-
Go, 382 / 230
-
Python: https://github.com/kratsg/advent-of-code/blob/master/2021/day02.py
-
-
Rust, nothing special here, not particularly fast (I initially thought aim should be a vector and lost some time because of it). The error handling could be a bit cleaner, I might fiddle with that for a bit so I don't have to put .unwraps and .expect and panic! everywhere.
-
Sad - this one didn't have much room for cleverness. simple loop and if/elif/else checks to figure out what to do. Solution
-
Nothing fancy again, just tried to do it as quickly as possible
-
Pascal 4710/5060
-
Updated (calculates both answers in a single pass): https://github.com/Bpendragon/AdventOfCodeCSharp/blob/5fc105352b8f8c9e0ff19554ead0921514bb632c/AdventOfCode/Solutions/Year2021/Day02-Solution.cs
-
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:
Link to full solution
-
C# https://github.com/Perska/AoC2021/blob/master/AoC2021/Days/Day02.cs I saw that my solution was very close to the 32-bit limit and got worried it overflowed. Turns out it didn't.
-
My C Solution
-
That's such a cool parser! I did something similar but it's a bit to clunky to be useful, and not as versatile. I just might switch over to using yours.
-
Done as a C# interactive notebook, rest of my solutions in here.
-
-
Link to code
-
GitHub: aoc2021_day2
-
Advent-of-Code
Me solving the wonderful problems here https://adventofcode.com/2021/events (by losecontrol4)
my solutions on github
-
-
-
-
Kotlin, the mapping step is unnecessary maybe, but otherwise straightforward. https://github.com/valiant-code/AdventOfCode/blob/master/2021/src/main/kotlin/Day2.kt
-
-
-
Python: https://github.com/a-mroz/adventofcode2021/blob/master/day2.py
-
-
day02 of doing only one-liners and I already failed for the second part, it would have been a huge mess. The first part is pretty messy as well so if anyone can improve on it I would be very grateful ! https://github.com/masmeert/advent-of-code/blob/master/2021/day02/main.py
-
adventofcode
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 and 2023 in Scala (by sim642)
My Scala solution.
-
Node solution part 1
-
-
-
All Solutions so far
-
Kotlin - Day 2
-
-
GitHub
-
+1, Quite similar to my solution
-
My Python solution: https://github.com/tomribbens/AoC/tree/main/2021/day02
-
My humble C++ solution.
-
go https://github.com/Jtramey/AOC-2021/blob/master/calendar/day-02/day02.go
-
Last year I built a Vector type that has instances for typical typeclasses. That came in really handy today (although I needed a few minutes to remind my self what I did last year).
-
-
I always overengineer my solutions somehow :D https://github.com/Rykee/AdventOfCode-2021/blob/master/src/main/java/rhykee/solver/task02/Task02Solver.java
-
-
C my beloved
-
And a link to a PDF with benchmarks for three different methods: https://github.com/guslipkin/AdventOfCode2021/blob/main/02/AoC2021-Day02-SpeedEdition.pdf
-
Nice. I figured we'll be parsing lines a lot so have written a function to parse the input into a vector of tuples: https://github.com/UnicycleBloke/aoc2021/blob/master/day02/day02.cpp.
-
Github AOC/2021/Day2
-
My solution in Rust:
-
Rust
-
Very similar to mine, clearly the platonic Clojure solution to the problem.
-
-
Similarly in Rust, parsing to
-
-
Nim
Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
It seems that Arch repos contain nim 1.4.8 which doesn't have scanTuple in std/strscans as far as I can see.
-
Rust
-
Python3 Part 1 & Part 2 using some Regex.
-
F# TDD https://github.com/bainewedlock/aoc-2021-fsharp/blob/master/aoc-2021-02/Solution.fs
-
I publishing my solutions on github as well: https://github.com/duarteocarmo/advent2021
-
My own toy language XIL implement an instruction module for this input part 1:
-
-
-
-
-
-
Solution: https://github.com/Skarlso/aoc2021/tree/main/day02 Blog post: https://skarlso.github.io/2021/12/02/aoc-day2/
-
-
Python (unlike many of the solutions posted thus far, this does not require 3.10)
-
-
Simple Python-based solution yet again.
-
-
-
Hi :) unfortunately I might not have the answers to your questions, but I'm also new to Zig and if you want to compare I'm putting my solutions here: https://github.com/vesche/aoc2021
-
-
Another way in PHP https://github.com/HolyHugo/AdventCodeCalendar/blob/main/day2.php
-
trying to do as many oneliners this year as i can, this is what i came up with for Day 2 :D https://github.com/ckainz11/AdventOfCode2021/blob/main/src/main/kotlin/day2/Day2.kt Part 1 is not really smooth, didnt know how to reduce a map in a good way XD
-
In Raku using a grammar
-
Here's my solution: I love unnecessary long code in Ruby :D
-
not the most inspired solution
-
EDIT: full code (with loading script)
-
here is the link to github Now let's look at the snippet (Command is an enum containing well, directions/commands)
-
F# solution for day 2: day02.fsx
-
-
Part 1 Part 2
-
day2
-
A simple python solution using pandas!
-
My Clojure solution, including a short explanation.
-
Just took a look at your solution on GitHub. Nice observation of just using the command's first character in the switch-case. I also have not thought about just using the stdin with a good old scanf. First AoC for me and already learning a lot of things! :)
-
-
My solution in Python, using list reduction and declarative specification of moves.
-
[Part 1](https://github.com/katzuv/advent-of-code/blob/solve/2021-02/2021/d02/p1.py), [Part 2](https://github.com/katzuv/advent-of-code/blob/solve/2021-02/2021/d02/p2.py).
-
programming-challanges
My attempts at solving various programming challenges. Leetcode, codewars, adventofcode, etc [Moved to: https://github.com/x-zvf/programming-challenges]
I am using AOC to learn clojure: code
-
In case you want to take a look, I managed to have a solution with fold https://github.com/rivten/aoc-2021/blob/master/02/rivten/Main.hs
-
Javascript link
-
Full writeup on my blog, and code on Gitlab.
-
Elixir
-
🎄 Python Day 2 🎄
-
I haven't had any problems with company/sly on emacs-plus v28 on an m1 chip FWIW: https://github.com/d12frosted/homebrew-emacs-plus
-
Common lisp: https://github.com/atgreen/advent-of-code-2021/blob/main/02.lisp
-
github link
-
Day 2 part a
-
day02.ts (github) Parse input with regex, map commands to { horizontal, depth } pairs, sum them accordingly
-
Elm https://gitlab.com/sakisan/adventofcode/-/blob/2021/Elm/Day02.elm
-
My answer in c# with dotnet 6 and records :D. https://github.com/sander1095/advent-of-code-2021
-
Solution for PHP 8.1
-
Here's my solution in Clojure. Still feeling like a beginner though, need to refactor solution using reduce.
-
-
Python So i use the regrex package to get the instructions in a clear format. Once this done it's pretty straighforward. Gitlab link.
-
PHP
-
GitHub
-
-
advent_of_code
This repository contains solutions to Advent of Code challenges (by joakim-strandberg)
Ada95, part one (full code at https://github.com/joakim-strandberg/advent_of_code/):
-
Here are my solutions in rust task 1 and task 2. I didn't really strive for completion speed but second task was done in like 5 seconds due to code from first task being structured in reusable way. Also learning vim with coc and rust analyzer and GOD DAMN this is cool! (got some dotfiles if you want) <3 Spent most time fighting with router plugin not to change working directory, for some reason it tripped poor ls.
-
Here's day 02 - python
-
-
github link ```
-
Python 3.10 with pattern matching
-
Scala using foldLeft
-
GitHub
-
My code is at https://github.com/pille1842/adventofcode-2021, although I won’t be pushing the solution for day 2 until tomorrow.
-
Trying to solve every day in haskell, but I'm somewhat of an amateur when it comes to that language. Still, if you want to look at my solution (and possibly drop some hints / give feedback which I would appreciate a lot ), you can find it on github.
-
part 1
-
-
GitHub repo
-
Same as yesterday, my answers using Go are on Github with a TDD-ish approach. I'm not being super strict with TDD here.
-
My C++ solution: https://github.com/pawelzydziak/advent-of-code-2021/tree/main/Day_2 :)
-
Probably overkill, because I parsed the instructions into instances of my point class. I tend to default to that for coordinates nowadays (as opposed to just using complex numbers) because it generically extends to arbitrary numbers of dimensions. Just in case.
-
Github
-
-
src
-
Go
-
-
Parts 1 and 2
-
Part 1
-
Part 2
-
Part 1
-
Here's my solutions in F# (and Jupyter Notebook).
-
a02.cc
-
GitHub
-
adventofcode
Advent of Code (http://adventofcode.com) solutions written in Python 3 (by viliampucik)
Python 3 - Minimal readable solution for both parts [GitHub] import fileinput aim, h, d = 0, 0, 0 for l in fileinput.input(): cmd, x = l.strip().split(" ") x = int(x) if cmd == "down": aim += x elif cmd == "up": aim -= x else: h += x; d += aim * x # cmd == "forward" print(h * aim) print(h * d)
-
Hosted on GitLab
-
-
C# github repo
-
-
AdventOfCode2021
My solutions to each day of Advent of Code 2021. We shall see how far I get! (by daxschoof)
Solution
-
challange one
-
Still a promising language though: https://github.com/spencerwi/AdventOfCode2021/blob/ballerina/day2/main.bal
-
Again this year I am posting my reflections for solving all of these in Haskell https://github.com/mstksg/advent-of-code-2021/blob/master/reflections.md :)
-
More linq oriented than my (old style) https://github.com/pgiacome/AdventOfCode2021/blob/10cd7e41b3ae6a65e81c48418550d50f7a2e5666/AdventOfCode2021/Program.cs
-
-
-
Kotlin, solution for part 1 and 2 — not super concise but a few cool concepts if you're learning the language.
-
Common Lisp unsophisticated newbie solution I'm going to keep my solutions here: https://github.com/tallbikeguy/advent-of-code/tree/main/2021 ` (defpackage :advent21-02 (:use :cl))
-
My solution this year was almost exactly like the one __abigail__ posted. I based it on last year's code for day 12. There are 50 days worth of bash solutions in that repo if you're interested. Some contain Voodoo, but it's mostly readable - I hope...
-
-
Day 2 solution: https://github.com/gauauu/adventOfCode/blob/master/2021/aoc-src/day2.s It uses a bunch of macros from the following, to help manage all the 16- and 32- bit math that's required. (as the 6502 natively can only do 8-bit adds and subtracts, and no mult/divides) https://github.com/gauauu/adventOfCode/blob/master/2021/framework/src/global.inc
-
Part 2 in Julia. Probably could have used multiple dispatch to do both parts in one file, but was lazy.
-
advent-of-code-2021
The 2021 adventofcode.com solutions I've written for the YouTube videos (https://www.youtube.com/channel/UCsATdyu8fmu7B_-22AfySxg) (by tpatel)
The code is available on github too: https://github.com/tpatel/advent-of-code-2021/blob/main/day02.js
-
Day 2, Kotlin still going strong. Today I had the opportunity to explore functional collections operations (fold and reduce) :D
-
-
-
Day 2 on Github
-
-
Trying my best in Unity :) (C#) https://youtu.be/a5VvmLE618I Will also add my code here: https://github.com/dspieard/AdventOfCode2021
-
Python 3 day 2 solution damn it took me more to figure how to organise the data than to write propper to solve the problem. And yet I ended up with List and tuples. IO tried the complex numbers way ( i don't know why they tempt me so much :P ) hope to help someone out.
-
Day2 solution in TypeScript: https://github.com/joao-conde/advents-of-code/blob/master/2021/src/day02.ts
-
Day2 solution in R https://github.com/JohannesFriedrich/AdventOfCode2021/blob/master/Day2/Day2.Rmd
-
Done in python https://github.com/michaelmoon57/AoC/blob/main/day_two.py
-
F# and TypeScript Solution
-
Both parts. Only started learning it a few days ago, so the code is probably not the best.
-
-
My solution in PHP, JS, and Clojure
-
[GitHub link](https://github.com/Gadiguibou/advent-of-code-2021/tree/main/day_02_scratch)
-
GitHub Link
-
Rust (both parts). Learning the language, happy for any feedback on how to be more idiomatic.
-
its like 600 lines, I recommend writing your own so that the functions make sense for you. Here is the "library" from someone that gets on the global leaderboard (mcpower): https://github.com/mcpower/adventofcode/blob/master/2020/01/utils.py
-
Hi everyone, here are my javascript solutions for both puzzles(day 2). https://github.com/AlanGCruz/advent-of-code
-
Day 2 Solution in R / Rlang. https://github.com/trfore/advent_of_code_2021/blob/main/day2/r/2021_aoc_day2.R
-
Nearly forgot to post it here: My solution in Janet https://github.com/tionis/adventofcode/blob/main/2021/2/main.janet
-
aoc-2021
Advent of Code 2021 https://adventofcode.com/2021 [Moved to: https://github.com/bozdoz/advent-of-code-2021] (by bozdoz)
Go! https://github.com/bozdoz/aoc-2021/blob/main/02/two.go
-
Python: https://github.com/plan-x64/advent-of-code-2021/blob/main/advent/day2.py
-
See https://github.com/bellaz89/lolAOC/tree/main/d2
-
Day 2 in Go: GitHub
-
Javascript solution
-
My Python solution :)
-
advent-of-code-2021
Solutions for Advent of Code 2021, written in JavaScript using node.js (by johnbeech)
Node JS https://github.com/johnbeech/advent-of-code-2021/blob/main/solutions/day2/solution.js
-
advent-of-code-2021
Trying to solve https://adventofcode.com/ [Moved to: https://github.com/ThePituLegend/advent-of-code] (by ThePituLegend)
-
Java 17 (with Lombok, Spring, and StreamEx) Main Code: Day2.java Movement Commands: Command.java Input Parser: CommandInputParser.java
-
-
My solution in Python.
-
Yeah it's [here](https://github.com/fnands/advent_of_code_2021)
-
- [Github](https://github.com/mdwhatcott/advent-of-code/blob/main/clj/src/aoc/y2021/d02.clj)
-
Scryer Prolog Github link
-
That person seems pretty advanced. He's using all sorts of symbols I've not come across!
-
Here, this will save you time Script
-
Julia
-
(define (solve-part2 input) (let next ([depth 0] [distance 0] [aim 0] [input input]) (if (null? input) (* distance depth) (let ([instr (caar input)] [amount (string->number (cadar input))]) (cond [(equal? "forward" instr) (next (+ depth (* aim amount)) (+ distance amount) aim (cdr input))] [(equal? "down" instr) (next depth distance (+ aim amount) (cdr input))] [(equal? "up" instr) (next depth distance (- aim amount) (cdr input))]))))) ``` Full code is here
-
-
Part 1 and part 2 were both very straightforward - I did cheat a bit by recognizing that there's only ever three possible movements, and that the value associated with each movement was always a single decimal digit.
-
Python day 2 solution (GitHub)
-
Python day 2
-
GitHub/PathCalculation.java
-
-
-
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives