[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
▼ Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: 1640648755256_.png (600 KB, 975x847)
600 KB PNG
>Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.
https://adventofcode.com/

/g/ leaderboard join code:
224303-2c132471
anonymous-only leaderboard:
383378-dd1e2041

lets hope eric does not phone it in this year

Previous thread: >>110472092
>>
File: wastl1.png (10 KB, 600x600)
10 KB PNG
>>110483600
>lets hope eric does not phone it in this year
too late
>>
File: solve.png (104 KB, 2177x686)
104 KB PNG
>>
File: 1783446343141233.jpg (1.15 MB, 896x1200)
1.15 MB JPG
day 1 sloppa
>>
File: swastika.png (41 KB, 1292x400)
41 KB PNG
>>
>>110483600
Digits and we actually get the full 12 puzzles this time.
>>
>>110483644
>12 puzzles
>full
we're fallen so far...
>>
>>110483611
interesting use of chunk_by. I usually use https://docs.rs/itertools/0.15.0/itertools/trait.Itertools.html#method.coalesce
for something similar, but chunk_by seems to work the way I'd expect for this problem so I can drop it. thanks for the idiomatic solution, bro.
>>
>>110483658
I guess dedup_with_count as well.
>>
File: 1710285063280216.png (108 KB, 900x900)
108 KB PNG
>>110483630
why?
>>
File: perl.png (50 KB, 1045x189)
50 KB PNG
>>110483611
>>
>>110483725
oops, meant to quote OP
>>
>>110483630
#12 and #13 on the meme ranking should be checked
>>
Going from reviewing vibecoded pull requests all year at work to working on an AoC problem in a language I like because it's declarative and visually pleasing feels like the cheeseburger scene in The Menu.
>>
>>110483757
>reviewing vibecoded pull requests
jesus christ. is this what modern coders do all day? I guess I'm glad I work in a space where we can't trust Anthropic to steal our IP and all the other AIs are either Chinese (muh chinese boogeyman bad even if hosted locally) or shit.
>>
>>110483611
I don't get why you wouldn't use map_filter instead of map? You could get rid of that nasty unwrap.
>>
>>110483734
you are trying too hard to make your shit list a thing, no one cares
>>
>>110483810
>just ignore the error
that's highly unidiomatic
>>
>>110483832
How about you unidiomatically go kill yourself?
>>
>>110483853
>unidiomatically go kill yourself
Not possible, that's idiomatic in rust
>>
>>110483771
I don't think it's as prevalent as AI companies would like to make it out to be. That being said it's still super common, I bet 60%+ of companies are all slopping stuff out.
>>
File: 1721617960455094.png (465 KB, 585x651)
465 KB PNG
bigboy #1
url: https://files.catbox.moe/mxtzl9.7z
lines: 17044061
silver: 57068430797700
gold: 941654718771813
>>
If you can't even do day one without AI it's unironically over for you
>>
Obviously this problem is trivial to do in linear time but it might be interesting to do it in better than linear space. Maybe you'd have to use a frequency estimating algorithm to do it? That can get you part 1 at least, but part 2 might be weird unless you make assumptions about the input
>>
File: carbon.png (277 KB, 1360x1702)
277 KB PNG
>>110483872
about 400ms
>>
>>110483906
invalid
>>
File: 1662940045851106.jpg (237 KB, 853x1000)
237 KB JPG
>>110483917
I have two gold stars that say otherwise
>>
File: 1444438671848.png (17 KB, 601x695)
17 KB PNG
>try to sign into AOC with the usual Twitter id
>"We've temporarily limited your login, Please try again later."
>>
>>110483896
you could sort the original array then use lower_bound three times?
>>
>>110484000
Sorting the original array would only get you the 3 smallest/largest IDs, not the 3 most frequent/least frequent IDs. If you had data like below then the most frequent and least frequent IDs wouldn't be at the edges
1
1
1

2

3
3
3
3
3

4
4
4
>>
>>110484065
fuck i alwasy embarass myself when i try to program in my head
>>
// c++26

import std;

struct Result {
std::uint32_t count;
std::uint32_t value;
};

int main() {
std::ifstream reader("days/1/input.txt");

std::vector counts(1000, std::uint32_t{});
std::vector results(3, Result{});

std::uint32_t input;

while (reader >> input) {
auto& count = counts[input];
count++;

for (int position = 0; position < 3; position++) {
if (count > results[position].count || !results[position].value) {
if (input != results[position].value) {
std::shift_right(results.begin() + position, results.end(), 1);
}

results[position] = Result{.count = count, .value = input};
break;
}
}
}

std::cout << results[0].value * results[1].value * results[2].value << std::endl;
return 0;
}
>>
>>110484138
why do people only do half the problem? is this some autism about eric "locking" the gold problem away behind muh heckin login?

also why would you initialize a vector like that instead of putting the type in angle brackets?
>>
File: beepoob.png (36 KB, 640x701)
36 KB PNG
beef wins again, too easy
>>
>>110484302
>silver
there are no silver stars though
>>
File: 26_D01_C#.png (69 KB, 957x437)
69 KB PNG
Wow, almost forgot about Advent this year. Anyway, the needful has been done.
>>
>>110483600
How many days this year?
>>
File: aoc.png (164 KB, 1330x1477)
164 KB PNG
>import solution

from collections import Counter
from functools import reduce
from operator import mul

with open('p01.txt') as fh:
nums = Counter(int(l) for l in fh.readlines())

mc = [n for n, _ in nums.most_common()]
print(reduce(mul, mc[:3]))
print(reduce(mul, mc[-3:]))


why does he bother with these day 1 shits. if there's only 12 days fuckin lets go
>>
File: faggot.png (2 KB, 207x22)
2 KB PNG
>>110484316
oh yeah?
>>
>>110484335
because he phones this shit in to get the paypiggy money

>>110484339
I see gold, blue and dark grey.
>>
>>110484349
yeah well in advent of code, any color that isn't gold, is silver. it's just the lore, deal with it
>>
>>110484349
they've been lacking soul for a while now, i think he's just TiReD
i also think the plebbitor learn2code brigade probably griefed him into losing hope
>>
>sudden influx of retarded posts
>look at time.gov
>americans are waking up
>>
>>110484372
where are you at bro
>>
File: day1.png (32 KB, 816x526)
32 KB PNG
>>110483600
>>
>>110484406
>Iterator::by_ref
?
use slice::sort_by_key, Iterator::take, and Iterator::product
>>
>>110484418
no?
>>
File: larry-wall.jpg (1.44 MB, 1619x2024)
1.44 MB JPG
>>110483725
You can just use product from List::Util
In Raku (Perl 6):
given words.Bag.sort(-*.value)».key {
say "silver: {[*] .head(3)}";
say "gold: {[*] .tail(3)}";
}

Golfed:
say [Z×] [Z] words.Bag.sort(*.value)».key[*-3..*,^3];
>>
>>110484418
wdym? using by_ref(), I turn the Strings into &str so i can call parse on them to turn them into numbers
>>
File: rape_me.png (97 KB, 1910x2008)
97 KB PNG
https://www.youtube.com/watch?v=4TsqlT0rfJI
>>
File: 1787250138248293.png (61 KB, 774x776)
61 KB PNG
Reposting my shiz cause we aint got enough solutions in here
>>
>>110484406
>and_modify or_default
does this actually work? don't you need or_insert(1)?
>>
>>110484715
oh... I mean I guess it does because the count doesn't matter outside that it has to be incremented for sorting.
>>
>>110484302
The only sane and readable code ITT.
>>
File: day1.png (22 KB, 814x471)
22 KB PNG
>>110484418
you were right. sorry, you sounded like a retard so i assumed you were one
>>
    input
.split_ascii_whitespace()
.flat_map(|line| line.parse().ok())
.collect()


y'all nigga over-complicate the parsing part for this problem.
>>
>>110484461
>say [Z×] [Z] words.Bag.sort(*.value)».key[*-3..*,^3];
I kneel for larry-CHAD
>>
:)
>>
>>110484596
No, Iterator::by_ref just gives you a borrow of the iterator. You use this if you don't want to consume the iterator. It's the same as writing (&mut iter).
You can call parse directly on a String because of deref coercion.
>>
>>110484750
>just parse invalid input bro
>just ignore errors bro
dumb retard
>>
>>110484707
your mind is a cobweb. even more concerning is that isn't even all of it monkaS
>>
>>110484831
this isn't random user input, the puzzle input is always kosher
>>
>>110484831
>literally a list of numbers.
doesn't really matter how you parse it.
Eric has been going easy on people with his babby parser questions.
>>
>>110484831
If it makes you feel better. Use map(...) and .expect() the number to parse. the split whitespace functions don't emit empty leading or trailing shit anyway.
>>
File: 1785467751586690.webm (3.16 MB, 1066x598)
3.16 MB
3.16 MB WEBM
>>110484874
watchu mean, vaguepost king
>>
>>110484831
>t. last year got filtered before the day eric poisoned the input to drain the bank accounts of every cnile with MAX_INPUT
>>
(ns advent-of-code.year-2026.day-1
(:require [clojure.string :as string]
[clojure.edn :as edn]))

