Advent of Code is an annual coding competition/event with daily challenges. Even complete beginners can keep up for the first few days as the difficulty slowly ramps up.
Join the rDrama leaderboard and see how you compare to your fellow dramanauts with the following code:
632268-20c7d1d5
Enter it here https://adventofcode.com/2022/leaderboard/private
Jump in the discussion.
No email address required.
But I only know python
Jump in the discussion.
No email address required.
there's no better time than now to pick up rust in solidarity with trans folks![:#parrottrans: :#parrottrans:](/e/parrottrans.webp)
Jump in the discussion.
No email address required.
I fricking hate that meme, not because I like
, but because it's impossible to discuss the language on /g/
Jump in the discussion.
No email address required.
day of the antioxidation when
Jump in the discussion.
No email address required.
True chads go with Zig![:marseygamer: :marseygamer:](/e/marseygamer.webp)
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Python's actually not a bad choice, honestly. Pretty fast to write. I did AoC in C for the lulz a couple years back and got on the global leaderboard a few days, but most normal people do more concise languages like Python or esoteric codegolfing langs.
Jump in the discussion.
No email address required.
what is it with those? like half
the time
these are like... either brainfrick tier languages or "implement this very specific thing in 1 character"
Jump in the discussion.
No email address required.
The latter of those are basically optimized specifically for AoC, haha.
Jump in the discussion.
No email address required.
trueee tbh
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Jump in the discussion.
No email address required.
More options
Context
I solved the first two puzzles and I still don't know how the stars work.. Is that a puzzle too?
Jump in the discussion.
No email address required.
if you complete the first task on a day you get a silver star for it
if you complete both tasks on a day you get a gold star instead
Jump in the discussion.
No email address required.
I got 2 gold stars but leader board says 76?
Jump in the discussion.
No email address required.
if you are the first person to get a certain star, you get points equal to the total players in the leaderboard. if you are the second person to get it, you get 1 less point, etc
Jump in the discussion.
No email address required.
ahh got it now, so thats the leader board score. confused me for a while
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
I prefer SQL tbh
Jump in the discussion.
No email address required.
More options
Context
More options
Context
That's what most (including me) use![:marseyblush: :marseyblush:](/e/marseyblush.webp)
Jump in the discussion.
No email address required.
Oh I thought it was Java script only for some reason![:marseybrainlet: :marseybrainlet:](/e/marseybrainlet.webp)
Jump in the discussion.
No email address required.
More options
Context
More options
Context
python is a fantastic choice because youre never judged on the speed of execution. tangentially (and still in benefit of python), standardizing how you choose to do data ingest/sanitization/output formatting is braindead easy in python - being able to plop the problem data into a "data.txt" and just "data = open('data.txt', 'r').readlines()" is a lot better than most other languages. python has fantastic useability for string manipulation and typecasting, and its incredibly fast to write and iterate on (you write pseudocode and it Just Werks™). i prefer some of javascripts array methods, but then the file handling and io boilerplate is lacking (also node_modules lmao). just give it a try.
Jump in the discussion.
No email address required.
also in js you have shit
like Array.sort() which defaults sorts like... this apparently
Jump in the discussion.
No email address required.
Lol shit marsifies into indiacel![:marseyraging: :marseyraging:](/e/marseyraging.webp)
Jump in the discussion.
No email address required.
More options
Context
javascript also can't add numbers with decimal points without an add-on library (or a bunch of unnecessary inline arithmetic like multiplying and then dividing all your numbers by 1000 or some stupid bullshit). Like every other r-slurred thing about the language, they can't ever fix it because all javascript functionality has to be backwards compatible to 1995 forever.
Jump in the discussion.
No email address required.
This is r-slurred. Js uses double as its base numeric type, like 99.99% of other languages. Integer arithmetic is supported up to ~2^53, because doubles. The strategy used in many other languages to support precise decimal arithmetic is to have a separate decimal type, which js could also do without any backwards compat issues.
not even necessary tbh. If your numbers map to physical quantities, simply change the unit of the physical quantity from U to mU or uU or nU. Walla, you have extreme precision. Since your prior choice of units was already arbitrary, this one isn't any worse.
Jump in the discussion.
No email address required.
I just use an add-on library (decimal.js) if I'm doing calculations on the frontend. I've read the articles on why decimal math doesn't work in js and I can't be bothered to write a bunch of dumb shit in my code like the geniuses on stack overflow who will do this kind of crap every time they want to write a math statement:
Sure though, adjusting your units to only be whole numbers is also fine.
Despite there being a solid reason, as you stated, for math not working out of the box in js, having not provided any solution built into the language for the last 25+ years is kind of fricking stupid, if you ask me.
Edit: even this stack overflow crap I've pasted in here doesn't actually work, btw. It "works" if you know the precision of your inputs is no more than 3 decimal places, and if you're certain the "extra" result of the innermost calculation is truly insignificant (since floor is just erasing information). What if you actually need to round some numbers in here? There are so many edge case failures with this kind of shitty kludge.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
True, but in javascript, you don't need to load the file at all, you can just reference the input as document.body.innerText. You can code your solution in the browser developer cowtools without even leaving the site. It's the true lazy man's approach.
Jump in the discussion.
No email address required.
ngmi
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
Jump in the discussion.
No email address required.
More options
Context
More options
Context