[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / 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


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1764929391889.png (1.2 MB, 960x1088)
1.2 MB
1.2 MB PNG
boring friday edition

>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

Previous thread: >>107439547
>>
File: codeimage-snippet_5.png (100 KB, 756x603)
100 KB
100 KB PNG
idiotmatic python
>>
File: solve.png (619 KB, 5708x4102)
619 KB
619 KB PNG
idiomatic Rust solution
>>
Kindly answer the needful saars
https://strawpoll.com/40Zm4GV1oga
>>
>>107443414
>.com
nice virus
>>
>>107443414
>rustfags already posting this poll on discord and reddit to rig the results
>>
>>107443414
don't click it's an ip logger
>>
>>107443396
>idiomatic Rust solution
more like unreadable Rust solution
>>
>>107443414
>Excel
where
>>
little does he know that he's the brown one
>>
File: AoC-05.png (127 KB, 922x1257)
127 KB
127 KB PNG
>Advent of range problems
>>
File: file.png (338 KB, 1360x2784)
338 KB
338 KB PNG
??? easiest day so far. He could have at least done something slightly tricky with part 2.
>>
gpt-oss 20b, the one you can run locally on your gaming pc solved this on first try without any issues
>>
>>107443483
>>107443527
filtered
>>
bigboy #5 v2

Run this bigdad5.py script with these default params to generate the input.

717551
4342208387770361
544ms

from random import choice, randint, seed, shuffle

seed(42)
min_id, max_id = 10**12, 10**16 - 1
num_disjoint_ranges, num_total_ranges, num_ingredients = 10**5, 10**6, 10**6

points = sorted(randint(min_id, max_id) for _ in range(2 * num_disjoint_ranges))
disjoint_ranges = list(zip(points[::2], points[1::2]))
assert len(disjoint_ranges) == num_disjoint_ranges

ranges = []
for _ in range(int(num_total_ranges * 0.9)):
chosen_range = choice(disjoint_ranges)
p1, p2 = randint(*chosen_range), randint(*chosen_range)
start, end = min(p1, p2), max(p1, p2)
ranges.append((start, end))

for _ in range(num_total_ranges - len(ranges)):
start = end = randint(*choice(disjoint_ranges))
ranges.append((start, end))

assert len(ranges) == num_total_ranges

ingredients = [randint(*choice(ranges)) for _ in range(int(num_ingredients * 0.5))]
ingredients += [
randint(min_id, max_id) for _ in range(num_ingredients - len(ingredients))
]
assert len(ingredients) == num_ingredients

shuffle(ranges)
shuffle(ingredients)

for start, end in ranges:
print(start, end, sep="-")
print()
for id in ingredients:
print(id)
>>
>>107443706
nice virus
>>
>>107443521
This one requires more math and algorithmic skills than the previous ones, but it's easier to implement if you already know them.
>>
>>107443509
kek
>>
>>107430560
I tried, but apparently Nim's too retarded to let you make a hash set from a range, and making one by looping through the ranges was incredibly slow.
>>
>>107443706
executed and uploaded: https://0x0.st/KtGx.txt
227ms with >>107443396
>>
>>107443775
thanks. how do you measure your times? and how do you take input? I think we should maybe have a standard way of doing these just to make time comparison easier.
>>
File: img-2025-12-05-12-21-39.png (94 KB, 1574x648)
94 KB
94 KB PNG
>>107443806
>how do you measure your times?
cargo bench
>and how do you take input?
std::fs::read_to_string
>>
am i going crazy or was this exact fucking problem already posted a few seasons ago? I vividly remember combining ranges like that but can't find it in my old code
>>
>>107443843
merging ranges is a common puzzle, there's a handful of them across all aoc years
>>
>>107443843
2023 which was also a day 5: https://adventofcode.com/2023/day/5
>>
>>107443865
that's the one, except those fertilizers were actually tricky
>>
File: aoc2025-05.png (100 KB, 510x832)
100 KB
100 KB PNG
meh
>>
Any idea why this parser shits itself on the bigboy?
parser :: ReadP ([(Int, Int)], [Int])
parser = pair (pair readDecP (char '-') readDecP `sepBy` char '\n') (string "\n\n") (readDecP `sepBy` char '\n')
where pair left sep right = left <**> ((,) <$ sep) <*> right

I had to resort to
bimap (map (bimap read (read . tail) . break (== '-'))) (map read . tail) . break null . lines
in the end
>>
>>107443830
cool. I use hyperfine for measuring and stdin for input. so that adds some overhead. can you once measure with hyperfine? I cleared build cache and reran. getting 320ms. the problem is so simple that there is not much scope for variability (other than the cool radix sort solution c23 anon posted). and both rust and zig use llvm.
>>
File: asdfasdfasdfasdf.png (166 KB, 948x1046)
166 KB
166 KB PNG
Haskell solution
takes 12.6s for the bigboy, wonder if it was all the copying of the same pool and i need to actually create sub-array for the binary search
>>
>>107443806
>>107443830
>>107443899
bro your
/usr/bin/time
?
>>
Surely the great filter will arrive tomorrow, right? Eric wouldn't leave us unsatisfied forever...
>>
>>107443925
pretty close to the one with hyperfine (320ms)

717551 4342208387770361

________________________________________________________
Executed in 334.92 millis fish external
usr time 290.04 millis 0.31 millis 289.73 millis
sys time 43.67 millis 1.99 millis 41.68 millis
>>
Shittiest AoC EVER. Even worse than Shitcodes. Im going to neck Eric
>>
File: carbon(4).png (244 KB, 1986x1318)
244 KB
244 KB PNG
>>107443904
Nice one.

Here is mine, I feel like i made it more complicated than it should be. At some point I was just too invested in my solution to look back.
I'll have a look at other anons solutions, I think there were smarter implementations using half intervals and such
>>
File: 1734880766225955.jpg (13 KB, 225x225)
13 KB
13 KB JPG
/(\d+)-(\d+)/
>>
File: 1758808615021801.jpg (304 KB, 1658x1356)
304 KB
304 KB JPG
Webdev's revenge
>>
>benchmarking different things across differing hardware
lmoa
>>
>>107444053
benchmark by number of cpu operations duh
>>
>>107444053
The comparisons are only measurably important when there are orders of magnitude difference.
Below that, it's just fun to try and get smaller numbers.
>>
File: aoc_day5.png (109 KB, 722x1041)
109 KB
109 KB PNG
What a letdown for part 2
>>
>>107444179
probably the most retarded solution so far
>>
>>107444188
>talks shit
>does not post code
>>
thanks to AoC every december i can learn about languages people use as well as their abhorrent shitass syntax
>>
>>107443151
part 2
>>
>>107443706
>>107443775
191ms with slightly washed >>107444179
>>
File: carbon (1).png (330 KB, 2020x1436)
330 KB
330 KB PNG
>>
The ranges get parsed once :)
#include <stdio.h>
#include <stdlib.h>
#define NRANGES 177

static inline int comp(const void *a, const void *b){
const long *A=a,*B=b;
return A[0]!=B[0] ? (A[0]>B[0])-(A[0]<B[0]) : (A[1]>B[1])-(A[1]<B[1]);
}

int main(){
long rangeTable[NRANGES*2][2] = {0}, fresh = 0, rangeMin = 0;
for(int i = 0; i < NRANGES*2; i+=2) {
scanf("%ld-%ld", &rangeTable[i][0], &rangeTable[i+1][0]);
rangeTable[i+1][1] = 1;
}
qsort(rangeTable, NRANGES * 2, sizeof rangeTable[0], comp);
for(int i = 0, lim = 0; i < NRANGES*2; i++){
if(rangeTable[i][1]) lim--;
else{
if(!lim) rangeMin = rangeTable[i][0];
lim++;
}
if(!lim){
fresh += rangeTable[i][0] - rangeMin + 1;
}
}
for(long product = 0; scanf(" %ld", &product) != EOF;);
printf("%ld\n", fresh);
}
>>
File: rape_me.png (60 KB, 721x953)
60 KB
60 KB PNG
im back and im here to share more of my ugly code and im still behind but im not filtered yet
>>
>>107444591
>#define NRANGES 177
>>
tomorrow's gonna be a maze day isn't it
>>
File: day5.png (532 KB, 1514x2382)
532 KB
532 KB PNG
I really expected to goof this up, but it worked on the first try.
>>
>>107444659
with how this year is going it won't even be a pathfinding problem, just a floodfill
and part 2 will still be easily brootable
>>
>off by one everywhere
fucking christ. finally got it.
>>
>>107441813
resultA: 1554
resultB: 450048181074

real 0m0,751s
user 0m0,718s
sys 0m0,033s

ok I guess
>>
>>107444033
welcome to regex
>>
>>107444659
Given they'll be the only weekend problems we'll be getting this year, I can only hope they're something absolutely brutal.
>>
>parse input
>merge intervals
>binary search ingredients
>sum range bounds

>can skip the merge and do linear search and it still werks
>no interesting approaches

Worst day so far?
>>
>>107445342
what? it was bad but its still the best so far, every other one was spoonfed to you with no traps whatsoever, this you had to at least think about because you cant broot part 2
>>
File: day05emu.webm (117 KB, 608x654)
117 KB
117 KB WEBM
This ended up taking longer than I expected.
The headache I have had all afternoon and evening probably didn't help.
I'll post code and run on hardware tomorrow.
>>
File: file.jpg (130 KB, 1600x800)
130 KB
130 KB JPG
if i do one more puzzle, it will have been the farthest away from good puzzles i'll have ever been
>>
File: file.png (29 KB, 200x83)
29 KB
29 KB PNG
>>107445437
I don't think there will be a second half, mr frodo
>>
File: aoc_day5_washed.png (198 KB, 616x919)
198 KB
198 KB PNG
>>107441813
1554
450048181074
229ms

>>107443706
717551
4342208387770361
191ms