(def filename "inputs/year_2026/day_1.txt")

(def input
(->> filename
(slurp)
(string/split-lines)
(map edn/read-string)))

(defn compare-by-count [x y]
(> (count (val x)) (count (val y))))

(defn sort-by-count [input]
(->> input
(group-by identity)
(sort compare-by-count)))

(defn get-result-1 [input]
(->> input
(sort-by-count)
(map first)
(take 3)
(apply *)))

(defn get-result-2 [input]
(->> input
(sort-by-count)
(reverse)
(map first)
(take 3)
(apply *)))

(def result-1 (get-result-1 input))
(def result-2 (get-result-2 input))
>>
Who else is taking the morning pill this year?
>>
#include <stdio.h>
#include <stdlib.h>

#define INPUT_SIZE 1000

int main ()
{
char id[3];
int id_arr[INPUT_SIZE];
int i = 0;
for (i=0;i<INPUT_SIZE;i++) {id_arr[i] = 0;}
int c = 0;

/*recording occurences*/
while ((c = getchar()) != EOF) {
if (c == '\n') {
i = 0;
id_arr[atoi(id)]++;
continue;
}
id[i] = c;
i++;
}

/*finding three most common IDs*/
int most_common[3];
int j;
int least;
for (i=0;i<3;i++) {most_common[i] = 0;}

for (i = 0; i < INPUT_SIZE; i++) {
/*select least common of current three most common ids*/
least = 0;
for (j = 0; j < 3; j++) {
if (id_arr[most_common[j]] < id_arr[most_common[least]])
least = j;
}
/*replace least common with current id if is more common*/
if (id_arr[i] > id_arr[most_common[least]]) {
most_common[least] = i;
}

}

int prod = 1;
for (i=0; i<3; i++) {
printf("%d, %d times\n", most_common[i], id_arr[most_common[i]]);
prod *= most_common[i];
}
printf("prod: %d\n", prod);

return 0;
}


Anyone have some advice on improving readability? I'm pretty happy with the method I chose for day 1 part 1, but I think its probably nightmare for others to read, particularly the section for choosing least common of three most common ids array.
>>
>>110485004
>he thinks i have anything in my bank account or a job for that matter
>>
>>110485279
you may use whitespaces, it is okay to do so
>>
>>110485359
Yeah my tabs weren't included for some reason when pasting to browser
>>
>>110485279
>#define INPUT_SIZE 1000
you didn't solve it
>>
you hardlimit the allocation MAX_INPUT
I allocate regardless of input size
we are not the same
>>
File: Day01.png (37 KB, 598x427)
37 KB PNG
I got filtered half way through Everybody Codes through having no free time left to do this shit, I expect I'll be out partway through AoC for the same reason. At least AoC only has the two parts.
>>
>>110483630
>P = NP + AI
They say all human life has value, but some say this.
>>
>>110485467
Explain how I didn't solve it
>>
>>110485605
ignore the tranny
this is the closest thing he has to human interaction
>>
>>110485631
You are right. How could I fall for such low quality wound bait
>>
>>110485605
you solved the problem, but the criticism is that this wouldn't work on any arbitrary problem input because you end up either having to hardcode the max allowable value or max sequence length when you do it this way. retarded criticism tbqh, i'd much rather have explicit limits and guards set by me instead of leaving it up to the runtime environment or machine, and all these problems take a fixed size static input so there's no point in being a faggot about it
>>
>>110485675
Yes I perfectly understand the criticism but fail to see where it negates my solution. If the elves needed it to work on an arbitrary list size I would've figured it out. Otherwise, why waste time? Seems outside of the scope of the problem.
>>
>>110484302
this looks like C# but.. not. wtf is ".. scope .()"
>>
File: 1775475023842.jpg (9 KB, 304x166)
9 KB JPG
in java this is just

public class Main {
static void main() {
try (Stream<String> lines = Files.lines(Path.of("bigboy.txt"))) {
List<Long> numbers = new ArrayList<>(lines
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::valueOf)
.toList());
numbers.sort(Long::compareTo);

long product1 = numbers.stream()
.collect(Collectors.groupingBy(n -> n, Collectors.counting()))
.entrySet().stream()
.sorted(Map.Entry.<Long, Long>comparingByValue().reversed())
.limit(3)
.mapToLong(Map.Entry::getKey)
.reduce(1L, (a, b) -> a * b);
IO.println(product1);

long product2 = numbers.stream()
.collect(Collectors.groupingBy(n -> n, Collectors.counting()))
.entrySet().stream()
.sorted(Map.Entry.comparingByValue())
.limit(3)
.mapToLong(Map.Entry::getKey)
.reduce(1L, (a, b) -> a * b);
IO.println(product2);

} catch (IOException e) {
e.printStackTrace();
}
}
}

Part1 : 57068430797700
Part2 : 941654718771813
________________________________________________________
Executed in 21.84 secs fish external
usr time 22.10 secs 950.00 micros 22.10 secs
sys time 1.29 secs 7.00 micros 1.29 secs
>>
>>110485696
>I ... fail to see where it negates my solution
Your little "solution" only happens to work because you cheated and assumed the contents of the input file. It's a hack that gets you the answer without actually solving the problem.
>>
>>110485763
Not falling for it sorry
>>
File: ss.png (156 KB, 1280x1413)
156 KB PNG
AI reviewed my code and informed me that it would be better if I made ArrayList of (id, count) tuple and sort by count. As it stands sorting needs to hash keys on every comparison.
>>
File: carbon(10).png (589 KB, 1952x2568)
589 KB PNG
hello sirs
>>110485811
nice ziggin'
>>
>>110483771
claude writes most my code now at work, i actually go over everything it writes and whip it until it fixes all the dogshit though
but i doubt many other people put that much effort, its soulsucking
>>
>>110484335
>
most_common()

didnt know this was a thing, i just did sorted with lambda
>>
File: carbon.png (288 KB, 1362x2004)
288 KB PNG
>>110485205
I should get into ranges sometime
>>
Maybe this year I'll make it all the way with Clojure.
>>
>>110483872
1.5s when I change >>110485863 to call `map.sortUnstable` instead.
>>
thread full of halfwits, lmao
>sorting
why are you sorting? stupid
>>
>>110485977
rude
>>
File: aoc-2026-01-el.png (277 KB, 1582x1340)
277 KB PNG
>>110485939
Same with Emacs Lisp. It's kind of fun when there's no difference between a text buffer and data or a program.
>>
>>110485977
>find the most/least common
>but dont sort by how often they appear
brainlet
>>
>>110485995
frequency map, kid
>>
>>110485995
x * n = 3 * 1000 = 𝟑, 𝟎𝟎𝟎
n log2 n = 1000 × 9.966 ≈ 𝟗, 𝟗𝟔𝟔

So 3n is smaller than n log2 n by over 3 × (since 3 < 9.966).
>>
>>110485994
I've found emacs to be more trouble than it is worth.
>>
>>110485977
because it is fast enough
>>
>>110485977
I bet whatever solution you use that you think is super clever and not a sort is still actually a sort
>>
>>110486178
and yes I consider quickselect a sorting algorithm
>>
>>110486178
Not him, but the faster way to avoid sorting is to compute the frequency table and use a min/max heap or quickselect (note not quicksort). Since obviously you don't care about the sorted order for most of the list.
>>
>>110486121
I got into Emacs when I was programming Scheme at my university. We had the Wizard Book as course book for the lecture Introduction into Programming at the time. I started Emacs' built-in tutorial, and I'll admit those keyboard "shortcuts" are not to everybody's taste, I get that. I then found out that Emacs is written in Lisp (similar to Scheme), started writing my own functions, macros and F-key definitions. If you want to process data that's in text form and you know Emacs, that can be a powerful tool. Sort of what Perl or (G)AWK used to be for. (Pattern and expression matching and generating a report.) Plus if you do it in Emacs, you can watch what Emacs is doing, you can evaluate partially and that makes development and debugging easy.
>>
File: 1774441133514684.jpg (82 KB, 686x621)
82 KB JPG
Just 1 shot this problem with AI lol, way too easy this year
>>
>>110486219
If you used AI for this, you need to be shot.
>>
is aoc unironically dead? used to be way more posters and they used to have many threads leading up to the actual day doing previous years problems.
>>
jfc how retarded are you guys to not use a min heap

also hard coding top 3 elements

this is why you guys are unemployed, NEET harder
>>
>>110485939
Btw. can you recommend a good introductory book for learning Clojure?
>>
>>110486264
the whole board and chan kind of is

>>110486266
I will implement one if a problem needs one but this rehashed day 1 that we have had 4-5 times already is not it
>>
>>110486266
Despite AI, it's a timed programming competition at heart. If only sort was included in your language library, using sort was the correct option. If you wish to refine the solution and solve big boys fast, only then does such autism matter.

I get the impression that you learned about min heaps 5 minutes ago.
>>
>>110486198
>quickselect
in spirit maybe but not really, there's a reorder of a fixed number of candidates taking place.
>>
>>110486063
and then after you have the frequencies?
>>
File: arst.png (90 KB, 1396x387)
90 KB PNG
>>110486277
>the whole board and chan kind of is
what triggered that?
>>
>>110484302
I KNEEL
>>
>>110484770
as a oneliner

main = readFile "input1.txt" >>= print . map (product . take 3) . sequenceA [reverse, id] . map fst . sortOn snd . toList . foldl (\m k -> insertWith (+) k 1 m) empty . map read . words
>>
>>110486266
>min heap
>for three elements
lol
>>
i will work on the problem now because i totally forgot that this was a thing. wish me luck
>>
i'm already missing drawanon
>>
>>110486350
discords
shills and bots spamming the site
as a result captchas being more tedious than it is worth
people getting older and busy with their lives
few new users

probably a bunch of stuff like that
>>
>>110486350
it's an unc site now
>>
File: space.jpg (670 KB, 672x6287)
670 KB JPG
>>110486402
>>
>>110486400
I only hang around /g/ these days, to stay semi informed on wtf is going on with AI, everything else just makes me feel my IQ drop in real time
>>
>>110486417
That's not what's gonna happen tho, I hate every single one of you mongoloids
>>
>>110486214
I've been using it on and off for a few years, trying to get into it because it sounds cool. Doom emacs was more useable to me out of the box, but still. It just never sticks.

The whole, self-modifying program, code-is-data, customizable software just sounds cool. But then when I use it, I realize I don't have any use for those features.
>>
>>110486264
Yes... I mean it's day fucking one and maybe 30 or 40 people posted solutions in two threads?
>>
File: 19f.jpg (51 KB, 680x657)
51 KB JPG
>>110486456
>>
>>110486471
previous years the leaderboard filled up instantly and we needed secondaries
>>
>>110486341
do you know how to find the largest integer in an array, without sorting it? if the current largest item gets promoted, then what it was previously, would currently be the next largest and so on. very simple stuff, anon. just a linear scan and some checks, no quickselect pivot crap, no min heap sillyness.
>>
File: d1.png (248 KB, 1510x1056)
248 KB PNG
>>
>>110486495
sure but why bother doing that when i can just sort it?
>>
>>110486264
>>110486277
its both this site dying slowly and also aoc dying quickly
eric has been phoning it in for ages, the switch to 12 puzzles killed off a ton of interest too, and removal of leaderboard a bit too
>>
>>110486499
because it's faster and you're posting on /g/, not reddit and it is obviously also the intended solution.
>>
>>110486522
not faster to write, and thats what really matters for a speed programming competition. so sorting is actually the intended solution
>>
>>110486495
that actually sounds more tedious than using a priority queue or quickselect.
Just scan the frequency map 3 times.
>>
>>110486530
the intended speed solution is to call select-top-n and select-bottom-n from your pre-written utils library
>>
File: aocProblem01.png (101 KB, 1296x473)
101 KB PNG
>>
>>110486495
can't tell if bait or actual retardation
I'm just getting angry reading these, maybe I shouldn't even have come here this year, AI is better at this anyway
>>
Did the same thing as other shell anon, (sort | uniq | sort | {head;tail} | math) except used an awk one liner for the multiplication instead of piping sed to bc. Same diff.

Then got guilty about relying on a second sort so also wrote one that raked the frequency map like >>110486495 did. Not a bad first day.
>>
>>110486573
christmas is ruined
>>
I wanna use different languages for each day this year as a break from c. Any sugestions?
>>
>>110486543
Nta but implementation here. >>110484302
Not so bad, sorting would be shorter but it seems to be the most common solution, at least in here. Curiously, sorting is also the very first solution ChatGPT provides unless you poke at how stupid it is, surely just a coincidence.
>>
I'd like to announce me being unfiltered by last year's day 10.
Did it before christmas so it counts.
https://files.catbox.moe/u996c1.png

Looking back I really really should have used rational arithmetic. Maybe this year.
>>
>>110482014
>how can i learn linq and do stuff like this? i have no idea what aggregate is or where you get those names from
well the broader view is that the concepts being applied to the data are going to be common across many languages and it's just a matter of practiced familiarity or plain looking it up to see how they're represented in linq. For instance, 'Aggregate' is what many other languages call 'Reduce' and that's basically just something you have to know (or scroll through the intellisense list or have AI simply write it for you these days I guess). 'Select' is often 'Map', C# and SQL's 'Where' is often 'Filter' etc.
LINQ specifically takes a lot of its method names from SQL more so than most other languages that have similar querying capabilities so familiarity with SQL also helps.
>>
>>110486611
>Not so bad
Holy shit, that's way worse than pretty much any alternative
>>
>>110483896
you could do it in infinity time ezpz
>>
>>110486264
Obviously yeah, I was even surprised it still is a thing, now that nobody gives a shit about programming anymore. There's no point or enjoyment left in any of this shit, especially on this website.
I used to participate enthusiastically but now I think the time would be better spent going outside and doing something less pointless.
>>
>>110486611
Because conceptual simplicity is the most important thing in competition code, everyone knows their language's sort function off the top of their head, and an extra log(n) never matters for AoC
>>
>>110486614
gj
>>
>>110486614
kek I forgot what day 10 was but then remembered when I saw how tall the code was
>>
>>110486608
D
>>
>>110486636
Let's keep feelings out of this.
>>
>>110486614
Oh, the import z3 day
>>
>>110486608
>sql
>prolog
>php
>gdscript
>simulink or equivalents (idk how you would do this)
>tex macros
>python list comprehensions
>autohotkey
>>
>>110486642
Of course it doesn't matter. Bigboy brooters are charming in their own way, too.
>>
>>110486608
F#, Zig, Beef, Erlang, Intcode
>>
>>110486264
yes. I used to love AoC because solving coding puzzles made me feel like my nerds skills were actually good for something. These days, why bother?
>>
>>110485710
kekd
>>
>>110486749
>why bother
because it's fun?
>>
>>110486608
R
PowerShell
Kotlin
J
Fortran
Clojure
>>
>>110486749
skill issue cope is what that is. if you were good at what you were doing, an artisan, you'd just do it for yourself, but you're a larper.
>>
>>110486264
kind of too low executive function to even do... anything
im going to bed
>>
>>110486749
>why bother?