Washed and I'm done
>>
File: 5.png (160 KB, 935x1294)
160 KB
160 KB PNG
>>107445365
>you cant broot part 2
you sure can
>>
File: fatretard.jpg (439 KB, 1800x1801)
439 KB
439 KB JPG
>>107444413
>using fatretard's font
>>
>>107445365
Best puzzle was the O(1) solution with divisors 111111, 10101, 1001 etc. The more you thought about it the better a solution you could make. Here you come up with range merge and binary search (both so obvious anyone who's not a complete beginner will do them automatically) and you're done. Zero depth.
>>
>>107445555
whats the point when its easily solvable without bothering with that shit
>>
>>107445479
turns out you can shave off 10ms with flat.extend([s, e + 1])
>>
>>107445570
If you don't enjoy puzzle solving for its own sake, why are you here?
>>
>>107445587
>cant answer
nice try faglord
>>
>>107445595
Would your ideal puzzle be 1+1 since that's easily solvable? Fucking retard.
>>
>>107445638
sounds like your ideal puzzle, you can invent some complicated way of solving it
think of all the possibilities
>>
>>107443521
tru dat
the seeds from one of the previous years was more fun
>>
File: rape_me.png (220 KB, 1074x1918)
220 KB
220 KB PNG
blown away that i just 1 shot this, part 2 was so easy to get to from my part 1 >>107444611
>>
File: d05.png (136 KB, 880x937)
136 KB
136 KB PNG
I am trying to write more idiomatically.
>>
File: 5.png (1.66 MB, 5708x6702)
1.66 MB
1.66 MB PNG
>>107441813
373ms

>>107443706
196ms
>>
File: day5.png (502 KB, 1230x2074)
502 KB
502 KB PNG
>>107443904
>>107443961
Functional programming is bending my mind. I got stuck while implementing the range merge stuff. I should've also do binary search instead of linear but I am done for today.

Would you Haskell anons tell me that if I am doing anything bad? Any bad practices I should avoid?
>>
>part2 works on bigboy
>doesn't on real input
give me an edge case or two to test
>>
>>107446141
which bigboy though? the first bigboy is retarded.
>>
>>107446141
when two ranges love each other very much and have a special hug
>>
>>107443393
If you pushed code like this to a real project I'd fire you on the spot
>>
>>107446086
First anon here, realized much later but use Data.Text instead of String. Cut down bigboy from 12.6s to just under 5s. It's mental.
>>
>>107446232
you haven't seen my Core Java yet
>>
File: 1640648755256_.png (600 KB, 975x847)
600 KB
600 KB PNG
so how about eric just hide top 100-500 and group them under <500
and then show the leaderboard position for the remaining >=500 ?
>>
>>107446471
>he is a >= 500 shitter
lol, go back to flipping burgers
>>
so what bigboy is the canon one?
>>107443706
this?

Part1 717551  Part2 4342208387770361

________________________________________________________
Executed in 133.46 millis fish external
usr time 98.30 millis 0.48 millis 97.82 millis
sys time 35.03 millis 1.43 millis 33.60 millis
>>
>>107446471
uh oh I might have inadvertently given no-silver-anon ammunition here
>>
>>107446494
if you have nothing nice to say you can just not post anon
>>
>>107446512
if you can't handle the banter, go back to r*ddit
>>
>>107446521
you are the brainlet here
masking top 100-500 would decimate llm-shitters while still telling you approx how you performed regardless of which group you were in
>>
>>107446521
>>107446534
I think the problem here is I was too abstract and said the threshold could be anywhere from 100-500
so you had some impotent tardrage insta-latching onto 500 for whatever reason
>>
>>107446155
I tried the first one. The second one correctly breaks on part two.
>>107446170
part2: source_part2.cpp:62: int main(): Assertion `ranges[i].second < ranges[i + 1].first' failed.

now that's a starting point. looks like in some cases it fails to correctly merge overlapping or adjacent ranges
>>
>>107446562
The first one reduces to a single range after (correctly) merging.
>>
>>107446497
sometimes stars are gold; sometimes stars are silver

>>107446562
what happens when these two ranges love each other very much?
(123, 456) (457, 8910)
>>
>>107446593
That's obvious, I've got a mistake somewhere in the merge-and-erase sequence
>>
Does anyone have a solution like you add all the start and end points as well as the food indexes to one big array and you do a line sweep algo over it and get both parts in 1 iteration? The thing I couldn't figure out is if you encounter multiple starts you can just skip the next start you see, but what do you do when you encounter multiple ends?
>>
>>107446636
ok, I've got it. In some cases I picked the wrong iterator after erasing vector element.
>>
>>107446381
If I had to work on a Java project I'd quit on the spot
>>
vscode cant do something so very simple. i cannot click the run code button and have it run my script in an external terminal. no matter what, it always runs the script in a new terminal attached to the bottom of the editor. fucking jeets man
>>
4chan cant do something so very simple. i cannot click the submit post button and have it download my post as a text document. no matter what, it always sends the post in a new <div> attached to the website.
>>
>>107445479
can you time idiomatic rust anon's solution on your machine?

I might try radix sort. c23 anon has the cutest solutions <3
>>
>>107446926
theres this shit too
https://github.com/microsoft/vscode-python/issues/10130
https://github.com/microsoft/vscode-python/issues/11812
>more than 5 years without fixing this fucking shit so you can configure the command that is used when you run code
what a joke
>>
File: 1745309445061180.png (57 KB, 683x743)
57 KB
57 KB PNG
>>107446653
You mean like this? It just werked for me.
>>
File: vim-slime.gif (75 KB, 488x186)
75 KB
75 KB GIF
>>107446889
I know this is probably not the answer you're looking for, but if you're using vim or emacs you can do a SLIME REPL. There's plugins for it, but you can also do it manually with screen or tmux and sendkey commands.
>>
>>107446653
You'd have to sort the array for the sweep to be meaningful. It'd work but it's a slightly more complex version of sorting both individually and doing a linear pass.

>if you encounter multiple starts you can just skip the next start you see, but what do you do when you encounter multiple ends?

Keep a counter. +1 for each start, -1 for each end. If the counter is positive you're in a range, if it's negative you made a mistake.
>>
>>107445519
I don't fully understand what you are doing in the N==2 block but this just seems like merging intervals, except in O(n^2) instead of O(nlogn)?
>>
>>107445555
How is that O(1) when it depends on the length of the ID? Should be O(log(n) * other factors for testing different patterns that multiply to 11111 10101, etc)
>>
File: rape_me.png (88 KB, 929x947)
88 KB
88 KB PNG
part 1 very easy
>>
>>107446495
nice time. post code. I can't seem to bring it down. could be a zig issue because it's essentially the same as everyone else's
>>
gusie
>>
>>107444377
post code
>>
>>107447066
The solution itself was closed form. You didn't have to test numbers or even generate them. Like how you can add the first million numbers in your head with n * (n + 1) / 2
>>
>>107447115
can you post the solution? I also derived the math-y solution but it was O(log^2(id))
>>
>>107446980
[1554, 450048181074] times are identical
[717551, 4342208387770361] theirs is ~20ms faster
>>
>>107446994
Woah that's cool thanks! Man that's way more clever than I had imagined. You don't have to care if one range is inside another because of the stack_diff interesting. Okay hypothetical, could you just throw the ingredients into your ranges array and then do something like this and just have 1 big array?
if stack_diff == 0: # meaning its a ingredient
if stack: # check if currently inside a range
silver += 1
>>
>>107447008
Ahh yes thanks! I think that's pretty close to what other anon posted actually.
>>
It's Friday which means weekend
Hope he tries to filter me tonight
>>
>>107446889
>>107447000
https://marketplace.visualstudio.com/items?itemName=nvbn.sendtorepl
oh I think this is what you want probably?
>>
>>107447095
based on the other codes, my guess is the part1 is slowing a lot of people down. bin search is optimal in O, but so is sort and advancing the ranges iterator like I do. That's my guess anyway.
fn parse_input(i: &str) -> (Vec<(u64, u64)>, Vec<u64>) {
let (ranges, ids) = i.split_once("\n\n").unwrap();
let mut ranges = ranges
.split_ascii_whitespace()
.map(|line| {
let (start, end) = line.split_once('-').unwrap();
let start = start.parse::<u64>().unwrap();
let end = end.parse::<u64>().unwrap();
(start, end)
})
.collect::<Vec<_>>();
ranges.sort_unstable();
ranges.dedup_by(|(rhs_s, rhs_e), (_lhs_s, lhs_e)| match rhs_s.cmp(&lhs_e) {
Ordering::Less | Ordering::Equal => {
*lhs_e = *rhs_e.max(lhs_e);
true
}
Ordering::Greater => false,
});
let mut ids = ids
.split_ascii_whitespace()
.map(|num| num.parse::<u64>().unwrap())
.collect::<Vec<_>>();
ids.sort_unstable();
(ranges, ids)
}

fn main() {
let input = read_input().unwrap();
let (ranges, ids) = parse_input(input.trim());
let mut range_i = 0;
let part1 = ids.iter().fold(0, |acc, id| {
while let Some((s, e)) = ranges.get(range_i) {
if id <= e {
return acc + u64::from(s <= id);
} else {
range_i += 1;
}
}
acc
});
let part2 = ranges.iter().map(|(s, e)| e - s + 1).sum::<u64>();
println!("Part1 {part1} Part2 {part2}");
Ok(())
}
>>
>>107447148
Something like that should work, as long as you adjust the sorting logic to make ingredients sort behind all stack adjustments at the same position.
>>
Still really not that hard. I'm sure there is some big brain way to squish the intervals down faster, probably union-find but I didn't want to pull out a book to shake off the rust to do that.
>>
>>107447040
yes
how worse can it be?
>>
>>107447214
also I think the rust binary search methods compile to cmov on x86 because they use the weird unlikely hints.... which probably hurts a lot.
>>
>>107447251
https://doc.rust-lang.org/src/core/slice/mod.rs.html#2958

ya... harrowing. idk why they do this.
>>
>>107447141
thanks! I was mainly interested in learning how good dedup_by is. seems to be the correct choice since it works inplace without any allocations

>>107446994
very cool, anon

>>107447214
great. I will try this too. yes, binary search is awful in practice due to jumping all over the place

>>107447245
generating a set of all the IDs. kek
>>
File: 1748289671573137.png (42 KB, 483x950)
42 KB
42 KB PNG
>>107447207
thank you, i appreciate it. i settled on this code runner extension outputting to the output panel which i docked on the side, it does basically what i wanted in a slightly different way
>>
File: filter_day.png (3.24 MB, 1024x1536)
3.24 MB
3.24 MB PNG
I feel it in the air! Today is the filter day boys! Don't forget to tie your shoelace algos.
>>
File: broot.png (61 KB, 646x439)
61 KB
61 KB PNG
>>107447282
>generating a set of all the IDs. kek
that was the first thing I tried for p1, which also would've solved p2 at the same time.
It did work fine for the example input...
>>
>>107447251
>>107447267
If there isn't any pattern as to what you're searching for, cmov is probably faster because with branches you will eat a misprediction 50% of the time.
But cmov doesn't allow for prefetching. So if there IS a pattern, branching has advantages.

To get the best result, you can use an Ahnentafel and manually add prefetch hints, it's pretty neat.
https://algorithmica.org/en/eytzinger
>>
>>107447282
>thanks! I was mainly interested in learning how good dedup_by is. seems to be the correct choice since it works inplace without any allocations

Comparing the times for each section, since they do broadly the same thing, yours (or whoever wrote >>107443396) is

>faster at sorting
>slower at merging and binary search
>>
>>107447495
PS I'm a retard, I forgot to include the file read time:

 --- other solution ---
read: 19.739554ms
split: 13.132664ms
range parse: 111.090129ms
sort: 69.627239ms
merge: 6.019997ms
binary search: 20.510832ms
[1554, 450048181074]
total: 240.675849ms

--- my solution ---
read: 19.327935ms
split: 12.744698ms
range parse: 108.71537ms
sort: 75.968226ms
merge: 3.127513ms
binary search: 19.806386ms
1554
450048181074
total: 240.600629ms


and

 --- other solution ---
read: 11.113093ms
split: 5.864627ms
range parse: 45.625202ms
sort: 21.018846ms
merge: 2.514642ms
binary search: 113.78451ms
[717551, 4342208387770361]
total: 200.212241ms

--- my solution ---
read: 11.020505ms
split: 5.584566ms
range parse: 45.215034ms
sort: 23.173684ms
merge: 2.160426ms
binary search: 112.152005ms
717551
4342208387770361
total: 199.512111ms


So pretty much identical. Which isn't surprising when they're so similar.
>>
if you implemented binary search for this you are a try hard faggot
>>
>>107447539
Not a problem for Rustchads where the language has builtin partition_point
>>
if you implemented binary search you are a try hard.
>>
i implemented poop sort, i paid an indian to do it for me
>>
>>107447563
what time complexity is poop sort
>>
>>107447219
>Something like that should work, as long as you adjust the sorting logic to make ingredients sort behind all stack adjustments at the same position.
Wow okay so you were right it works, but it definitely needs that third variable for sorting. Thanks! I feel slightly smarter for understanding it!

data = """
3-5
5-14
16-20
16-20
17-19
12-18
1
2
3
4
5
"""
ranges = [[int(x) for x in row.split("-")] for row in data.strip().splitlines() if "-" in row]
ids = [int(x) for x in data.strip().splitlines() if "-" not in x]
combined = sorted(
[(x,0,0) for x in ids] +
[(x[0],-1,1) for x in ranges] +
[(x[1]+1,1,-1) for x in ranges]
)
stack = last_pos = 0
s = g = 0
for pos, priority, diff in combined:
if diff == 0 and stack > 0:
s += 1
if stack > 0:
g += pos - last_pos
stack += diff
if stack > 0:
last_pos = pos
print(s,g)
>>
>>107447563
dis nigga don't even know 'bout Crime Sort
>>
Whelp, looks like I'm getting filtered on part 2 today.
>>
>>107447728
anon just draw the demo on a piece of paper
>>
File: 1700746747438532.jpg (89 KB, 1208x620)
89 KB
89 KB JPG
>>107447563
>pajeet celebration day
>gives free meals in several coastal cities
>each city has a determined amount of curry per dish
>wait 96h
>take satellite screenshot
>>
>>107447792
Isn't this just the 2004 tsunami?
>>
>>107447639
>>107447219
Oops I fucked up ID's need a priority of 1 or 2 to be sorted correctly not 0. I'm going to explain it because I think its super clever, but took me a while to understand how it works.
ranges: 3-5
ids: 3, 6
combined.sorted() = [
(3, 0), # id 3
(3, 1), # range 3-5 starts
(6, 0), # id 6
(6, -1), # range 3-5 ends (5+1)
]
combined.sorted(with_priority) = [
(3, -1, 1), # range starts first now
(3, 2, 0), # then id checked
(6, 1, -1), # range 3-5 ends
(6, 2, 0), # id 6
]
>>
>>107447827
:( oh my god. I typo'd the explanation too. im ngmi
>>
>>107447435
ehhh
https://github.com/llvm/llvm-project/issues/39374
idk bro. even in real life data, my guess is bin search has more of a pattern than people realize.
>>
>>107447728
collapsing the ranges is extremely trivial, how are you getting filtered?
>>
>>107447889
sorry..... wrong link. I can't find it now. someone did some benches of it recently, or at least I thought.
>>
Does anyone remember the question / year about ranges where it was like a dynamic programming question with ranges that kept getting smaller and smaller or something. I got filtered on it, but I think I'm smart enough to solve it now. Maybe! Probably....
>>
>>107447827
You don't need triples. Just (value, kind) pairs where kind can be 3 values (Open, Ingredient, Close). kind will be used to sort in tiebreaks, make sure whichever standard you use is consistent. For closed intervals Close must come after Ingredient, if you switch to half-open intervals Close must come first.
>>
>>107447944
2023 day 5? Wasn't really dynamic programming, though.
Funny that this also was a day 5, except significantly more difficult and with twice as many days.
>>
>>107447646
>Crime Sort
how do that work and shiet?
>>
>>107447944
>it was like a dynamic programming question with ranges that kept getting smaller and smaller or something. I got filtered on it

This sounds like a nightmare you'd have after spending too much time in /aocg/ threads
>>
>binary search
y'all niggas need to try
https://docs.rs/itertools/latest/itertools/fn.merge_join_by.html

if you already sort IDs and fresh ranges, my guess is using this iterator adapter is faster.
>>
>>107447974
https://en.wikipedia.org/wiki/Selection_sort
gibs me dat smallest element
>>
>>107447944
2023 05 ?
>>
>>107447728
you mean that your code is taking 11 minutes and 41.8s on the bigboy, right?
there's no shame in that!
probably lots of really good guys solved part 2 like that!
>>
File: phone.png (687 KB, 1280x720)
687 KB
687 KB PNG
tomorrow is trash squirrel recycling/sorting day hope you are ready
>>
>>107447894
I never do leetcode stuff, my job doesn't require this kind of things and I only had boring webshit in uni
>>107448027
First try ended being slow as shit, so I decided to do it properly by filtering out overlapping ranges and calculating the correct one.

Now the stupid part: I actually had the correct algorithm for filtering when I made that post, but I forgot to remove some retarded check when counting the result that made it so it did not count ranges with an equal start and end. I only realized that after I copied some algorithm I found on the internet and it gave me the exact same incorrect result.
So I guess the filter has not gotten me yet.
>>
>>107443347
wow, samebrain
>>
>>107448027
Yep, that is me. I dd this: >>107447225
I just stopped it after the big boy took longer than 10 seconds. What is the smart way to do it to get the subsecond times on the big boy like you guys?
>>
lmao my solution is so shameful. advent of shame
i basically do 2 passes to merge everything. but well, it works
>>
File: carbon(5).png (413 KB, 1498x2478)
413 KB
413 KB PNG
200ms on the bigboy. 1/3 is parsing. 2/3 is sorting.
>>
i merge overlapping ranges, this was the intended solution.
>>
>>107447814
I hadn't even noticed...
>>
>>107447944
2021 Day 22 maybe?
>>
Couldn't figure out day 4 with haskell, so did it in hideous C code, this is day 5. I am still learning haskell, open to criticism.
>>
File: brightidea.png (117 KB, 1143x1031)
117 KB
117 KB PNG
chat I had my biggest fukken brainfart just now
I thought
>hmmm there are far less than maxint() ranges
>lets use a single bitmask instead of an array of bools to keep it in memory
>it should be blazing fast

turns out even though you can represent pretty big numbers with 32bit ints it is hard to represent more than 32 bits of state that way
>>
>>107447814
Least resistant path or something.
>>
File: wordswordswords.png (130 KB, 878x595)
130 KB
130 KB PNG
what is this style of writing and why do I hate it so much?
>>
>>107448917
sardonic youtuber script
or grammatically correct greentext story from /b/ without the cringekino charm

I was fine with it until the hot garbage line
>>
File: Day5_2025.png (204 KB, 1194x970)
204 KB
204 KB PNG
>but you neeeed to merge the ranges
>but you neeeeeed to implement a binary searching algorithm
>but you neeeeeeeed to use a memory-safe type-safe language

No, actually. I don't.
>>
>>107448966
You don't have to if you don't want to
>>
File: rape_me.png (137 KB, 1039x1376)
137 KB
137 KB PNG
i got stuck on the else case for a long time as in i wasnt even checking it and then i forgot to sum the current range at the end. also shit program cut off the bottom of my screenshot gg
>>
>>107448966
Python is memory-safe and type-safe.
>>
File: times.png (33 KB, 284x437)
33 KB
33 KB PNG
Any anon thinks they can beat these bigboy times, step on up
>>
i cant even read most of these programs you guys are posting. feels bad
>>
>>107449198
to be fair a lot of them are in fairly obscure languages or are written in goofy ways
>>
>>107449240
my code looks like a high schooler wrote it compared to most of this arcane shit. i'm not educated
>>
>>107449198
to be fair a lot of them are written in Python, an infamous write-only language that encourages pointlessly obscure code.
>>
>>107449198
Prior to 2023 I would always tell people that it didn't matter if their code "looked basic" because it all compiles/interprets down to similar instructions on the CPU but now I can also say that it doesn't matter if your code "looks basic" because AI can shit out code faster than any of us, no matter how we type.
>>
>>107449261
aoc is a great way to grow
or trying out new stuff

although it does take having a lot of sparetime to go at aoc with a completely uncharted territory language so there is that
>>
>>107445555
>binary search
no guarantee the ranges are sorted :^)
>>
>>107447066
It would be O(log(n)) only if the numbers are arbitrarily large.
>>
>>107449365
they are after you merge them, dimwit
>>
File: 1733801519961953.png (59 KB, 478x360)
59 KB
59 KB PNG
what about that kino moment with the rotation code (I think it was beacons)
but whoever posted the rotation code that a huge chunk of the thread copy-pasted had a bug in it
and it took hours before anyone noticed the reason it was not working was that the rotations were bugged
>>
Hey /g/, you introduced me to AoC in 2019 and I just wanna let you know, I'm really glad that you are all here and I'm thankful that I got to spend time with you over the years. I read some reddit comments earlier, and the snarky midwit tone they all had made me really appreciate this little shithole of ours.
>>
>>107449198
Most of these solutions are actually optimized for inscrutability, if inadvertently.

I mean, just take a look at this heap of shit >>107447360

Do you really think anyone can actually read that?
>>
>>107449452
I love you too anon. Enjoy! More Christmassy puzzles coming.
>>
>>107443386
which model vibes the advent best?
>>
>>107449017
are those single-threaded times? I can do 105ms on that bigboy if I use tbb::parallel_sort on my 4 coffee lake cores
>>
>>107449448
for me? it's the elephant valve day when even the "pros" didn't have a solution after 7 minutes and then some anon just accidently solves it and it takes another 15 minutes for someone else to get on the board
>>
>>107449313
Python is easily the most readable language being used in this thread. What's your idea of a readable language?
>>
>>107449471
which ai will win out supreme?
>>
>>107449328
Prior to 2023? What happened?
>>
File: day5.png (270 KB, 810x1710)
270 KB
270 KB PNG
elixir day5.exs
Part 1:
Time: 46ms - result: 789
Part 2:
Time: 3ms - result: 343329651880509

Thoughts? Lots of lines of code compared to other solutions here. This is my first time doing AoC.
>>
File: day05.png (808 KB, 2199x2796)
808 KB
808 KB PNG
>>107445367
The code for this.
I realized I was being dumb with my ascii converter and forgot what I learned with 6502, you can do a multiple by 10 with a couple of shift lefts and an addition.
>>
File: sam-altman-openai.jpg (98 KB, 931x523)
98 KB
98 KB JPG
>>107449728
>>
File: 20251206_064230228.webm (1.17 MB, 853x480)
1.17 MB
1.17 MB WEBM
>>107449806
Seems if I run day1 before running day5 it works just fine. Not sure what's going on with the recent days that don't want to run cleanly on hardware.
>>
>tfw good at advent of code
>tfw side projects
>can't get out of being a shit admin
I'm sick of waging as a computer janny bros.
>>
>>107449816
Never used AI so I never thought of it
>>
>>107449511
Yup, single threaded. Is your code itt?
>>
>not very good at advent of code
>one side project
>unemployed
Wish I was a computer janny, bros...
>>
>>107449834
Clean up my disk, jannie
>>
>>107449852
I got my job through nepotism, do you have any well connected family members?
>>
>>107449834
try applying to the AOC sponsors for a dev job, they might appreciate it
>>
>>107449861
No but my sister is dating a richfag.
>>
File: 2025-12-05 170428.png (45 KB, 596x562)
45 KB
45 KB PNG
I'm upset I didn't finish this before going to bed last night
>>
File: 8gscja.png (60 KB, 250x211)
60 KB
60 KB PNG
>>107449859
You joke but this actually happens to me. For some reason the work machines accumulate %temp% garbage and even though I'm not a desktop support cuck, I still end up having to do it (because I have a desktop support account as a shitadmin for some reason).
Pic related though.
>>
>>107449927
Cool.
Just do it.
Thanks
>>
>>107449483
>Should I use AI to solve Advent of Code puzzles? No. If you send a friend to the gym on your behalf, would you expect to get stronger? Advent of Code puzzles are designed to be interesting for humans to solve - no consideration is made for whether AI can or cannot solve a puzzle. If you want practice prompting an AI, there are almost certainly better exercises elsewhere designed with that in mind.
>>
>>107450169
If I send someone I bought off a boat to pick cotton for me, who's the real weak person, and who's the real strong person? The master, of course.
>>
>>107450183
You're not going to get any better at picking cotton if you don't practice
>>
File: aocday5gptreview.png (328 KB, 784x2012)
328 KB
328 KB PNG
>>107449467
>take a look at this heap of shit
that's throwaway code. Actual solution is >>107444413 which is more dense than I would write real code, but still very readable.
>>
>>107450183
Look at the state of American culture right now. Do you really think that's how it works, nigga?
>>
>>107450241
>the always-validating delusion machine says I'm cool :)
tell it that you just found someone else's shit code and you need help explaining why it's so repulsive to you
>>
>>107450231
lmao
>>
>>107449927
Feel sorry for you. Honestly, I do. I've had enough of management myself. They don't know shit so they can't tell when someone knows enough shit to do a job.
My wife studied computer engineering and has a masters in it, and at the university she was expected to simply learn a new language for a course because that was the language that particular course admin wanted for that course (not deep knowledge, but enough to program in). No intro material, no tutorial, nothing, just "you're going to program in this dialect of C" and that was that. And she did it. Then at work she learnt new langs for new assignments on the fly, new frameworks when they were brand new and barely even had any questions on stack overflow.
But now she's been struggling to get new assignments in because they have a demand for C# devs but for whatever reason she has been pigeonholed into Java (including Javascript, I shit you not, they can't tell the difference), and at the same time they take in morons from bootcamps who's maybe looked at C-something once and therefore definitively knows everything there is to know about C#. Doesn't matter that C# is just Java for Windows.
I fucking hate management. I'm management, but I try to create some sort of sane space.
>>
mod lib;
use std::cmp::min;
struct Range{
Start:usize,
End:usize
}
struct Day5Input{
Ranges:Vec<Range>,
Ids:Vec<usize>,
FinishRange: bool

}
fn read(data: &mut Day5Input, line: &str) {
if line.len() == 0{
data.FinishRange = true;
}
else if data.FinishRange {
data.Ids.push(line.parse().unwrap());
}
else{
let (a,b) = line.split_once("-").unwrap();
let (start, end):(usize, usize) = (a.parse().unwrap(), b.parse().unwrap());
data.Ranges.push(Range{Start: start, End: end});
}
}
fn gold(ranges: &Vec<Range>) -> usize{
let mut data = ranges.clone();
data.sort_by(|a,b| a.Start.cmp(&b.Start));
let mut unions:Vec<Range> = Vec::new();
for range in &data{
let mut entry_to_add = Some(Range{Start: range.Start, End: range.End});
for union in & mut unions{
if let Some(ref entry) = entry_to_add{
let (lower, upper) = (in_range(entry.Start, union), in_range(entry.End, union));
if lower && upper{ entry_to_add = None; break; }
else if lower{
*union = Range{Start: min(entry.Start, union.Start), End: std::cmp::max(entry.End, union.End) };
entry_to_add = None;
}
else if upper{
*union = Range{Start: min(entry.Start, union.Start), End: std::cmp::max(entry.End, union.End) };
entry_to_add = None;
}
}
}

if let Some(entry_add) = entry_to_add{
unions.push(entry_add);
}
}

unions.iter().fold(0, |acc, x| acc + 1 + x.End - x.Start)
}

fn in_range(id:usize, range:& Range) -> bool{
range.Start <= id && id <= range.End
}
fn solve(mut data: Day5Input) -> (usize, usize) {

let mut silver = 0;
let mut gold = gold(&data.Ranges);

for id in &data.Ids{
for range in &data.Ranges{
// silver
if in_range(*id, range){
silver+=1;
break;
}
}
}


(silver, gold)
}


fn main() {
let inp: Day5Input = Day5Input {Ranges:Vec::new(), Ids:Vec::new(), FinishRange: false };
println!("{:?}", lib::read_then_write::<Day5Input>(read, solve, inp));
}
>>
>>107448764
Cute trick with idempotently - though I suppose sorting first is just faster
>>
>>107450183
Jew detected.
>>
2015 day 13:

Generate all possible seating permutations and calculate the score for each possible permutation. Keep a global maximum.

For Part 2 you can cheat and simply modify the input with an extra person who has score 0 towards everyone else, and towards whom everyone has score 0:

package main

import (
"bufio"
"fmt"
"maps"
"math"
"os"
"slices"
"strings"

"gonum.org/v1/gonum/stat/combin"
)

func main() {
max := math.MinInt
rules := make(map[string]map[string]int, 0)
file, err := os.Open("mod_input.txt")
if err != nil {
panic(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
s := scanner.Text()
if len(s) == 0 {
break
}
var orig, targ string
var score int
s = strings.TrimSuffix(s, ".")
if strings.Contains(s, "gain") {
fmt.Sscanf(s, "%s would gain %d happiness units by sitting next to %s.", &orig, &score, &targ)
} else {
fmt.Sscanf(s, "%s would lose %d happiness units by sitting next to %s.", &orig, &score, &targ)
score = -1 * score
}
fmt.Println(orig, targ, score)

if _, ok := rules[orig]; !ok {
rules[orig] = make(map[string]int, 0)
}
rules[orig][targ] = score
}
n := len(rules)
people := slices.Collect(maps.Keys(rules))
permutations := combin.Permutations(n, n)

for _, p := range permutations {
score := 0
for i, idx := range p {
curr := people[idx]
fmt.Print(curr + " ")
//check left
var l string
if i == 0 {
l = people[p[n-1]]
} else {
l = people[p[i-1]]
}
//check right
var r string
if i == n-1 {
r = people[p[0]]
} else {
r = people[p[i+1]]
}

score += rules[curr][l] + rules[curr][r]
}
fmt.Println()
fmt.Println(score)
if score > max {
max = score
}
}
fmt.Println(max)
}
>>
File: aocreview2.png (310 KB, 775x2157)
310 KB
310 KB PNG
>>107450287
yeah now it shittalks things it was praising before, but that's no different from the people here. If I write everything step-by-step then lisp cunts like >>107419394 complain about it, when I go super concise the pOOP heads can't follow it.
>>
File: code.png (331 KB, 1342x2708)
331 KB
331 KB PNG
Python
>>
>>107443843
>>107443865
>>107447970
>Funny that this also was a day 5, except significantly more difficult and with twice as many days.
Lol yeah holy fuck that part 2 was nuts! Man I thought I was getting smarter, but I think eric is getting softer.
>>
File: d-rust5.png (441 KB, 1934x2692)
441 KB
441 KB PNG
>>107450415
in d this is just ... too long to post in a code block.
why is d so verbose and not clean and terse like Rust?
>>
File: file.png (86 KB, 1200x1200)
86 KB
86 KB PNG
One day I won't be filtered by Factorio anymore
>>
>>107450702
https://adventofcode.com/2023/day/5
How would you do this part 2 with a line sweep? I solved it with a DFS and splitting the ranges for each map. But with a line sweep you'd have to add the seed ranges to the current map, sort them, then somehow split them. Ahh maybe its just not an ideal solution?
>>
>>107450472
would sorting really make it simpler? my problem is that when i extend a range in the list of ranges, that it may overlap with a range further in the list, so i repeat to union of the ranges until they don't change

>>107446086
>Functional programming is bending my mind. I got stuck while implementing the range merge stuff
Me too, i spend 2-3 hours on every day for elegant-ish haskell solutions, and i haven't tried day 4 with haskell at all. It feels weird to spent so much time on so few lines, knowing that i started learning the language a week ago and my code is probably illegible for an actual haskell programmer. By far the most useful resource is actually reading competent people's code.
>>
File: file.png (94 KB, 1200x1200)
94 KB
94 KB PNG
>>
>>107450786
>>107450806
elves eat... metroids?
>>
>>107450806
I wanna see the elves shooting a potato gun naked.
>>
>>107450786
>>107450806
I love you! <3
>>
>>107450806
Thank you for your service, genuinely.
>>
>>107450853
That's too lewd anon...
>>
>>107450786
>>107450806
Awesome drawings as always anon, thank you for posting
>>
>>107450883
drawanon is so good at drawing cute elves
>>
>>107446369
>Data.Text
I gave it a try. It reduced time by factor of 7. Wtf? This is the fastest bigboy I did on this machine. Thanks anon.

>>107450802
It feels like sorcery when I read other people's Haskell code. I still struggle with its syntax. But it feels very satisfying when you write something that works.
>>
>>107450907
the Haskell solutions this year haven't had as many GHC extensions as in previous years, which is a nice change...
oh.
https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/control.html
that all comes with GHC2024 now.
>>
>>107449834
Make a temp email that I'll email you at and help you with your resume. Post it in these threads and I'll see it. or post it here anonymized

t. I've hired 20 people and run a VC-backed firm at a 100mil val
>>
>>107450788
I don't think sorting overlapping ranges will help much.
The simplest solution I could come up with that did not require explicitly splitting or merging ranges was to start with an initial guess of zero. If you simulate that through the mappings, you can keep track of the smallest increment that would have led you down a different sequence of ranges. Increase the guess by that increment and repeat until you find a something that works.
>>
wait if I get drunk tonight I won't be able to focus on the problem when it's released?
>>
File: d5.png (1.08 MB, 1200x4302)
1.08 MB
1.08 MB PNG
>>107449849
Here, I've ditched tbb::parallel_sort in favor of a single-threaded radix sort and managed to tie my multi-threaded performance with it. The parsing is kinda meh and could also use some parallelization, but at this point, I just can't be bothered.
btw with a single-threaded std::sort(), it was around 300ms.

>>107441813
Silver: 1554
Gold: 450048181074

Performance counter stats for './5_radix ../../../inputs/5/bigboy.txt' (100 runs):

101,160,615 user_time ( +- 0.05% )
8,567,145 system_time ( +- 0.31% )
401,579,497 cycles:u ( +- 0.06% )

0.1098226 +- 0.0000763 seconds time elapsed ( +- 0.07% )


>>107443706
Silver: 717551
Gold: 4342208387770361

Performance counter stats for './5_radix ../../../inputs/5/bigboy2.txt' (100 runs):

54,288,664 user_time ( +- 0.06% )
5,839,393 system_time ( +- 0.41% )
215,282,457 cycles:u ( +- 0.05% )

0.0602945 +- 0.0000527 seconds time elapsed ( +- 0.09% )
>>
can someone explain cool math solution for part 2
I just collapsed all ranges to eliminate duplicates
>>
File: aoc-2023-day-5.png (405 KB, 708x804)
405 KB
405 KB PNG
>>107447944
Oofff ya I'm still not smart enough for 2023 Day 5. Literally infinite amounts of off by 1 errors. I was basically just guessing until I got it.
>>
>>107451109
lol and I sorted it for some reason. whoops.
>>
>>107450907
>It feels like sorcery when I read other people's Haskell code.
The thing is that the sorcery is written in a very consistent way, so its very fun to explore and hoogle is very useful for that. For now i just learn patterns as i see them, because the raw theory of functors, applicative, etc is just impossible to understand just by reading laws and function signatures. My haskell code is littered with snippets that use things like &&&, <*>, just because i saw them somewhere and read about the operators and i am slowly starting to integrate them into my way of thinking. Apart from hoogle i found a list of useful logical combinators and a youtube channel code_report who focuses on array programming languages like APL and on functional programming, so it is very interesting.
>>
Good luck today anons! Remember to eat healthy and try to stick to the four main food groups: candy, candy canes, candy corns, and syrup.
>>
>>107451109
>2023 Day 5
That was the closest I ever got to the leaderboard. Good times.
>>
>>107451307
If all the elves' ingredients were composed of those, they wouldn't have to worry about anything spoiling
>>
>>107450786
>>107450806
>drawanon is a factorioGOD
I fucking kneel
>>
pythonic part 1 solution
>>
File: file.png (2.98 MB, 1872x4030)
2.98 MB
2.98 MB PNG
day 2
>>
>>107451027 (me)
And here is a compact numpy version of my gold algo, which is based on range truncation instead of merging / collapsing. It solves the first bigboy in 0.8 secs, but sadly, it doesn't help you with silver.
import sys
import numpy as np
dr, di = open(sys.argv[1]).read().split("\n\n")
dr, di = np.fromstring(dr.replace("-","\n"), sep=" ", dtype=int).reshape((-1,2)), np.fromstring(di, sep=" ", dtype=int)
dr = np.sort(dr, axis=0)
print("Silver: ", ...)
print("Gold: ", (np.minimum(np.concat((dr[1:,0], [np.iinfo(dr.dtype).max])), 1 + np.maximum.accumulate(dr[:,1])) - dr[:,0]).sum())
>>
>>107451345
Woah nice! How'd you solve it? I remember I needing a lot of /g/ hints.
>>
>>107451620
>>
File: day5_image.png (1.17 MB, 1374x2775)
1.17 MB
1.17 MB PNG
>>107451720
I was trying out Nim that year. Though I think I hacked some garbage python together to solve it fast, then rewrote it as picrel. I remember essentially keeping a queue of ranges to be transformed and iterating until it was empty.
>>
>>107451819
A better version, where I left helpful comments to myself: https://gist.github.com/erk52/d0815054efa66def27f9f9aaceacdd2d
>>
File: day5go.png (160 KB, 1253x1183)
160 KB
160 KB PNG
Baby's fourth Go program, gets 265ms on >>107443706.
I used Fscanf at first and that was waaay slower, took 1.8 seconds.
>>
>>107448137
wtf creepy
>>
>>107451620
>>107451744
part 2 pythonic solution
>>
File: day5perf.png (76 KB, 1446x600)
76 KB
76 KB PNG
>>107452097
Any gotards here know how to make the sorting faster? It spends 80% of that 265ms sorting.
>>
>>107452119
jesus christ
>>
>>107452119
niggerlicious
>>
File: file.png (82 KB, 653x1080)
82 KB
82 KB PNG
day 3 rust
>>
File: P2eLnxh.jpg (97 KB, 1280x800)
97 KB
97 KB JPG
>>107451819
>sneeds
kek. thanks edward!
>>
File: day5stretch.png (2.29 MB, 8769x996)
2.29 MB
2.29 MB PNG
>>107452119
With puzzles so shitty, sometimes you have to make your own fun. day 5 part 1 and 2
>>
>>107452642
Can't you put a semicolon after the import statement to make the whole thing a true one-liner?
>>
>>
>>107452745
I wonder if there's a single biological female on that list...
>>
>>107452787
there is
>>
>>107452695
>semicolon
>a true one-liner
do you even english, rajesh?
>>
>>107452817
Daily reminder that while you can cut off some things, you cannot cut off your Y-chromosome.
>>
>>107452856
No need to get snippy sir. Just trying to help a newbie out

>key=lambda item: item[0]
No need for that either :)
>>
>>107452912
i agree with you
>>
File: carbon-2.png (502 KB, 1784x2718)
502 KB
502 KB PNG
final wash before day 6, not good enough for the bigboy(s)
>>
>not a single ONE HOUR poster on Day 5

Unbelievably grim. Christmas is ruined
>>
>>107450786
>>107450806
based
>>
>>107452994
>resorting the array for every line of the input
>doing O(NM) instead of sorting the ids
Congrats, you have proven that Python beats C++.
>>
if day 6 isn't brutal aoc is done.
>>
>>107453119
eric did this
>>
eric is literally the grinch who stole christmas
>>
rape and murder eric
put eric in a saw trap
steal eric's gold and silver stars
>>
Tonight is going to be a bloodbath.
>>
All he had to do was ask for help ahead of time. There are literally thousands of people that would have volunteered. Instead he chose to slack off all year and ruin christmas for hundreds of thousands of people for whom (let's face it) this is probably the highlight of the season.
>>
>>107453236
Okay you took it too far. Stealing his gold stars is one thing, but the silver stars too?? Some punishments are TOO cruel and unusual, you know?
>>
>>107453124
>>resorting the array for every line of the input
it sorts the array when it hits the blank line separating the ranges and ids, which only happens once
>>doing O(NM) instead of sorting the ids
ok you're right i probably should've done that
>>
>>107453250
The highlight of the season is firing up my snow blower and clearing my driveway.... simple things.
>>
>>107453256
he should have thought about that before keeping to himself 26 stars he owed, including 13 silver stars

>>107453250
/g/ can replace him
>>
>>107453250
Every aoc ripoff problem not written by Eric is lame and gay and soulless
>>
>>107453287
Everybody codes was pretty good this year.
>>
20 minutes or something
>>
can eric delay the release? i need to poop
>>
>>107453300
>>107453355
two double doubles in a row
today's the day fellas
>>
>>107453363
>a double double double
blessed
>>
>>107453366
fuck
>>
>>107453366
>triple double double
wtf
>>
File: day5stretch.png (2.39 MB, 8760x996)
2.39 MB
2.39 MB PNG
>>107452695
feels like cheating
>>107452945
so true
>>
Woah, we're half way there.
>>
Alright Eric, you've made enough donation bucks from the fools on reddit. You've roped in the rubes by giving them a false sense of accomplishment, in turn they paid you well because they felt fuzzy. Now is the time to drop the hammer: They need to be... reminded.
>>
death to eric
>>
File: WALL_INCOMING.jpg (157 KB, 462x260)
157 KB
157 KB JPG
TONIGHT'S THE NIGHT
>>
>>107453391
the elves need you to convert the letters in your input to numbers (A = 1, B = 2, etc.) then add them together. case insensitive
part 2: ACTUALLY the lowercase letters have different values (a = 26, b = 27, etc.), uppercase stays the same. NOW can you add the letter list?
>>
>>107453401
good to see you here
>>
>>107453406
and you as well
>>
File: thewall.jpg (190 KB, 1280x720)
190 KB
190 KB JPG
>>
>>107453405
Damn, I'm filtered
>>
>>107453379
That captcha is obviously intentional. Just how deeply has numoot embedded AI into this website? How long has this been going on?
>>
AoC++ guy here:

>The elves have discovered that someone amongst them has done racism! They have a clue about their ID but they need you to check. Of the following sets of digits, how many have an even number of even numbers?
>>
>we'll never have a cool crt racing the beam puzzle ever again
bros idk if i can go on
>>
Of the shit we've had so far, grid problems are the most fun.
If we're getting another simple one I hope it's a grid.
>>
its djikstra.
>>
It's out https://adventofcode.com/2023/day/6
>>
>>107453425
that one was kinda hard
>>
>>107453414
thanks, i lost this image on an old hard drive and couldn't find it
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
www.youtube.com/watch?v=hjGZLnja1o8
>>
>>107453444
cancer music
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>
Guys.... I have to shit!
>>
>>107453444
triples music
>>
>>107453424
how is this possible without bruting using a for loop from 1 to the digit? start at odd, increase by 1 to set to even, increase by 1 to set to odd, until you reach the digit
is there some math trick I need to know? I thought this was advent of code not advent of math.
>>
>>107453444
CHECK'D
>>
>>107453444
>14 years ago
>>
good luck everyone
popping a snus
see you on the other side
>>
>>107453455
>daylight is fading away
>>
File: 1683660687992506.jpg (481 KB, 663x921)
481 KB
481 KB JPG
in the square hole
>>
If I can complete this within the hour Eric has failed me.
>>
>>107453444
1 2 7 3 !
>>
Today I WILL get a good time.
>>
TONIGHT it is SHOWTIME
>>
>>107453405
diabolical puzzle because Z and a have the same value
a J solution would be +/b i. if not for that
>>
weekend puzzle so it's going to be hard, r-right guys?
>>
wtf! waited an hour for this and puzzle is still not released. goodnight folks
>>
it's going to be day 1 difficulty again
>>
FUCK
>>
>>107453472
it's going to benefit from recursion and a cache
>>
the great filter
>>
FUCK
>>
FUCK
>>
File: image.png (2.75 MB, 1024x1536)
2.75 MB
2.75 MB PNG
>>
>parsing columns
>>
ah yes, the advant of parsing day
>>
Wait, this one is actually just parsing
>>
>>107453487
>>107453498
can't be, there aren't even any tricks:
$ perl -lane 'print scalar @F' input
1000
1000
1000
1000
1000
>>
>part 2
what the fuck am i reading
>>
File: dance.gif (402 KB, 544x384)
402 KB
402 KB GIF
>https://files.catbox.moe/tuevnx.mp4
PART 2 TIME
>>
>part 2
holy fucking mother of parsing
>>
>pt1 works on test but not input
oh no
>>
fresh off the shitter part 2 code (part 1 is lost)
# *** advent of parsing ***
inp = open(0).read().strip().splitlines()

nums = []
for col in range(len(inp[0])):
build = ""
for row in range(len(inp) - 1):
if inp[row][col] in "0123456789":
build += inp[row][col]
nums.append(build)

operators = inp[-1].split()

p1 = p2 = 0
tem = int(nums[0])
j = 0
for i in range(1, len(nums)):
if nums[i] == "":
p2 += tem
tem = ...
j += 1
continue
if tem == ...:
tem = int(nums[i])
else:
if operators[j] == "+":
tem += int(nums[i])
if operators[j] == "-":
tem -= int(nums[i])
if operators[j] == "*":
tem *= int(nums[i])
if operators[j] == "/":
tem /= int(nums[i])
p2 += tem

print(f"silver: {p1}, gold: {p2}")
>>
*yawn*
>>
File: code.png (463 KB, 1958x2344)
463 KB
463 KB PNG
Day   -Part 1-   -Part 2-
6 00:09:40 00:15:46

holy mother of jank
>>
*fart*
>>
>>107453580
Day   -Part 1-   -Part 2-
6 00:06:06 00:15:16

(>>107453570)

you almost caught me, anon
i guess you're at the top of the leaderboard right now?
>>
THAT STILL WASN'T HARD
IT WAS JUST A SLIGHTLY ANNOYING PARSING PROBLEM
YEAAAAARRRGGGHHHHHHHH I'M GONNA LOSE IT
>>
>>107453592
i didnt join leaderboard because im on a work one with names up
dont want to namefag on /g/ board
>>
>>107453596
sad, glad you're in these threads though
/g/ seems to not be very good with computers
>>
holy fuck, this nigger can't be serious. aoc is so shit nowadays goddamn.
>>
>>107453607
>filtered by appending digits in a line
>>
>>107453604
my solution is ugly as shit though i wonder what the nice way to parse this retarded thing is
>>
>>107453461
I completed it within the hour. Eric has failed me.
>>
>>107453612
persumably you can hide the ugliness by calling something to rotate the grid and reusing most of the part 1 code
>>
>>107441364
was this true after all?
>>
File: 1734857416215969.png (27 KB, 407x446)
27 KB
27 KB PNG
import numpy as np

data=np.array([[*l] for l in open("input.txt").read().splitlines()])
data=np.rot90(data)

nums=[]
cur_nums=[]
for line in data:
line = ''.join(line[:-1])
if line==' ':
nums.append(tuple(cur_nums))
cur_nums=[]
else:
cur_nums.append(int(line))
nums.append(tuple(cur_nums))

ops = open("input.txt").read().splitlines()[-1].split()
r=0
for o in ops:
if o=='+':
r+=sum(nums.pop())
else:
r+=np.prod(nums.pop())
print(r)
>>
>>107453631
i think so
>>
>original spacing matters in part 2
oh fuck this parsing bullshit
>>
>memory prices sky high
>aoc too easy
everything turns to dust
>>
>>107453648
that's where i'm fucked, how the fuck am i supposed to tell " 4" from "4 " or even possibly " 4 "
>>
>>107453644
>rotating and splitting on empty line
clever
>>
>>107453659
it's a grid, not a list of numbers, anon
>>
holy fucking parsing
>>
File: 6.png (278 KB, 1612x1736)
278 KB
278 KB PNG
the most unidiomatic code I've ever written
>>
>>107453694
>indians can't write r-
>>
>>107453662
That'll mess up part 2 though.
>>
>>107453701
dont think so, i'm gonna try it
>>
File: xarbon.png (22 KB, 580x1028)
22 KB
22 KB PNG
>advent of parsing
I'm really bad at this

Day   -Part 1-   -Part 2-
6 00:06:48 00:32:21
>>
>>107453667
it clicked, thank you
>>
>>107453631
it has to be
unless tomorrow is literally slam shuffle 2, this is just the easier half of the year
>>
>>107453631
truth nuke
>>
123
45
6 7
*

include this case somewhere randomly in the bigboy so we can argue about it
>>
>he left/right alignment of numbers within each problem can be ignored.
ERIC YOU FUCKING NIGGER
>>
>>107453722
lmaoooo please do this unironically
>>
>>107453596
If you can't namefag on /g/, you gotta anonfag on /work/
>>
fuck you, eric

Day   -Part 1-   -Part 2-
6 00:09:54 00:36:11
>>
>>107453596
>>107453737
>sorry guys im also on the reddit leaderboard so i turned off my name
simple as that
>>
>>107453722
###
##
# #
^

uhh guys?
>>
https://markdownpastebin.com/?id=597f9fd325e54eba8d9189cbc75ab40e

/aocg/2024#48=103661747 #-1=107371611 #0=107379367
d1=107379367/107389983 #1=107391909 #2=107400869
d2=107400869/107402978 #3=107407288 #4=107413670
d3=107413670/107415107 #5=107417323 #6=107424958
d4=107424958/107428346 #7=107430428 #8=107439547
d5=107439547/107441181 #9=107443386
d6=107443386/107453478
>>
File: d06_024057.png (250 KB, 960x1843)
250 KB
250 KB PNG
>not picking up the singular 4 in the last column in the example
>check the input
>picks up the expected last column value
>accepted
I'm done.
>>
Would have been a lot easier if I'd realized the operators were all aligned with the left column desu
>>
>is a grid problem
>lines have differing length
this puzzle is easily the worst one, it's just annoying parsing.
>>
I am going to simd the fuck out of this

>>107453776
>lines have differing length
they don't though
>>
>>107453776
The lines don't have differing length, they're padded with spaces. This might fuck you over if you trim whitespace from the ends of your input, but for me all I had to do was pad the last line with spaces
>>
>>107453791
>>107453793
you are right, I fucked up with the example input
>>
File: 1752671383035428.png (35 KB, 415x706)
35 KB
35 KB PNG
unwashed
>>
>>107453775
That's what I realized, though I could have done it better.
>>
File: 2025_day6.png (69 KB, 1673x588)
69 KB
69 KB PNG
Sorry to keep you waiting, complicated business.
>>
Ok so what was the clever way to do part 2. I just scanned the columns to create strs to cast to ints, and used the bottom row to decide where the columns stopped for each problem
>>
1422
77
139
44

I hecking love edge cases!
>>
>>107453791
>I am going to simd the fuck out of this
Oh fuck, I can make use of the parallel add and multiply operations in the PS2 EE.
>>
>>107453828
>and used the bottom row to decide where the columns stopped for each problem
this is what i did, seemed like the most obvious way to tell the true length of the digits in that column
>>
File: code.png (259 KB, 1988x1242)
259 KB
259 KB PNG
>>107453580
washed ass
transposing it was the trick to cleancode
>>
>>107453828
rotate the grid and reuse part 1 code
>>
File: what the fug.png (11 KB, 211x246)
11 KB
11 KB PNG
>There's only 12 puzzles
>They're like the puzzles of the first 12 days of previous years instead of the last 12 days
>>
>>107453837
not even an edge case
file of size 0 tier nonsense
>>
pt 1 array name: "problems"
pt 2 array name "fuck_you_problems"
>>
File: d6.png (355 KB, 1518x2593)
355 KB
355 KB PNG
not really a wtf, just kinda meh
>>
File: JUST.jpg (6 KB, 204x247)
6 KB
6 KB JPG
REMINDER THAT AOC IS NOW HALFWAY OVER

DID YOU RIKE IT??
>>
>>107453828
Let the grid be MxN. Start from last column and build the number doing acc = acc * 10 + c. Then do sum += acc, prod *= acc. Then check if there is a + or * below the current column, if there is then gold += sum if + else gold *= prod. reset sum = 0, prod = 1 and skip one column. Go like this from last column to first. No arrays needed. I processed directly the byte array input. It's bad on cache though. any form of transpose is bad.
>>
>>107453865
no
>>
File: aoc_day_5.png (1.44 MB, 960x838)
1.44 MB
1.44 MB PNG
Ahh maybe I'll clean up the code later. But it seems to fit the theme, so then again maybe I won't! TGIF boys! See ya next round!
>>
Day 06 (part 1):

Just parse, populate into a grid, and iterate through the grid in a column-wise manner:

package main

import (
"bufio"
"fmt"
"os"
"regexp"
"strconv"
)

func main() {
operands := make([][]int, 0)
operations := make([]string, 0)
file, _ := os.Open("input.txt")
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
s := scanner.Text()
if len(s) == 0 {
break
}

parts := regexp.MustCompile("[\\s]+").Split(s, -1)
ints := make([]int, 0)
if s[0] == '*' {
operations = parts
break
}
for _, p := range parts {
conv, err := strconv.Atoi(p)
if err != nil {
panic(err)
}
ints = append(ints, conv)
}
operands = append(operands, ints)
}

n := len(operands)
m := len(operands[0])
var total int64

for j := 0; j < m; j++ {
operation := operations[j]
var curr int64
if operation == "*" {
curr = 1
} else {
curr = 0
}
for i := 0; i < n; i++ {
if operation == "*" {
curr *= int64(operands[i][j])
} else {
curr += int64(operands[i][j])
}
}
total += curr
}
fmt.Println(total)

}
>>
File: 1764057088949822.png (1.62 MB, 905x896)
1.62 MB
1.62 MB PNG
>>
File: Day-6-Part-2.png (691 KB, 2220x2912)
691 KB
691 KB PNG
Day 6 Part 2
No intermediate arrays edition
>>
>>107453918
No AI please.
>>
File: carbon.png (666 KB, 1666x3910)
666 KB
666 KB PNG
kinda washed but my brain is lagging hard tonight, would've done it faster but i was getting filtered by not being able to recognize the blank lines and getting segfaults from making dumb vector out of range mistakes

pls help
>>
>>107453920
lang: zig
should au += mul instead of au *= mul
>>
>>107453918
very nice, more please
>>
>>107453901
all of your make() calls can be replaced with default initialization: var operands [][]int
you can use `` strings instead of doubling the backslashes in a regex
>>
File: ikneel.png (3.51 MB, 1024x1536)
3.51 MB
3.51 MB PNG
>>107453644
>np.rot90(data)
Haha wow! I kneel!
>>
>>107453947
see, but I was in a team at work that gave me 40 lashes and ritual shaming if I didn't use `make()`
>>
Can someone explain the point of this
>>
File: 1743640831178729.png (1.66 MB, 895x898)
1.66 MB
1.66 MB PNG
>>107453925
>>107453937
>>
>>107453955
it's fun
>>
>>107453955
To have fun?
>>
File: 25_D06_C#.png (366 KB, 1708x2174)
366 KB
366 KB PNG
Good Morning Sirs!
>>
>>107453961
>>107453962
Only in software do people have "fun" doing their job at home. I do not want to see any screen after work, I don't get it but whatever
>>
File: day 6.png (39 KB, 1322x256)
39 KB
39 KB PNG
zip is variadic so it's equivalent to transpose
>>
>>107453644
holy based
>>
>>107453981
N
>>
Last year's "Eric has given up" meme seems more relevant than ever.
>>
>>107453955
no, gtfo if you don't like it, there are literally thousands of other threads on this website you can look at
>>
>>107453693
'washing' my python code always turns into the nastiest ugliest most indian list comprehension code golf imaginable. I hate it
>>
>>107453981
get a hobby
>>
>>107454000
stop washing, then
>>
>>107453981
>I do not want to see any screen after work
did you post this using smoke signals?
>>
>>107453991
Last year's doomposting about it being the last advent of code was a funny meme, but it was a meme for a reason, everyone could feel this coming. I am genuinely surprised this year happened at all.
>>
>>107453955
Shitposting content.
>>
>>107454034
I normally don't bother, usually I just try to combine my duplicated code from parts 1 and 2 and that's good enough for me.
>>
File: 6.png (1.51 MB, 5170x5792)
1.51 MB
1.51 MB PNG
unidiomatic Rust solution
>>
>parsing problem
finally
>>
File: day6.png (567 KB, 1682x2458)
567 KB
567 KB PNG
Parsing in any language but python just feels painful. Unwashed shit coming through
>>
>>107454096
I always say I want to do aoc in some memelang, but the parsing always holds me back.
>>
>>107453644
>from np import solution
cool doe
>>
File: aoc06.png (199 KB, 1280x1870)
199 KB
199 KB PNG
I would not call it difficult just incredibly tedious nitty gritty
wtf are these clocked out puzzles this year eric

>>107454096
aoc has singlehandedly improved my fortran io-fu and there is still room to grow
>>
>>107454096
>Parsing in any language but python just feels painful.
Perl exists, kid. >>107453982
>>
day6 almost got me good, took me 1h30~ to finish part 2 and that's only because i didnt know a good way to parse the retarded input
>>
File: darkeric.jpg (23 KB, 400x400)
23 KB
23 KB JPG
phase 1 is now complete and the contestants are halfway through the trial
they are not ready but they will soon see...
they will be reminded of their place in this universe of my creation
i will kill them all
>>
>>107453727
this annoyed me too
>>
If tomorrow isnt hard, I'm going to switch langs to lisp or something I'm getting bored
>>
>less puzzles per year
>they aren't higher quality per year
>>
Stupid puzzles department

ACCEPT ACCEPT
>>
>>107454174
is reddit praising him regardless

dont get me wrong burnout is horrible but I get the feeling reddit glosses over that part and (pretends to) love the puzzles
>>
File: rape_me.png (43 KB, 923x804)
43 KB
43 KB PNG
i plugged my solution in gemini and its like hey dumbass use zip() but ive literally never used this function in my life
>>
File: 1540036329114.jpg (38 KB, 550x440)
38 KB
38 KB JPG
Another day, another simple, straightforward puzzle.

Do you think it's so easy this year because there's new money/investors/ad customers behind the AoC? And they're demanding people not be filtered out so the ads are seen by more potential customers?
>>
>>107454219
I find it more likely there is some hugboxxery going on where eric got moved by people stressing out over not managing puzzles
but that is a bit cynical of me
>>
>>107454212
zip just takes two things and spits out two elements (one from each thing) at a time
>>
Why are 64 and 23 in the right column left aligned but 45 and 6 in the left column right aligned?
>>
>>107454185
The glazing is out of control.

>Hello everybody,
I would like to take a moment to express my gratitude to the creator of AoC and to the whole community.

>This year, for the first time, I’ve been consistent in solving the problems, and thanks to AI and other users, after submitting my solutions I keep discovering new algorithms and approaches that enrich my skill set.

>I know that the creator was forced to make “only” a 12-day challenge this year, but maybe this format actually makes it easier to balance work and life while still providing challenging puzzles. I’d even suggest keeping this number for future years. If it doesn’t require too much extra effort, alternating the quiz day could also be helpful so if a puzzle requires more time, people have an extra 24 hours to work on it and might be less likely to quit.

>I also want to thank the community. I think I put so much effort into the quizzes just so I can come here afterward and enjoy the memes and the amazing visualizations. So thank you all as well.

>Good months to everyone!
>>
>>107454230
nobody knows, fuck eric
>>
>>107454230
because eric is a smarmy goofball and went back on his word about alignment not mattering
>>
File: carbon(151).png (596 KB, 1426x3462)
596 KB
596 KB PNG
Absolute shitcode for today.
>>
>>107454230
you'll find out in part 2
just ignore it/work around it in part 1
>>
>>107454230
why not?
>>
somebody bake the big boys. or tell me what should the expected dims be of one. can't be too big due to * and cniles complaining about bigint
>>
>>107454244
there is absolutely nothing a bigboy could do here
>>
>>107454230
For part 2 of the puzzle.
>>
>>107454249
it could be a 100gb text file
>>
>>107454244
>cniles complaining about bigint
18,446,744,073,709,551,615 is plenty big, junior
>>
>>107454240
I already did Part 1 in Excel, it is part 2 that I'm struggling with.
>>
>>107454259
here is a bigboy for you. create a 100x100 grid of all 9 digits and put a * at the line below.
>>
File: great take.png (123 KB, 1532x582)
123 KB
123 KB PNG
Comments like this on reddit remind me why I put up with you guys here. Anyone using the term "work-life balance" should be shot.
>>
File: 1740245598860654.png (43 KB, 657x527)
43 KB
43 KB PNG
>>107454238
Mine looks shittier. Not going to post it here. Basically I wrote a read_data() function that parsed me all the data into ints and operators for the 1st problem calculation. Then for part 2 I had to write it again, differently.
>>
Observe:
in =. (([:<;.1' ',}:"1),.[:;:{:"1)|:>cutLF 1!:1 <'input_6.txt'
f =. 1&{::".@,'/',0":@-.~[:,0".@{::]
] p1 =. +/ f"1 |: L:0 in
] p2 =. +/ f"1 in

Thank you for observing.
>>
>>107454249
not true. if the result needs to fit into a u64 and * is an op then can't have bigger numbers than 1e4. so a 4xNx4 grid where the last dim is for length of each number in a row. number of columns can be increased arbitrarily. I just want to test how bad on cache my sol is and then optimize it :<
>>
>>107454185
>(pretends to) love the puzzles
they dont need to pretend, all they want is a pat on the back and a participation trophy which it seems eric is happy to give them
>>
File: 1763870092314174.gif (303 KB, 498x289)
303 KB
303 KB GIF
>>107454280
It's character salad!
>>
>>107454270
>entire year to make 25 puzzles
>muh work life balance
>>
File: 1757042637891231.jpg (95 KB, 1200x800)
95 KB
95 KB JPG
Observe:

Thank you for observing.
>>
File: file.png (168 KB, 496x1354)
168 KB
168 KB PNG
ezpz
>>
>>107454306
what did you just write about my mother?
>>
>>107454280
>>107454306
kek
>>
waiting for c(ute)23 and idiomatic rust anons' posts
>>
File: 1752530825887852.png (419 KB, 950x3291)
419 KB
419 KB PNG
C

wasted an hour because I was out of bounds accessing my array and randomly fucking up a few pieces of data in the middle lmao

I parsed as normal numbers and did math to perform the vertical number conversion instead of using a grid and parsing the vertical string. after doing it I feel like this was probably the intended idea seeing as how the operators work in either direction and the logic for left / right aligned number sets are variations on a theme
>>
>>107454305
The Everybody Codes team managed to make 20 three part problems.
Eric should either bring on help or work harder.
>>
>>107454292
nvm we need to sum the results too. so N can only be upto 1e4 too, which the input already contains 1e3. seems pointless
>>
File: 1764962244009194.jpg (8 KB, 236x250)
8 KB
8 KB JPG
>>107454280
Seriously, WTF is that? Is that a new form of APL, with ASCII-characters instead of made-up symbols? (upside down pyramid with stroke through, lamp, etc.)
>>
File: 06.cc.png (511 KB, 1428x3502)
511 KB
511 KB PNG
Finally, an Advent of Parsing problem.
>>
File: aoc++.png (14 KB, 1151x54)
14 KB
14 KB PNG
Explain yourself. I completely understand supporting quality work, and I've donated to AoC in the past, but why reward mediocrity now that Eric has given up?

Only one AoC++ supporter the /g/ board.
>>
File: carbon(16).png (195 KB, 1566x894)
195 KB
195 KB PNG
>>107454096
you are just ignorant.
>>
>>107453722
Mine would accept this and parse it as the great eric puzzle king decreed. Right to left, top to bottom. The entire column has to be empty to move to the next column.
>>
>>107454341
>#include <bits/stdc++.h>
>using namespace std;
>not generalizing execute
to the loo with you, wash that ass
>>
>>107454410
Yes it is unwashed ass I shat out in 10 minutes. I will do the needful and clean it saarr
>>
>>107454426
Clean ups are for Dalit.
>>
>>107453722
print(int("1 6"))
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '1 6'
>>
>>107454436
Bloody benchod
>>
>>107454441
yep, in both parts a number is made up of contiguous digits. horizontally in p1 and vertically in p2

anyone has any ideas for optimizing this? mine >>107453920
>>
File: 1701450636335218.png (46 KB, 636x382)
46 KB
46 KB PNG
but can your code handle smallbois
0
*
>>
>>107454490
works on my machine
>>
File: eric1.jpg (4 KB, 414x414)
4 KB
4 KB JPG
>>107454363
ahh I'll throw him 10 bucks or whatever too. this thread and aoc are what I look forward to most. halloween and scary movies are a close second. the everybody codes duck one turned out actually pretty fun though too.
>>
>>107454338
it's an ancient form of APL: J
every primitive is either a single ASCII character or a single character followed by (any number of) : and .
>>
>determining the width of each problem's numbers by checking how many spaces are after the operator, minus one for the blank column
>there's not a trailing blank column
advent of cock and ball torture
>>
>>107454441
actually it's 106
16sisters need not apply
>>
>>107454270
Such a great take!
>>
>>107454490
Apparently it can. 0 for both parts. Also tried changing the 0 to a 5 and still got the right answer (5 for both parts).
>>
>>107454270
I've grown so heckin much! I love to copy solutions from my favorite streamers!! I'm gonna work at Netflix one day thanks to you Eric!
>>
>>107454529
just work from the other direction dumbo
>>
>>107454529
He literally tells you in the problem to read it right from left. All of the operators are left aligned, so when you find the operator column you can skip the next one.
>>
>>107454490
>part one: 0 (took 750ns)
>part two: 0 (took 292ns)
Yes.
>>
>>107454310
impressive, very nice
>>
>it's not going to get better, is it anons?
>>
File: 1703547102605.jpg (604 KB, 960x1280)
604 KB
604 KB JPG
Wow it is literally halfway over already. None of these problems has taken me longer than 15 minutes and I am a retard. Really hoping this weekend has something that makes me sweat a little bit.
>>
>>107454331
Were there an Everybody Codes general here? Not gonna lie, I completely forgot about that competition
>>
>>107454730
Yes there was, but it was much slower than aocg as you can imagine.
>>
>>107454219
Because Eric has completely checked out. I think he's exhausted from always staying up at midnight trying to put out fires. Already halfway done and not a single interesting challenge.
>>
File: FyRGoJ8aUAAo4Qk.jpg (25 KB, 525x384)
25 KB
25 KB JPG
>>107454786
>staying up at midnight
Over here in Europe that's 6 in the morning. Getting up at 5.30 to solve the puzzle at 6 isn't so great either.
>>
>>107454504
I get what you mean, but I don't want to signal any sign of approval to Eric for this year. Maybe I'll change my mind if the next 6 are just brutal. Tossing some shekels to EC was easy though, those guys worked hard, and the money probably matters more while the competition is small.

If he's actually checked out I hope he takes on more help; probably won't happen though, he has a captive audience of redditors who love these 'feel good' challenges.
>>
>>107454730
Yeah, and we had a /g/derboard. I'm sure next year will be better, a lot of anons just weren't aware.
>>
File: Screenshot_Firefox.jpg (644 KB, 1080x2117)
644 KB
644 KB JPG
Wife banned me from the P C tonight so I phone coded it in bed, realized I write really shitty code when every character is a struggle against the touchscreen
>>
>>107454903
In 2020 everyone said he'd gotten soft because it was the easiest year by far but then 2021-2024 were back to the previous difficulty
>>
File: 6.png (184 KB, 1080x1236)
184 KB
184 KB PNG
fun day today
>>
>>107454946
>wife
>banned me
>rust
Are you in an abusive homosexual relationship?
>>
123     234
345 456 567
678 789 890
+ + +

Well?
>>
>>107454962
It's not abuse if he keeps coming back
>>
>>107454977
Well what?
>>
>>107454977
Messed up my part1, part2 is 2012.
>>
another easy day but at least it was fun
>>
>>107454977
The blank number isn't a problem but the missing trailing spaces on the last line fucked up my line length calculation
>>
>>107454977
4082 2012

why tf do all my simd attempts make it slower TwT
>>
>>107453444
ONE TWO SELL A TREE
>>
File: 1756787701019036.png (60 KB, 1586x716)
60 KB
60 KB PNG
program the monty hall problem tomorrow
>>
File: swift_day6.png (325 KB, 1462x1500)
325 KB
325 KB PNG
Advent Of Parsing
>>
Cute P1
print(
sum(
(op == "+" and sum or __import__("math").prod)(map(int, col))
for *col, op in zip(*map(str.split, open(0)))
)
)
>>
>>107455234
Disgusting.
>>
>>107455343
>talks shit
>no code posted
back your claims, anon
>>
>>107455234
>map instead of generator comprehension
>imports
shame upon thy estate
>>
>>107455408
How is (int(x) for x in col) better than map(int, col)?
How else would you do prod in that environment? Either that or functools.reduce. I don't want to do the obsolete and yucky acc *= x thing.
>>
>>107455445
map is fine, ignore that anon
>>
File: file.png (336 KB, 1360x1876)
336 KB
336 KB PNG
What a fucking fag p2 with the text being not consistently aligned
>>
>>107455382
Still working on my assembly.
>>
> day 6 out of 12 is easy
It might be actually over
>>
part2 is an exercise in whitespace parsing
yeah I'll go for a bike ride to think this through
>>
>>107455487
>with the text being not consistently aligned
Does that even matter? I had a text 2 dimensional array that I traversed from right to left, from top to bottom, composing lists of ints and applying the operator at the end.
>>
File: 1748872103973161.png (1.09 MB, 1024x929)
1.09 MB
1.09 MB PNG
Shameful, unwashed Nim.

Day   -Part 1-   -Part 2-
6 04:43:41 05:15:31
>>
>>107455520
m-maybe eric was going for "half easy/half hard" this year
day 7 and up are going to be huge filters, just you wait
haha
>>
>>107455520
First half was for the Redditors, the second half is for the real /g/s. I believe. Usually shit gets hard only after day ~16 anyways.
>>
File: 1748743898922961.gif (482 KB, 265x264)
482 KB
482 KB GIF
>>107455586
>>
NEW THREAD >>107455604
>>
File: file.png (59 KB, 1255x583)
59 KB
59 KB PNG
If you're a brainlet like me, here's what he means.



[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.