I'm struggling with this as well. All of this is starting to feel like a "secret art". By which I mean, it's an art form that extremely few people can or will ever appreciate.
I don't mean just writing code, but the entire system around it too. Which editor you use, custom tooling, linux distro tinkered to perfection. It's beautiful, but nobody but you and a handful of strangers on the internet will ever care.
>>
>>110486840
>not enough people care about what i do in my moms basement
microdick energy
>>
File: 1677810126677334.jpg (125 KB, 826x871)
125 KB JPG
>tfw i clicked the google image search button on my image post and it automatically OCRd it and started giving valid improvements
i haven't done this professionally in like 8 years but i'm still not happy about the absolute state of things
>>
>>110486840
I think I might care again in a decade or so with some distance, when all this is over (assuming we didn't all starve to death by then).
But for now I just can't find the will to care about anything related to computers or technology any more. It all just sucks and I want nothing to do with it, if I really think about it.
>>
>>110486809
I honestly envy retards like you that lack the self-reflection required to understand their own motivations at a deeper than surface level. must be nice, thinking you can do things like coding for their own sake
>>
Enjoy it while you can.
Sadly this year I won't be able to participate nor even follow.
I haven't the time.
>>
>>110486920
Why so busy?
>>
>>110483872
good enough for haskell, took only 7G ram lol

time ./day1
[57068430797700,941654718771813]

real 0m56.727s
user 0m53.733s
sys 0m2.827s
>>
>>110486936
Taking care of my grandfather with dementia. Fun. Fun. Fun.
>>
>>110486940
>7G ram
wtf did you do anon
>>
>>110486953
don't worry thats what haskell does
my solution is >>110486372
>>
>>110486953
Writing haskell that doesn't use shitloads of memory is a level of cocl and ball torture few delve into. It's kind of a meme language that ends up looking like imperative slop mixed with neue sounding programming concepts to make it fast.
It's a good place to get inspiration from, but don't expect quality.
>>
>>110486898
if it's difficult for you to grok programming for fun you're an NPC, not much more to it.
>>
>>110486973
>>110486977
Interesting, I didn't know. Any idea _why_ that is? What's haskell using the memory for? I assume it's runtime and not for the compile?
>>
>>110483872
>>110484672
>1:57068430797700
>2:941654718771813
>Elapsed: 10.026592 seconds
>>
>>110484302
been meaning to give beeflang a go now since the ide works on linux so i might try this year
>>
>>110487036
buy an ad
>>
>>110487021
what are these numbers? and why do you guys use Gold, Silver in your code?
Day 2 isn't out for another 7 hours
>>
>>110484302
>make new language
>java syntax
Into the trash it goes.
>>
>>110487073
those are the numbers for the big text file given in >>110483872
each problem is broken into 2 problems each day, silver just means the first part and gold means the 2nd part, a silver star used to be awarded for completing the first half and a gold star was awarded for completing the second half. there are no longer any silver or gold stars, just "stars" and 2 stars are available each day
>>
>>110487073
in the leaderboards (only private now) you get a silver star for part 1, then it upgrades to a gold star when you complete part 2.
>>
>>110487128
The Stats page also uses silver to denote people who have only completed part 1.
>>
Learning Rust
>>
File: 1774021405537231.png (159 KB, 1688x908)
159 KB PNG
solving this in clojure feels like import solution
>>
>>110487119
>used to be awarded
https://adventofcode.com/2026/stats
>Gold indicates users that have completed both parts of a puzzle, while silver indicates users that have completed only the first half.
like that on the leaderboard as well
>>110487296
if you'd import APL you could do it in a few primitives and a nice fork.
>>
>>110486686
>>110486703
>>110486777
>>110486726
Thank you anons
>>
>>110487355
oh ok thanks
>>
>>110483600
>first task of the first problem is very easy
>get filtered, because I don’t know go and use this to get more familiar with the language
Maybe tomorrow, but it truly is annoying to not know basic functionality.
>>
File: file.png (50 KB, 862x586)
50 KB PNG
>>110483872
bigint for a big boy. it takes twice as long as Long and isn't necessary for this data set but hey
actually the larger input also made me realize i should have enumerated the ordered list before. too used to avoiding that at all costs working with dbs/iqueryable
>>
>>110486977
>level of cocl and ball torture few delve into
I remember a long time ago looking into the Haskell solutions for the "Programming Language shootout" and it was indeed the most disgusting form. Haskellers would tout C-like performance with beautiful code, but it was always a lie. Gave up the language right away.
>>
Eric is a bit sadistic, so I think he'll drop a filter problem today. Lure in the rubes, and then just drop the hammer down.
>>
>>110487641
only ATS didn't lie about what the PL normally looked like, but the writer's personal style was and is so repulsive that it was anyway perceived as violating the spirit of the shootout
>>
>55k silver stars
huh it's not dead somehow
>2.5k silver stars
these guys were clearly so disgusted by part 2 that it's dead for them
>>
>>110487673
people said this literally every day last year up until like day 10 where a bunch of people did actually unironically get filtered by solving a system of equations
>>
>>110487688
You're assuming that 2.5k are stationary users... that's largely participants starting the challenge late and progressing to part 2. It's like observing a busy bridge full of cars.
>>
>~50k players this year

now that the fad is over, can eric start designing puzzles for people who actually like them rather than people who have just learned what a computer is 14 minutes ago?
>>
>>110487766
He put his heart and soul into IntCode, and reddit gave him nothing but grief. Endless whining about it being too hard, or that it couldn't be solved out of sequence.
>>
>>110487766
eric doesnt care anymore, he'll put the minimum amount of effort in until the sponsorship money dries up then abandon it
>>
>>110483707
just look at the busty elf and be happy anon
>>
File: 4stats-dev-all.png (31 KB, 841x401)
31 KB PNG
>>110486350
The 4stats dev brought back /all/ on dev.4stats.io recently. Looks really dire. /b/ alone had about this much traffic at one time.
>>
>>110483872
from collections import Counter
from math import prod
from sys import argv

with open(argv[1], "r") as file:
inp = Counter([int(x) for x in file]).most_common()

pt1 = prod([key for key, _ in inp[:3]])
pt2 = prod([key for key, _ in inp[-3:]])
print(f"Part 1: {pt1}\nPart 2: {pt2}")


Benchmark 1: python src/day01.py inp/bb01.txt
Time (mean ± σ): 1.778 s ± 0.027 s [User: 1.656 s, System: 0.118 s]
Range (min … max): 1.737 s … 1.819 s 10 runs
>>
>>110486350
>>110487870
Considering traffic is decreasing in an era where it is easier than ever to set up a bot and there is plenty of incentives to do it everywhere that takes user input, the actual human population here must be painfully low
>>
File: 1731252418254341.png (214 KB, 468x396)
214 KB PNG
ok time for another nap
I will hopefully make it to showtime
>>
>>110483630
based, i love this trash
>>
File: day1.png (449 KB, 1426x2568)
449 KB PNG
Odin is so comfy.
bigboy: 5.8s
>>
>>110485811
>>110485811
first parts of our solutions are pretty similar

const std = @import("std");

const Entry = struct { key: u32, count: u32 };

fn byCountDesc(_: void, a: Entry, b: Entry) std.math.Order {
return std.math.order(a.count, b.count);
}

fn byCountAsc(_: void, a: Entry, b: Entry) std.math.Order {
return std.math.order(b.count, a.count);
}

pub fn solve(gpa: std.mem.Allocator, input: []const u8, comptime desc: bool) !u64 {
var count_map: std.AutoHashMapUnmanaged(u32, u32) = .empty;
defer count_map.deinit(gpa);

var it = std.mem.tokenizeAny(u8, input, ", \r\n\t");
while (it.next()) |tok| {
const key = try std.fmt.parseInt(u32, tok, 10);

// Only uses one lookup, rather than separate get/set ops
const gop = try count_map.getOrPut(gpa, key);
if (!gop.found_existing) gop.value_ptr.* = 0;
gop.value_ptr.* += 1;
}

const compareFn = if (desc) byCountDesc else byCountAsc;
var pq: std.PriorityQueue(Entry, void, compareFn) = .empty;
defer pq.deinit(gpa);

var map_it = count_map.iterator();
while (map_it.next()) |e| {
try pq.push(gpa, .{ .key = e.key_ptr.*, .count = e.value_ptr.* });
if (pq.count() > 3) _ = pq.pop();
}

var prod: u64 = 1;
for (pq.items) |i| {
prod *= i.key;
}

return prod;
}

pub fn part1(gpa: std.mem.Allocator, input: []const u8) !u64 {
return solve(gpa, input, true);
}

pub fn part2(gpa: std.mem.Allocator, input: []const u8) !u64 {
return solve(gpa, input, false);
}
>>
package main

import "core:fmt"
import "core:os"
import "core:strconv"
import "core:strings"

read_file :: proc(filepath: string) -> [dynamic]string {
data, err := os.read_entire_file_from_path(filepath, context.allocator)
if err != nil {
// could not read file
return nil
}

it := string(data)
lines := [dynamic]string{}
for line in strings.split_lines_iterator(&it) {
// process line
append(&lines, line)
}
return lines
}


main :: proc() {
fmt.println("Hello AoC!")

m := make(map[string]int)
defer delete(m)

lines := read_file("input.txt")
defer delete(lines)

if lines == nil {
fmt.println("Could not read file. Wrong filepath?")
return
}

for line in lines {
if line in m {
m[line] += 1
} else {
m[line] = 1
}
}


three_smallest: [3]int

for i := 0; i < 3; i += 1 {
best_val := 100000
curr_best_key: string = ""
for k, v in m {
if v <= best_val {
best_val = v
curr_best_key = k
}
}
// three_smallest[i] = curr_best_key
n, ok := strconv.parse_int(curr_best_key)
if !ok {
fmt.eprintln("Error when parsing string: ", curr_best_key)
}
three_smallest[i] = n
delete_key(&m, curr_best_key)
}

// fmt.println("Printing the three results:")
result: int = 1
for i := 0; i < 3; i += 1 {
fmt.printfln("{}", three_smallest[i])
result *= three_smallest[i]
}

fmt.println("Result: ", result)
}


Just got off from work. Super quick and dirty, and honestly dumb brute-forcey Odin code
>>
>>110487830
I think last year was the first time I neglected to send him a donation. He needs to pass the torch.
>>
>>110487806
people always say this but reddit loved intcode
>>
>>110483982
>>try to sign into AOC with the usual Twitter id
Who the hell uses Twitter instead of Github?
>>
>implying i don't use my google account for everything so i am completely locked out of the internet if they ever review some of my early attempts at seeing how far I could push gemini into writing illegal erotica
>>
>>110488572
Google is like LinkedIn: only good for burner accounts to troll people with.
>>
>>110488572
There's no such thing as illegal written erotica
>>
>>110488732
You kinda have to dox your phone number to even have a google account these days
>>
File: day1image.png (521 KB, 1680x2040)
521 KB PNG
Idiomatic Java Solution
>>
>>110489002
I'm sick of all the idiomatic solutions.
give me a IDIOTIC solution
>>
File: day1part 2 image.png (778 KB, 1680x3028)
778 KB PNG
>>110489006
Idiotic day 1 part 2 solution as requested
>>
Is the GREAT FILTER graphic guy still here?
>>
>>110483757
"Neils? do we still have VSCode installed?"
>>
>>110488346
It probably became popular there to pretend you loved it, but at the time, there was a lot of complaining. Faggots were complaining that because they missed one day, it derailed their entire experience.
>>
File: merge lol.png (530 KB, 1650x2154)
530 KB PNG
Just found out merge existed lol
>>
File: day1.png (73 KB, 513x1210)
73 KB PNG
>>110489006
My idiotomatic solution
>>110487688
Did you read it backwards?
>>
>>110487254
>return
>>
day 2 will unironically be a great filter
source: eric revealed this to me in a dream
>>
>>110487806
Intcode was pure kino though. wtf. My only complaint is a lot of the puzzles weren't intcode related.
>>
how does AoC work? how punishing is the progression? if you didn't solve Day1 are you allowed to do Day2 without cheating?
>>
>>110489240
day 13-25 are now completely impossible, so it's harder than it's ever been
you are cheating if you don't do everything in J within day*2min of the puzzle dropping
>>
>>110489251
that's fine. K is where i have trouble
>>
>>110489006
just look for any rust solution posts
>>
>>110489112
>5.5 secs on bigboy
damn, javascript sucks
>>
>>110487918
They have really arbitrary range bans too and ain't nobody gonna give email to them. If your IP isn't basically a legacy at this point, you'd probably catch it.
>>
>>110488295
Last year was really bad. That last puzzle was a really good fuck you but the half assed hueristic "worked." I was giga pissed.
>>
File: 1784150304210044.png (204 KB, 859x229)
204 KB PNG
it's out
https://adventofpuzzles.io/2026/day/2
>>
>>110489340
if you write a rant i will read it
>>
>>110484461
Did they improve Raku's speed or is it still slow to execute?
>>
Is gameboy anon here?
>>
>>110489386
this game gave me divine knowledge. a higher being communicated to me and taught me to walk
>>
>>110489374
Easy day 25 problems were nice when it was actually a 25 day challenge, especially as most people are busy around that time. For 12 days, it's just a missed opportunity to drop a monster. Speaking of which, we'll never get a problem as fun as searching the water for those sea monsters.
>>
>>110489386
I remember having to solve this for and algorithms or data structures class one time.
>>
[spoiler]lantern[/spoiler][spoiler]fish[/spoiler]
>>
...fuck
>>
trying to decide if today is going to be djikstra or random shit + bigint
>>
10 MINUTES
>>
ADVENT OF PARSING
>>
File: eric.png (1.87 MB, 1536x1024)
1.87 MB PNG
Today is going to be an intcode program to run inference on a neural network (your puzzle input).
>>
File: thewallcometh.jpg (104 KB, 675x1000)
104 KB JPG
TONIGHT'S THE NIGHT!
>>
File: 1779300459689941.png (696 KB, 708x1000)
696 KB PNG
soon
>>
guys I forgot how to code manually.
>>
wtf. the train moves
>>
>the elves need some help
>you have a list of IDs in no particular order
>there is exactly one ID missing between the lowest ID number and the highest ID number, what is it?
>example
6
4
3
7

>this list is missing ID 5
>>
File: showtime.jpg (86 KB, 640x480)
86 KB JPG
https://www.youtube.com/watch?v=IMF1HRiBC7Q
>>
>>110489899
meds. now.
>>
>>110489901
cancer music
>>
>>110489900
part 2
>how many numbers are in your input?
>careful! don't count part 1's answer!
>also don't count any stray newlines!
>the answer is 4
>>
5 MINUTES
>>
>>110489891
>>110489895
wall mind
>>
>>110489895
great fucking movie
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB JPG
>>
important reminder: there are no silver stars!
>>
>>110489908
aoc is for programmers not mathematicians.
>>
File: 1791917457422748.png (118 KB, 804x804)
118 KB PNG
I'm ready
>>
>>110489901
am I crazy or did the youtube title used to not have "Getter Jaani -" at the beginning?
>>
Day 2 grid
>>
I NEED TO SHIT
>>
>>110489929
Dude's posting a different link.
The original shows up as a related video
>>
LOCK IN
>>
brb
>>
>>110489934
oh shit 98million views vs 1.5 million
https://www.youtube.com/watch?v=hjGZLnja1o8
>>
CRAWLING IN MY SKIN
>>
FUCK
>>
FUCK
>>
Oh this is easy
>>
ok for a moment there I thought we had to do some crazy parsing of the annotated demo example
>>
FUCK
>>
guys how does modulus work...
>>
I don't get it????
>>
>So, if the robot is at an orange waypoint, it would be best if the robot's next instruction were o (for distance 6); if there aren't any o instructions left, the next-best instruction would be r (for distance 5), and so on.
you know you could have let us solve that ourselves eric. you didn't have to spoil the whole puzzle.
>>
return (steps['r'] * 6) + 5 + ((steps['v'] - 1) * 6) + 5 + ((steps['b'] - 1) * 6) + 5 + ((steps['g'] - 1) * 6) + 5 + ((steps['y'] - 1) * 6) + 5 + ((steps['o'] - 1) * 6)
>>
yay i solved it...
>>
uhhhh... mathlets???
>>
wasted so much time trying to understand what he was asking. eric is such a tard I swear
>>
He fucking got me I had to google the negative modulo thing
>>
File: code.png (343 KB, 1648x1850)
343 KB PNG
easy day, bet it could be done more nicely though
>>
guys ... i think i hit the wall
>>
File: 1770792753085814.png (10 KB, 439x53)
10 KB PNG
OH NO NO NO NO NO
>>
who broot here
>>
File: 1779307476173200.png (14 KB, 650x308)
14 KB PNG
claude destroyed a generation of men
>>
>>110490040
don't tell me you actually allocated a really long rainbow string..
>>
>>110490039
shit is laggy, i finished like 10 minutes ago and the /g/derboard still shows me at one star. i don't recall this happening in the past, guess he's cheaped out on infrastructure this year
>>
>>110490047
~6k characters is tiny
>>
>>110490057
bet eric did it intentionally seeing as leaderboards are "toxic" now
enjoy your participation trophy
>>
Had a brainfart doing modular arithmetic, so I just went for the lazy solution. Even lazier for part two by just sorting, an impressively dreadful solution.
data = sorted(list(open("Day 02 input.txt", "r").read().strip()), key=lambda x:"rvbgyo".index(x))
dist = 0
for num, i in enumerate(data):
dist += 1
target = "roygbv".index(i)
while not dist%6 == target:
dist += 1
print dist
>>
let input = read_line ()
let colors = "roygbv"
let look i = colors.[i mod String.length colors]

let p1 c (i, n) =
let exception Return of int * int in
let rec loop i n =
if look i == c then raise (Return (i, n)) else loop (i + 1) (n + 1)
in
try loop (i + 1) n with Return (i, n) -> (i, n)

let travel p f = String.fold_left (fun robo c -> p1 c robo) (0, 0) p

let () =
assert (11 = Pair.fst (travel "roygbv" p1));
assert (30 = Pair.fst (travel "vbgyor" p1));
assert (35 = Pair.fst (travel "vvvvvv" p1));
Printf.printf "p1: %d\n" (travel input p1 |> Pair.fst)

going to --package ocamlgraph for p2
>>
last year, even though we didn't have the global leaderboard, i could've sworn the "personal stats" page still showed your rank but it's not there anymore, just your "personal times". am i misremembering?
>>
>>110490076
I don't recall it showing rank last year.
>>
r8 my code:

Claude, solve aoc 2026 day 2. Make no mistakes.
>>
File: 1790736665998598.png (206 KB, 984x1793)
206 KB PNG
C, easy one today
>>
>>110490076
You could only try to infer your rank from the anonymized stats Eric published after the event
>>
>muh modular arithmetic
if next_n > pos_n {
ans_a += (next_n - pos_n) as u64;
} else {
ans_a += (6 - (pos_n - next_n)) as u64
}
>>
File: 1770227313946989.png (46 KB, 664x796)
46 KB PNG
>>
Why is there no Indigo waypoint Eric
>>
THE TRAIN JUST MOVED AGAIN
AHHHHHHHHHHHHH
>>
>>110490100
You're imagining things
>>
File: file.png (58 KB, 270x151)
58 KB PNG
>>110489448
>>
File: 1789913434265551.png (27 KB, 422x818)
27 KB PNG
Kind of cheated because I noticed Eric gave me no yellows, so not a robust solution at all.
>>
A robot with program roygbv would travel a total distance of 11.

No it fucking wouldn't.

Let's frame it in the same way as the prior example.
roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
^ initial robot position

roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
^ robot travels distance 1 to next orange waypoint

roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
^ robot travels distance 1 to next yellow waypoint

roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
^ robot travels distance 1 to next green waypoint

roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
^ robot travels distance 1 to next blue waypoint

roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
^ robot travels distance 1 to next blue waypoint

After these instructions, the robot has traveled a total distance of 5.

THAT'S IT

I wasted 15 minutes debugging part 1 before I realized the second fucking example is just wrong.
>>
File: carbon.png (549 KB, 1768x2806)
549 KB PNG
initially tried to broot it with next_permutation, discovered that didn't work, despaired, then wrote this. worked for me, original had negative modulo bullshit but the workaround to make it work right is super fucking ugly so i rewrote it a bit
>>
>>110490165
>
roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
^ initial robot position

roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
^ robot travels distance 1 to next orange waypoint

where is your instruction that make it go to the next red waypoint
>>
>>110490165
BRAINLET ALERT BRAINLET ALERT BRAINLET ALERT. It starts on r, so the first move takes 6 and the other moves take 1.
:^)
>>
>>110490165
lol u wrong
>>
idiomatic webshit

const dist = (a, b) => {
let i = 'roygbv'.indexOf(a);
let j = 'roygbv'.indexOf(b);
return i < j ? j - i : (j + 6) - i;
}

const p1 = input => {
let p1 = 0;
let commands = input.split('');
commands.forEach((c, i) => {
p1 += dist(i ? commands[i-1] : 'r', c);
});
console.log(p1);
};

const p2 = input => {
let order = 'rvbgyo';
let sorted = input.split('').sort((a, b) => {
return order.indexOf(a) - order.indexOf(b);
}).join('');
return p1(sorted);
};
>>
File: bapboopabepab.png (46 KB, 642x835)
46 KB PNG
oh boy
>>
>part 3
>there are several gardens, and every garden has different waypoint arrangements
>the first garden repeats roygbv, like usual
>the second garden has many more colors:
abcdefghijklmnopqrstuvwxyz
, repeating forever as well
>the third garden has an unusual arrangement:
royoroyggbbvv
, also repeating infinitely
>find the maximum distance for your robot's program for each garden, then multiply the results together
>>
File: carbon.png (551 KB, 2560x2866)
551 KB PNG
guys i think i might have early onset dementia
>>
>>110490233
AI induced dementia
>>
>>110490246
claude did i take my pills today make no mistakes
>>
File: cl.png (90 KB, 688x596)
90 KB PNG
part 2 was too easy. partitioning and then summing is equal to just summing.
>>
File: file.png (71 KB, 503x828)
71 KB PNG
This year in Ada again.

God I hate the captcha.
>>
>>110490075
>ocamlgraph
oh right the terrain is repeating
so I did much worse than that
let input = read_line ()
let colors = "roygbv"
let look i = colors.[i mod String.length colors]

let travel c i =
let exception Return of int in
let rec loop i = if look i == c then raise (Return i) else loop (i + 1) in
try loop (i + 1) with Return i -> i

let p1 p = String.fold_left (fun robo c -> travel c robo) 0 p

let p2 p =
let r = ref 0 in
let o = ref 0 in
let y = ref 0 in
let g = ref 0 in
let b = ref 0 in
let v = ref 0 in
String.iter
(function
| 'r' -> incr r
| 'o' -> incr o
| 'y' -> incr y
| 'g' -> incr g
| 'b' -> incr b
| 'v' -> incr v
| _ -> assert false)
p;
let d = ref 0 in
while !r + !o + !y + !g + !b + !v > 0 do
let x, dd =
[(r, 'r'); (o, 'o'); (y, 'y'); (g, 'g'); (b, 'b'); (v, 'v')]
|> List.filter (fun (x, _) -> !x > 0)
|> List.map (fun (x, c) -> (x, travel c !d))
|> List.sort (fun (_, a) (_, b) -> Int.compare b a)
|> List.hd
in
d := dd;
decr x
done;
!d

let () =
assert (11 = p1 "roygbv");
assert (30 = p1 "vbgyor");
assert (35 = p1 "vvvvvv");
Printf.printf "p1: %d\n" (p1 input);
assert (33 = p2 "vrvbvg");
assert (55 = p2 "groovyyoyo");
assert (103 = p2 "roygbvroygbvroygbv");
Printf.printf "p2: %d\n" (p2 input);
>>
File: 02.png (107 KB, 2015x638)
107 KB PNG
>>
File: carbon.png (131 KB, 1414x834)
131 KB PNG
Janet FTW
>>
>>110490222
part 2 used to have interesting twists like this way more often. My part 1 code works for part 2 more often than not now. Eric ruined Christmas again

>its only day 2

there are only 12 days now we are 1/6th over already. This is it.
>>
>>110486947
This will be a waste of your life. Just let him die, he had his time.
>>
File: 1787004442934553.png (76 KB, 327x403)
76 KB PNG
>>110486947
>>
>raped by work this week
>want to do some visualizations for aocg this year
>by the time i get around to it it will be 80% over

I am still seething so hard over the 12 day thing what even is the point anymore.
>>
File: fuckwebp.png (535 KB, 715x981)
535 KB PNG
bigboy #2
url: https://files.catbox.moe/mhw4zx.7z
size: 142M
silver: 558275033
gold: 893216516
>>
File: ocaml2.png (117 KB, 864x1248)
117 KB PNG
>>110490280 (me)
awful code but it could still benefits from cleaner tuples in that list
>>
>>110490292
Your part 2 is slick.
>>
>>110490312
>https://files.catbox.moe/mhw4zx.7z
Content-Length: 0
>>
>>110490312
>bigboy
>0 bytes
kek
>>
File: 1767141152525414.png (1.97 MB, 1248x832)
1.97 MB PNG
I think adding the rainbow made it add the gay signs
>>
>>110490312
you had one job, anon..
>>
>>110490317
>>110490328
fuck catbox I'll try again...
>>
>>110490317
>>110490328
we're gonna need a bigger boy...
>>
>>110490337
hellooooooo? dial-up anon, get going!
>>
>>110490312
>Exception: End_of_file.
defeated by bigboy
>>
File: 2026_day2.png (61 KB, 1519x569)
61 KB PNG
>>
>>110490354
>still reading slashdot in 2026
>needing multithreading for this
>@@@
:) :) :)
>execute@Join
stay away from this death cult
>>
>>110490377
I'm not sure if this is a bot, but /. made me laugh.
>>
File: 26_D02_C#.png (93 KB, 699x912)
93 KB PNG
>>
>>110490329
I for one like the slop.
>>
>>110490303
i kek'd but have some decency anon
>>
File: d02_034149.png (107 KB, 960x1678)
107 KB PNG
I am so dumb ahhhh.
>>
>>110490338
>>110490350
>>110490351
sorry fellas, catbox shat the bed
bigboy #2
url: https://gofile.io/d/b9mffmvi
size: 142M
silver: 558275033
gold: 893216516
>>
>>110490165
Because it starts on r, the first r instruction would take it 6 places.
>>
>>110490418
const COLOR: [u8; 256] = const {
let mut color = [0; 256];
color[b'r' as usize] = 0;
color[b'o' as usize] = 1;
color[b'y' as usize] = 2;
color[b'g' as usize] = 3;
color[b'b' as usize] = 4;
color[b'v' as usize] = 5;
color
};

const THREADS: usize = 16;

fn main() {
let input = unsafe { memmap2::Mmap::map(&std::io::stdin()) }.unwrap();
let input = input.trim_ascii();

let (a, counts) = std::thread::scope(|s| {
let mut handles = Vec::new();
for i in 0..THREADS {
handles.push(s.spawn(move || {
let start = i * input.len() / THREADS;
let end = (i + 1) * input.len() / THREADS;
let mut prev = if start == 0 {
0
} else {
COLOR[input[start - 1] as usize]
};
let mut a = 0;
let mut counts = [0u32; 6];
for &c in &input[start..end] {
let cur = COLOR[c as usize];
counts[cur as usize] += 1;
let mut step = cur + 6 - prev;
step -= (step >= 7) as u8 * 6;
a += step as u32;
prev = cur;
}
(a, counts)
}));
}
let mut a = 0;
let mut counts = [0; 6];
for handle in handles {
let (suba, subcounts) = handle.join().unwrap();
a += suba;
for (i, &count) in subcounts.iter().enumerate() {
counts[i] += count;
}
}
(a, counts)
});

let mut b = 0;
b += 6 * counts[0];
let mut prev = 6;
for i in [5, 4, 3, 2, 1] {
if counts[i] == 0 {
continue;
}
b += 6 * counts[i];
b -= (prev - i) as u32;
prev = i;
}

println!("{a}");
println!("{b}");
}

18.0ms on 16 threads
120ms on one thread
>>
All of your part 2s are wrong
>>
>>110490418
this >>110490313 gets it in 14.5s with a peak RSS of 289 MB
>>
>>110490427
haven't you heard that the light is darkest under the lamp?
if you're standing with one foot covering your keys and looking around for them, won't you first find your neighbor's identical keys that are seven feet away and through his front window?
>>
File: 2.png (122 KB, 2075x638)
122 KB PNG
>>110490418
217ms
>>
File: aoc2.png (166 KB, 1280x1649)
166 KB PNG
that was kind of cheeks
>>
>>110490427
It's not wrong if it got a star.
>>
File: day2.png (27 KB, 568x507)
27 KB PNG
eh i didn't like how i solved it
>>
>7z
nice exploit
>>
C
#include <stdio.h>
int val(int c) {
return
c == 'r' ? 0 :
c == 'o' ? 1 :
c == 'y' ? 2 :
c == 'g' ? 3 :
c == 'b' ? 4 :
c == 'v' ? 5 :
-1;
}
int dis(int a, int b) {
return (b > a ? 0 : 6) + b - a;
}
int main() {
int p1 = 0, p2 = 0, o = 0;
for (int v; (v = val(getchar())) >= 0; ++p2, p1 += dis(o, v), o = v);
printf("part 1: %i\n" "part 2: %i\n", p1, p2 * 6 - 1);
}
>>
>>110490494
cry moar, neet
>>
>>110490512
>chained ternary
PUKE
>>
>>110490512
not sure about that part 2
>>
>>110490522
Don't be a cry baby, don't you love Rust pattern matching?
>>110490524
All the colors are present, otherwise calculate frequencies and pick the color that gives maximum distance to the previous one until you run out of colors.
>>
>>110490524
Yep, there is a typo. It should be p2 * 6 - 5.
>>
File: carbon.png (253 KB, 1222x1432)
253 KB PNG
>>110490418
$ time ./a.out <bigboy.txt
558275034
893216522

real 0m0.300s
user 0m0.269s
sys 0m0.024s
>>
>>110490076
if you click [stats] in the topbar after you submit you can find the lowest possible rank you would have
but eric delays and fuzzes the results and batches them per every few minutes or something so it will probably be quite a bit higher

on days with really hard puzzles where solutions come in slow you get a reasonably accurate estimate though I think
unless eric REALLY decids to be an asshole and scales the update frequency with submission frequency
>>
Asked claude to do systemverilog and it did it no problem. This industry really is finished. I won't post it's solution because who cares
>>
>>110490607
I was about to say what a language where all the keywords are slurs but you could just tell claude to do it in a proxy-language and then find+replace at the end
>>
>>110490611
>what a
what about a*
>>
>>110490427
Only if there's no 'o' in my input but I verified that first
>>
>>110490592
jfc i did the same thing and then overthunk it majorly and settled on a poop solution
>>
most solutions you guys come up with are ugly. the numerical solvers should piss off to /sci/
>>
>>110490669
>most
now you have to point out the non-ugly ones and also post your own
>>
>>110490669
>I'm a brainlet
>Seeing smart solutions makes me seethe
>>
>>110490672
that was his plan to force you to comment on his code. He's a narcissist, don't respond again to him
>>
>>110490592
doesn't work with bigboy
what AoC meme was that?
>>
>>110490669
>numerical solvers
wot
>>
>>110490682
jokes on him, i had a firm grip of my cock when i responded so now he's gay
>>
Getting kinda tired of solving in C++ but I don't have time to do another language right now. Kinda wanna try zig, but that will have to be Dec 13-24 I guess.
>>
File: Day02.png (102 KB, 1282x731)
102 KB PNG
Day 2 and I already don't know what the fuck I am writing.
>>
File: carbon(2).png (205 KB, 1670x1550)
205 KB PNG
>>110490418
$ mix aoc.solve -r input/big -y 2026 -d 2 -p b --bench 1
558275033
893216516

Ran in 3637.602ms


Fighting for my life.
>>
>Most of my leaderboard rivals from last year are not participating this year (HiggstonRainbird, Oresama, mid-kid, sin-ack)
>No twitch thot streaming "her" solutions
>No ASM anon
>No looking-for-internship
>Only 2 threads in 2 days
Very quiet this year.
>>
File: elfves.jpg (117 KB, 521x385)
117 KB JPG
>>110490712
>but that will have to be Dec 13-24 I guess.
>>
>>110490723
love niche shit like this
what language anon?
>>
>>110490724
/aocg/ is winding down
quiet days ahead I'm afraid
>>
File: file.png (68 KB, 644x938)
68 KB PNG
"Elliot! You idiot!"matick rust
>>
>>110490724
It's unironically over. Happy to be here with you all but it's going to be small, slow, and quiet from now on until Eric full on pulls the plug someday.
>>
>>110490724
>>No ASM anon
I'm here, I'm just not doing it in assembly this year.
I was going to do PS3, but I'm still infatuated with the PS2 and I didn't get enough prep done for PS3. I haven't even done a previous year's problem to practice yet.
I still intend to do PS3 sometime. Maybe next year I'll use it for everybody codes and AoC (if AoC is still alive). I think it will be very cool (but it'll mostly be ASM SPU programs with a C PPU helper).
>>
am I the only one who bothered with the "no color in input" edge cases?
>>
>>110490592
off by one, buddy
>>
>>110490789
wait what like a blank input?
>>
>>110490802
no like the example(s), where at least one color is missing entirely
>>
>>110490696
Any arithmetic more complicated than x + 1 makes you a hylic. You're supposed to simulate the robot stippety-stapping over the track
>>
>>110490807
everyone's input was missing a color anon
>>
>>110490789
My original implementation of part 2 assumed all colours were present, then I realised Eric would have probably done that to trip people up, so I made it just check the furthest possible colour from the last one.
>>
>>110490807
idk how you would solve it in a way that *depends* on one or more colours not being there
>>
>>110490789
no
>>
>>110490816
my shit solution here did >>110490145
>>
>>110490816
((count - 1) * 6 for every color) + 5*6 for moves between colors
>>
>>110490831
oh yeah
though I guess it is just leaving out the case to save 4 lines rather than depending on it not being there
>>
>>110490424
this assumes all colors are present
>>
>>110490844
The "if counts[i] == 0" guard should take care of that, it works on the examples. (Before I added that it worked on my challenge input but not on all the examples.)
Do you have an input on which you think it fails?
>>
>>110490735
It's Elixir, I've done the past few years with it. Really fun language to mess around in, especially if you get into the comfy metaprogramming. I love getting to use the AoC tools/workflow I've built up in it every year.
>>
>from collections import Counter
Yup. That's the workhorse for this year.
>>
File: fillt.png (12 KB, 634x268)
12 KB PNG
is this the first actual filter or is it too early to say yet
>>
>fun puzzle at Day 2

color me impressed Eric
>>
seebles
using s = std::string;
int main_day2a()
{
s waypoints = "roygbv";
auto get_index = [&](char c) { return waypoints.find(c); };
auto get_cost = [&](char c, char p) { return (5 + get_index(c) - get_index(p)) % 6 + 1; };
int cost = 0;
char prev = 'r';
for (char c : program)
{
cost += get_cost(c, prev);
prev = c;
}
return cost;
}
int main_day2b()
{
std::unordered_map<char, int> freq;
for (char c : program)
{
freq[c]++;
}
program = s(freq['r'], 'r') + s(freq['v'], 'v') + s(freq['b'], 'b') + s(freq['g'], 'g') + s(freq['y'], 'y') + s(freq['o'], 'o');
return main_day2a();
}
>>
>>110490981
The puzzle description is just incomprehensible. I had to work backwards from the results of the examples to figure out what Eric wanted me to do.
>>
>>110490981
Definitely not the filter yet.
>>
>>110491004
His technical writing skills have definitely slipped.
>>
#include <iostream>
#include <fstream>
#include <filesystem>

//Resorts the nodes
std::string NodeSort(std::string instructions)
{
std::string path{"rvbgyo"}; //Reorganize the instructions in terms of distance to travel
int currentNode{0};
for (int x = 0; x < 6; ++x) //While cycling through the instructions
for (int y = currentNode; y < instructions.length(); ++y) //Venture through the nodes
if (instructions[y] == path[x])
{
char temp = instructions[y];
instructions[y] = instructions[currentNode]; //Swap nodes that match
instructions[currentNode] = temp;

++currentNode; y = currentNode; //And iterate to progress with the transcription
}

return instructions; //Return the finished results
}

int main()
{

std::ifstream input("day2 code input.txt"); //Input the data
std::string instructions{}, path{"roygbv"}; //Instructions entails the nodes, path indicates the node order
int steps{0}, instruSize, pathIter{0};
char currentNode{}, iterNode{};

getline(input, instructions); //Get the input
input.close();

instructions = NodeSort(instructions); //Resort the input for max distance

instruSize = instructions.length();
for (int x = 0; x < instruSize; ++x)
{
currentNode = instructions[x]; //Then iterate through the nodes
do
{
iterNode = path[++pathIter]; //While counting steps, progress to the next node
++steps;
if (pathIter == 5)
pathIter = -1;

} while (currentNode != iterNode);
}

std::cout << "Steps taken: " << steps << "\n"; //And show the final tally

return 0;
}


Yay.
>>
>>110491056
>technical writing
lmao there's nothing technical in the description
>>
>>110491004
I fucked up reading it and just had to re-read the problem text.
I think it was more that it was easy to be led astray if you weren't reading carefully.
>>
>>110490860
oops, i missed that, yeah no it's fine
>>
File: washed26.02.png (27 KB, 562x1393)
27 KB PNG
One of the least coherent problem descriptions to my memory. It wasn't even a hard one once I realized what kind of problem it was.
>>
File: adv_2026_02.png (85 KB, 1282x836)
85 KB PNG
I couldn't make it pretty...
>>
>>110491075
What do you think a problem description is you mouth-breathing tard?
>>
File: adv_2026_02_pretty.png (79 KB, 1336x727)
79 KB PNG
>>110491150
Scratch that, I remembered that sets exist.
>>
For yesterday
>>
File: 1782969986906026.png (361 KB, 600x450)
361 KB PNG
>>110490984
>color me impressed
>>
>>110490418
total haskell domination, took only 13G ram

(558275033,893216516)

real 28m26.471s
user 5m2.928s
sys 16m17.030s
>>
C using Win32 API to memory map the input file.
(15+ times faster than using getchar in Windows)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef struct { HANDLE f_, m_; PBYTE begin, end; } MemFile;
void MapF(const char* s, MemFile* o) {
o->m_ = NULL, o->begin = o->end = 0;
o->f_ = CreateFile(s, GENERIC_READ, FILE_SHARE_READ,
0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (o->f_ == INVALID_HANDLE_VALUE) return;
LARGE_INTEGER z;
if (!GetFileSizeEx(o->f_, &z)) return;
o->m_ = CreateFileMapping(o->f_, 0, PAGE_READONLY, 0, 0, 0);
if (o->m_ == NULL) return;
o->begin = (const PBYTE)MapViewOfFile(o->m_, FILE_MAP_READ, 0, 0, 0);
if (!o->begin) return;
o->end = o->begin + z.QuadPart;
}
void UnMapF(MemFile* o) {
if (o->begin) UnmapViewOfFile(o->begin);
if (o->m_ != NULL) CloseHandle(o->m_);
if (o->f_ != INVALID_HANDLE_VALUE) CloseHandle(o->f_);
}

enum {maxcol = 6};
static int dis(int a, int b) {
return (b > a ? 0 : maxcol) + b - a;
}
#include <stdio.h>
int main(int argc, const char** args) {
if (argc < 2) return puts("Missing filename");
MemFile in; MapF(args[1], &in);
const int val[256] = {
['r'] = 1, ['o'] = 2, ['y'] = 3, ['g'] = 4, ['b'] = 5, ['v'] = 6};
int freq[maxcol] = {};
int p1 = 0, o = 0, v;
for (auto it = in.begin; it != in.end; ++it)
v = val[*it], (--v >= 0) && (++freq[v], p1 += dis(o, v), o = v);
int p2 = maxcol * freq[0];
for (int o = 0, i = maxcol; --i;)
if (freq[i])
p2 += dis(o, i) + maxcol * (freq[i] - 1), o = i;
printf("part 1: %i\n" "part 2: %i\n", p1, p2);
UnMapF(&in);
}
>>
>>110491066
>return instructions; //Return the finished results
i could never have guessed
>>
>>110491399
you should try processing the file in small chunks too
going back and forth between freq and *it must cost a lot of cycles given the size of bigboy, assuming that's the input you're testing your solution with
>>
File: ss.png (174 KB, 1280x1413)
174 KB PNG
time spent mostly in the switch I would guess

Ryzen 5 3600X

> time ./main
traveled: 893216516

________________________________________________________
Executed in 814.92 millis fish external
usr time 807.16 millis 223.00 micros 806.94 millis
sys time 4.73 millis 738.00 micros 3.99 millis



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.