[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 / qa] [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: 1734506496608713.webm (234 KB, 568x568)
234 KB
234 KB WEBM
yet another maze 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:
796940-44255af5
anonymous-only leaderboard:
383378-dd1e2041

previous thread: >>103559822
>>
Eric has given up.
>>
>>103568845
you will be filtered tonight
>>
I created a form for your alternative AoC puzzles.
If here will be at least some puzzles I will build a site by 01.12.2025.
https://forms.gle/7f8849M1LLF8ZeAF6
Please don't send me an input generator that secretly evaluates rm -rf.
>>
>>103568853
>>103568845
>>103568820
I wanna do this but I’m too dumb how do I get good at it ? I got filtered by second problem
>>
now you're asking for it
>>
>>103568872
What makes it hard for you?
>>
>>103568872
the only way you will get good at them is by spending the time to figure out how to solve it
practice
>>
>>103568883
Idk but idk much about different algorithms used so it seems intimidating when u don’t know where to start
>>
>>103568897
>>103568872
I don't know, try solving example input by hand and try noticing what you are doing.
>>
>>103568897
You don't need to know the algorithms people are talking about. It's just names of things. All of the problems so far this year have been possible to solve without any formal knowledge.
>>
>>103568872
>>103568897
for early days, you should be able to look at the problem and know what logical steps you have to do to get the answer
the programming part is just turning your logical steps into code that a computer can read and run for you much faster than you could manually
it isn't until later on that you need to know algorithms and other computer science skills outside just being able to program
>>
>>103568893
Imagine telling someone who never did s bench press to bench press a plate . How do I get up to level where I can be good
>>
>>103568872
Follow these threads. WHen you get stuck, see how other anons solved it. Try implementing one of their solutions. Look up terms that we use to describe problems (BFS, Dijkstra's algorithm, binary search, etc). Solve more problems.
>>
>>103568954
u are retarded just give up
>>
>>103568954
Do you already know how to program? Day 2 is not much of a bench press. Unless you're totally new to programming, I really think you'd be able to figure it out in a few hours if you take it slow and read the problem carefully.

There are easier problems on leetcode or codingame if you want something easier to practice.
>>
Odds on tomorrow being a maze?
>>
>>103568872
Also if you do really want to learn the fancy words people are throwing around, find a youtube series that goes over a "Structures and Algorithms" curriculum (but it's really not necessary)
>>
Who else /UK and up at 2:25 AM/ here? Might as well wait for the problem at this rate.
>>
>>103569047
You could take a 2 hour nap and be less miserable for the rest of your day
>>
File: mokou-solving-aoc.png (205 KB, 461x605)
205 KB
205 KB PNG
today will be rough, i can feel it.
>>
inb4 day 3 difficulty tier problem today
>>
>>103568872
Sorry these problems are for Ivy League CS + Math PhD + Fields Medal recipient level programmers only.
>>
>>103569205
damn, I've only got none of those
>>
>>103569164
the last one was really easy. I'm expecting today will make up for it.
>>
>>103569164
I'll be drunk by midnight, so I expect a hard problem.
>>
sorry sepia, no emojis. there is something broken about fonts and matplotlib
>>
File: carbon.png (956 KB, 1914x8300)
956 KB
956 KB PNG
Maze generator using Kruskal's algorithm with configurable cycle density, if anyone wants it
They end up looking very similar to Eric's so might be good for bigboy creation
https://pastebin.com/UCndYyud
#####################
#.#.....#.......#.#.#
#.#####.#.#.#.#.#.#.#
#.........#.#.#.....#
#.#.#.###.#.#.#.#.#.#
#.#...#...#.......#.#
#.#####.###.#.###.#.#
#.#.......#.#.#.....#
#.###.#######.#.###.#
#.#.........#.......#
#.###.#####.#.#.#.###
#.#.....#...#...#...#
#.###.###.###.#######
#...#.#.....#.......#
#.#######.#.#.###.###
#.........#...#...#.#
#.#########.#.#.#.#.#
#.#.#.........#.#.#.#
#.#.#.###.#.#.#####.#
#.......#.#.#.......#
#####################
>>
>>103568820
Please Eric, anything but another grid. If I have to write
bool inbounds(int i, int j, int m, int n) {
return 0 <= i && i < m && 0 <= j && j < n;
}

again I am going to lose it.
>>
File: file.png (330 KB, 480x270)
330 KB
330 KB PNG
if you didn't solve it using actual rats you're filtered
>>
File: 3-women-laughing.jpg (69 KB, 724x483)
69 KB
69 KB JPG
>>103569318
>he doesn't have a library of aoc utils
>>
I hope you all still have your paper cubes from 2022 for tonight's puzzle!
>>
File: carbon(143)(1).png (1.2 MB, 2776x6787)
1.2 MB
1.2 MB PNG
You know what? Fuck you
*compiles your elfcode*
>>
>>103569377
I should really write one.
>>
>>103568013
Someone could host a site where you post your code and it's benchmarked on their hardware in a VM or container.
>>
>>103569400
Based.
>>
>>103569400
based broooter
>>
>>103569362
those are hampsters
>>
>>103569362
those are mice
>>
>>103568897
I don't really know what BFS, DFS, A* or Djikstra are. My way of solving grids sounds like a BFS but it's just what I cobbled together from trying to solve a grid problem and I keep recycling it.
Most of the problems are just understanding what you're trying to accomplish and then writing code that does it.
>>
>>103569592
dont worry, bfs is all you need
>>
Now that the dust has settled... is Dijkstra pronounced DEEKstra or DICKstra?
>>
>>103569654
d-eye-kstra
>>
>>103569654
dyke-stra
>>
File: 1734001793092751.png (1.33 MB, 2084x1584)
1.33 MB
1.33 MB PNG
Today's problem was so fucking bad it killed the thread for most of the day.

I solved it in like 5 minutes in awk, solved part 2 in about 5 minutes in awk, got mad, tried doing some crazy wall-tracking flood fill shit, realized it was slower, got mad, and just went outside.

>>103569592
based self-deriver
>>
Finished day10 for GBA.
Took less than an hour.
>>
guys should i get drunk?
>>
>>103569592
post ur code and we'll tell u what algorithm it is
>>
>>103569821
It only leads to regret.
>>
>>103568870
I love you too, Israel, but I need puzzles, not love.
>>
>>103569654
like the "dig" part of "digit" plus "ck" plus "struh"
dij ck struh
>>
This was definitely a bad puzzle, but in hindsight, at least it made some cool visualizations. The main problem was that it was too easy and too close to another maze problem.
>>
>>103558363 the puzzle done correctly
>>
>>103568870
I'm not creative enough for this shit
>>
File: image.png (530 KB, 1091x646)
530 KB
530 KB PNG
my humble BQN solution for day 18.

was sick yesterday, so couldn't do it on time. thankfully it was easy, i can now rest a bit before day 19 drops.
>>
>>103569654
Rijk == Reich
Dijk == Dyke
>>
1 HOUR
>>
>>103568820
>whale game of code
>>
>>103567912
>the problem is coming up with a question that has an objective numerical solution (beyond "compute this input")
if the goal of the problem is to produce an array or a data structure, you can always walk over it and count something, add something, apply an arbitrary formula or even make a hash of it. the result can also be a small string.
>>
>>103569821
I already did. Just adds extra challenge. Like Goku training under extra gravity.
>>
I WILL NOT BE FILTERED TODAY
>>
THE FILTER IS COMING
>>
File: maze-chan.jpg (1018 KB, 1280x720)
1018 KB
1018 KB JPG
I'm not a big fan of maze solving.

without text:
https://files.catbox.moe/u4rkga.jpg
>>
>>103570259
says the unfiltered man for the 18th time
>>
>>103570273
damn maze-brat! needs flood-fill correction!!
>>
>>103570259
Ask not for whom the filter filters, it filters for thee
>>
>>103570273
中出し maze-chan
>>
>>103570259
For You.
>>
>>103569654
It's Dutch, so: ['dɛjkstra:].
>>
>>103570316
no one else has any clue what your made up language sounds like
>>
15 minutes ahhhh
>>
>>103570273
As for me, I like the mazes
>>
Will today be the hardest problem? Usually its around this point right?
>>
10 minutes ahhhh
dead thread ahhhh
>>
IT'S GOING TO BE ANOTHER FUCKING GRID
>>
>>103568870
I will think about making a problem after the today's puzzle.
>>
>>103570401
feels like he might bring us to the 3d space now
>>
>>103564447
CUTE!
Thanks for coming back krita-anon. Highlight of my day
>>
bfs ready
>>
>>103568870
I have the seed of an idea. Dunno if I can flesh it out into a two-part problem.
>>
no grid today
extension of our interpreter
>>
HURRY UP I WANT TO GO TO BED REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>103570417
u think he has the balls?
>>
>>103570417
you wish
>>
>>103570417
No grid today, only pain.
>>
>>103570273
i need her to be mean to me
>>
File: file.png (6 KB, 254x107)
6 KB
6 KB PNG
didnt spot this before
>>
FUUUUUUUUCKKKKKKK I HAVE TO TAKE A SHHHIIIIIIIITTTTTTTT AAAAAAAAAAAAHHHHHHHHHH
>>
>>103570435
>Aoco
>Joten
>yrs
What did Eric mean by this?
>>
>>103570437
use your poop sock
>>
>>103570423
He's doing callbacks
What better callback to intcode than using it for multiple problems?
>>
File: showtime.jpg (46 KB, 640x480)
46 KB
46 KB JPG
https://www.youtube.com/watch?v=hjGZLnja1o8
>>
>>103570449
cancer music
>>
>>103570449
kino music
>>
>>103570449
kino music
>>
>>103570449
SHOWTIME
>>
>>103570435
-----
|AoC|
|ten|
|yrs|
|.is|
|too|
|old|
-----

what did Eric mean by this?
>>
File: mokou-showtime.jpg (130 KB, 440x518)
130 KB
130 KB JPG
>>103570449
>>
>>103570435
Out of 10!
>>
>>103570466
he was /ourguy/ all along
>>
>the map is a giant 10
WOAH
>>
im scared bros

this is day 19 we're talking about...
>>
>>103570478
it's a 2 retard
>>
>>103570478
slowpoke?
>>
>>103570480
keep moving
keep moving
keep moving
>>
TODAY IS DP FOR SURE
>>
>>103570483
AOC 2 soon
>>
>>103570480
Prepare for a 4D grid.
>>
We never had a tree day..... Its going to be a tree.
>>
File: showtime-frog.png (468 KB, 1858x1829)
468 KB
468 KB PNG
we rollin
>>
>>103570480
Hopefully it's ass-rapingly hard
It's been too long
>>
NP-hard problem where you need to find a hidden property to make it trivial.
>>
>>103570487
I STILL DON"T KNOW WHAT DP IS
>>
SEE YOU ON THE OTHER SIDE FAGS
>>
dijkstra today
>>
simulation day
>>
>>103570498
youll find out tonight ;)
>>
its joever
>>
FUCK
>>
advent of parsing
>>
File: maze-chan2.jpg (362 KB, 720x1280)
362 KB
362 KB JPG
>>103570390
>>
its a hotspring episode
>>
nope, I'm filtered I have no idea how to solve this.
>>
>>103570354
Dutch is not a "made-up language", it is spoken by millions of people in the Netherlands and Belgium. As for the notation: If you don't know what IPA is, then you're obviously an American isolationist ignoramus.
>>
I know how to do this, but I don't really want to. so I won't
>>
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
19 00:03:43 273 0 00:05:01 216 0

Holy fuck, why are the puzzles so easy now?
>>
I also know how to do this, but I don't really want to. so I won't
>>
IM BROOTING
>>
File: file.png (164 KB, 824x1229)
164 KB
164 KB PNG
>>103570572
UNWASHED ASS
I'm going to bed.
>>
>>103570572
>its an llm day
>>
advent of magic the gathering?
>>
wtf that was so easy
>>
File: 1705043789156282.png (71 KB, 1078x672)
71 KB
71 KB PNG
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
19 00:07:04 745 0 00:09:34 586 0
>>
Too drunk to do this now. No regrets. I'll solve it hungover tomorrow.
>>
>>103570614
This is a day 5 puzzle, maybe day 10, but definitely not day 19.
I suspect the Day 20 puzzle will be brutal.
>>
Im broooooting
>>
>>103570656
just one more day bro, the wall is coming bro, one more day and it'll be brutal bro
>>
>>103570636
Whoops I fucked up my code trying to clean it
That line should have been return sum(solve(target[len(p):]) for p in patterns if target.startswith(p))
>>
Well drawing this one is gonna be funny.
>>
File: really now eric.png (373 KB, 510x572)
373 KB
373 KB PNG
>>
> it is just memoization
meh
>>
>>103570582
oh yeah caching
kek
>>
does it get any more idiomatic than this?

4 sloc if i remove punctuation / whitespace, shortest program since like day 2 kek

let [&split(', ') ~> ts, &lines ~> ds] = slurp().split(/\n\n/)

let memo = %{'': 1, *: count(it)}

function count(d) {
[memo[d.slice(#t)] for t in ts if d.starts?(t)].sum() ?? 0
}

print([count(it) for ds].sum())
>>
File: 1708707790319931.gif (1.62 MB, 448x598)
1.62 MB
1.62 MB GIF
>>103570656
>two absurdly easy, week 1-tier puzzles in a row
unironically what did he mean by this
>>
File: day19png.png (275 KB, 844x389)
275 KB
275 KB PNG
what did he mean by this
>>
Eric has given up.
>>
Eric is filtered
>>
File: D19_washed.png (273 KB, 2400x1124)
273 KB
273 KB PNG
Washed Kotlin.
>>
File: haet.jpg (75 KB, 536x400)
75 KB
75 KB JPG
> works on example
> out of memory on input
>>
No point in a bigboy since since answers would exceed 64 bits
>>
can eric please make a proper question these are so lame
>>
forgetting to cache was a real brainshart here
i just assumed it wouldnt be that bad to broot because it should prune early when it doesnt start with a pattern
>>
>>103570748
>No point in a bigboy since since answers would exceed 64 bits
Do you even BigInteger?
>>
>>103570748
so just give the answer mod 2^64 bro
>>
DONE
part 2 answer way higher than I thought it would be, I thought brootbros might've had a chance today
>>
>>103570713
>still doing clojure solutions

God damn. I gave up clojure around day 5
>>
p2 was obvious a mile away
>>
>>103570760
That's unaesthetic and changes the problem
>>103570759
Not fair to languages without it
>>
so is functools cache just import memoization
>>
File: 1732017781122872.jpg (190 KB, 928x1232)
190 KB
190 KB JPG
functools bros where we at?
>>
>>103570782
yes (and that's a good thing)
>>
>>103570766
If I had seen it I would've probably gotten into the leaderboard. Too bad.
>>
>>103569400
ha!
MIPSlet detected
>>
>>103570782
>>103570788
>>103570789
you did not solve the problem
>>
File: 1715848706296284.jpg (234 KB, 1024x1024)
234 KB
234 KB JPG
>>
>>103570795
My two gold stars say otherwise
>>
File: day19.png (237 KB, 1526x1482)
237 KB
237 KB PNG
$ mix run -e 'AOC.main()' -- 2024 19 b input/real
347
919219286602165

Ran in 27356.401ms


>import solution
>>
>>103568897
hear about an algorithm
look it up and watch an explanation on ytubes
do the problem
repeat
congrats you now know algorithms
>>
File: img-2024-12-19-06-32-20.png (868 KB, 5224x3192)
868 KB
868 KB PNG
idiomatic Rust solution
>>
>>103570765
I love the language, even if everything I make is a poor use of it.
But god damn is scripting in clojure literally a different language to the prod clojure we use at work. 90% of what we do in my job is passing maps through other maps and having them get manipulated by other maps.
>>
File: 1722061128987552.png (115 KB, 1500x1034)
115 KB
115 KB PNG
>>103570795
Did I solve it now?
>>
>>103570647
UPDATE: I was not in fact, too drunk for part 1.

But I am probably too drunk for part 2.
>>
>>103570753
>>103570721
>>103570716
just say you're filtered
>>
>spend 15 minutes brooting instead of setting up memoization
I will never learn
>>
>>103570822
r u so drunk you can't type @functools.cache ?
>>
>>103570822
>But I am probably too drunk for part 2.
Just replace Boolean with Long.
>>
>>103570822
its the same thing
>>
>>103570819
>prod clojure we use at work
I'm jelly.
>>
>try to solve problem as fast as possible
>comment out lines of code in case I need to use them again later
>trying out ideas the instant I think of them instead of thinking them through
>have tons of variables that I don't use or that contain redundant information

>solve puzzle
>look back at my solution
>wash it
>it's a quarter of the length it was when unwashed
every single day
>>
File: 1710413323268416.png (206 KB, 1386x988)
206 KB
206 KB PNG
Advent of BFS and DFS
>>
>>103570840
same
>>
>>103570822
Base case returns 1 instead of true and you count instead of filtering. That's literally it.
>>
I think I’m going to have to implement Aho-Corasick :(
>>
Name 1 time you used this sort of "pattern builds up to a whole with memoization" at your coding job
>>
>>103570506
I still don't know what dp is. Is it memoization?
>>
>>103570859
Ask your mom, she's a world renowned expert.
>>
>>103570843
Advent of BFS/DFS was 2022.
>>
>>103570856
this one time instead of working I was doing aoc and so I used it there
>>
>>103570802
> not any bbrgwbs
0 stars, would not get into the onsen
>>
>works on example not input
Fugg why am I so retarded.
>>
>>103570856
At my what?
>>
big tiddy elves in the onsen
>>
>>103570878
same brother
>>
File: xarbon.png (8 KB, 452x468)
8 KB
8 KB PNG
it's over, fucked up my alarm and woke up at 6:30 :(
and fuck you eric for another babby's first problem day
      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
19 00:40:13 4222 0 00:41:18 3035 0
>>
>>103570856
i havent used this or grid shit, but i used some jeetcode puzzles at work, mainly things around string manipulation
>>
Waste of a callback to 2022's gears, I was dreading it reading the story and now I'm just blueballed
>>
sigh. fucked around with my recursive function without adding a memory map for like 30mins. solved it instantly when I just added the map.

      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
19 00:47:38 4625 0 00:49:43 3421 0

type towels struct {
next map[byte]*towels
end bool
}
func main() {
var err error
var dat []byte
dat, err = os.ReadFile("./" + os.Args[1])
check(err)
input := make([][]byte, 0)
vss := strings.Split(string(dat), "\n\n")
for _, vs := range strings.Split(vss[0], ",") {
vs = strings.TrimSpace(vs)
if len(vs) <= 0 {
continue
}
input = append(input, []byte(vs))
}
patterns := make([][]byte, 0)
for _, vs := range strings.Split(vss[1], "\n") {
vs = strings.TrimSpace(vs)
if len(vs) <= 0 {
continue
}
patterns = append(patterns, []byte(vs))
}
dmap := &towels{next: make(map[byte]*towels), end: false}
for _, in := range input {
curr := dmap
for i, b := range in {
nm, ok := curr.next[b]
if !ok {
nm = &towels{next: make(map[byte]*towels), end: false}
curr.next[b] = nm
}
if i == len(in)-1 {
nm.end = true
curr.next[b] = nm
}
curr = nm
}
}
sum := 0
gcount := 0
for _, pat := range patterns {
fmt.Println("pat", string(pat))
ccount := findp(dmap, make(map[string]int), pat)
if ccount > 0 {
fmt.Println("make")
sum++
} else {
fmt.Println("cant")
}
gcount += ccount
}
fmt.Println("sum", sum)
fmt.Println("sum1", gcount)
}

func findp(pats *towels, mem map[string]int, word []byte) int {
if ss, ok := mem[string(word)]; ok {
return ss
}
if len(word) == 0 {
return 1
}
npats := pats
ok := false
ccount := 0
for i, cha := range word {
npats, ok = npats.next[cha]
if !ok {
break
}
if ok && npats.end {
// fmt.Println("match", string(word[:i+1]))
cc := findp(pats, mem, word[i+1:])
ccount += cc
}
}
mem[string(word)] = ccount
return ccount
}
>>
>>103570927
I thought today was going to be an insane filter, calling back to the spring problem followed by gold requiring memoization
but it was a very trivial memoization

reminder that the spring problem was day 12 last year.
we're on day 19 this year.
>>
Unwashed. Took me an embarrassingly long time.
I was counting number of times states occurred, and my bug was that when a pattern matched, I was only adding 1 to the count, not the number of states. This passed on the test input because the patterns were very simple.

>check thread
>solutions with <10 lines of code

I really need to brush up on my memoization techniques.
>>
File: carbon(17).png (2.48 MB, 1206x2200)
2.48 MB
2.48 MB PNG
your least favourite jsfag is back
>>
If Eric doesn't rape us with a hard problem tomorrow that takes me 3 hours, I might lose interest in AoC entirely....... Or at least I will be forced to switch to memelangs.
>>
>>103570979
dont you just put @cache above a def?
>>
>>103570999
I don't know how functools cache works. I see now that that's how people are getting their terse solutions.
>>
>>103570839
it really is just it's own domain specific language at this point. It's kino to work with, but impenetrable for new hires.
>>
File: file.png (195 KB, 1872x938)
195 KB
195 KB PNG
lame and boring
>>
what do you get for silver on this input? https://0x0.st/XC1A.txt
>>
>>103571021
more than 200
less than 300
>>
day 6 was ok, day 12 was ok, day 14 part 2 was excellent, day 16 was great
all the other puzzles were massive boring dogshits
what's up with eric this year?
>>
Ouch, memoization hurts my brain
But nice, holy crap the number to part 2 was huge, no way could you broot that
>>
>>103571021
217
>>
How long is today's taking to run for people?
>>
>>103571021
>>103571029
That's weird, I get 255 for https://0x0.st/XC1A.txt
>>
>>103571041
i also got 217, your program is bugged.
>>
>>103571041
Your code must be wrong then
>>
did this while tabbing back and forth with a cs2 game
      --------Part 1--------   --------Part 2--------
Day Time Rank Score Time Rank Score
19 01:01:28 5231 0 01:02:05 3919 0
>>
>>103571047
>30 second part 2
Anon? Something you want to tell us?
>>
>>103571031
200ms
>>
>>103571031
<1s
>>
>>103571025
ha, i'm not trying to cheese. my code that passes example gets 256, but eric wants 255 (which i got by chance)
>>
>>103571055
If you do it the smart way its a very simple change
>>
>>103571055
to be fair, it was very easy to guess what part 2 was going to be, and many people probably did it while solving part 1 (I didn't, but I did correctly predict what part 2 was going to be)
>>
File: 1733823587591138.png (1.01 MB, 2040x781)
1.01 MB
1.01 MB PNG
>change "any" to "sum" to solve part 2
Eric has given up.

>>103571031
About .8s with CPython.
>>
>>103571061
fuck, i didn't filter out empty lines. all is right now
>>
File: carbon (14).png (68 KB, 563x529)
68 KB
68 KB PNG
Not too tough today, surprisingly. Where is the difficulty?

Washed python. Thrilled with how concise it is.
>>
>>103571031
2.5s, which seems to be roughly 3x CPython so I'm fairly happy with that
>>
Is this year easier than 2020? Wtf is eric doing?????
>>
>>103571097
end of aoc
>>
>>103570996
Jokes on you I lost interest last week and saved myself 5+ hours
>>
>>103571031
120ms
>>
>>103571106
:salute:
>>
>>103571097
Last AOC. Eric is tired, plus Reddit was whining that AOC is too hard, so he toned it down by a lot so everyone can do all 25 days and enjoy Christmas
>>
>>103571109
>I got filtered last week
Got it
>>
File: carbon(63).png (252 KB, 1218x1354)
252 KB
252 KB PNG
>>
>Each stripe can be white (w), blue (u), black (b), red (r), or green (g).

solve my smallboy
r, u, b, s

rubs

you should get

silver: 0
gold: 0


(s is not a valid stripe color and should be ignored)
>>
>>103571117
>>103571097
If this year is so much easier how come so many people have been filtered already? Maybe you're just better than you used to be at this sort of problem.
>>
>>103571117
This isn't the AOC I signed up for
>>
>>103570316
>It's Dutch
OF COURSE, the fake language gotta have fake names, how could I have been so blind?
>>
>>103571125
>If 1+1 is so easy why does no one want to repeatedly solve it for a month straight
>>
>>103571125
as far as percentage of people filtered is concerned, I argue that number of days is much much higher weighted than difficulty of puzzles.
I would argue that the difficulty of puzzles barely matters at all. If every day was a checkbox, there would still be an 80% filter rate by the end.
>>
>>103571097
>Wtf is eric doing?????
Giving up.
>>
>>103571123
>Each stripe can be white (w), blue (u), black (b), red (r), or green (g)
>data includes a stripe that isn't allowed
Malformed problem statement. Being obtusely retarded is not being clever. If the question said "only use the stripes w, u, b, r, and g from the input" instead of "each stripe can be..." then you'd be fine
>>
>>103571141
That would be me unfortunately see you guys next year if there's a next year
I'm done
>>
>>103571123
faggot
>>
>>103571149
>>103571123

designs aren't stripes.
>>
>>103571125
at some point people realised it's not worth waking up at 3am for this shit and filtered themselves
>>
what if the stripes are 0 length?
>>
>>103571141
>If every day was a checkbox, there would still be an 80% filter rate by the end
If you mean to say that 80% of people would drop out even if every problem was easy for them, I don't agree at all.
>>
>>103571169
People are bad at habit forming. There is nothing to agree with, this is just observed behaviour across any domain you can think of.
>>
>>103571166
or you can just do it 12 hours after it's released at your own pace
>>
how are the brooters doing today
>>
>>103571176
>People are bad at habit forming
That doesn't let you just make up an 80% figure
>>
>Easy puzzles
>Zero (0) puzzles with trick inputs with undisclosed edge cases
wtf? That is the most fun part.
>>
>>103571169
theres not really a reason to do AOC apart from fun
once that runs out no one's going to stick around
>>
>>103571166
>waking up at 3am
That's just a part of Brazil that has UTC+03:00.
>>
Last year was infinitely better than the current one.
>>
>>103571180
just fine if they memoized
>>
>>103571167
Then part 2 would be Infinity assuming you can create at least one pattern.
>>
this is just a BFS problem. again.
Eric is really running out of ideas
>>
>>103571198
there's not an infinite number of textbook algorithms
>>
File: walking.png (190 KB, 3334x3334)
190 KB
190 KB PNG
>>103571183
Ok how about somewhere between 40-60 percent. It would be high regardless is what I am saying.
>>
File: image.png (338 KB, 1080x397)
338 KB
338 KB PNG
my humble BQN solution for day 19.

easy DFS shit. no problem!
>>
File: day19-mathematica.png (57 KB, 1326x794)
57 KB
57 KB PNG
Part 1 reduces to a consequence of Part 2, so both can be solved together.
>>
File: day19_fast.png (269 KB, 1526x1672)
269 KB
269 KB PNG
>>103570806
$ mix run -e 'AOC.main()' -- 2024 19 b input/real
347
919219286602165

Ran in 85.875ms


Made it a bit faster.
>>
>>103571212
>looks at the 3% survival rate from day 1 (I pulled that number out of my ass but you get the idea)
yeah no 80% is too low, AOC's novelty wears off after a few days
>>
>>103571106
>>103571117
>End of AoC
If advent of code ends 100 clones will pop up and at least 1 will be good. The true nightmare scenario is Eric hands it off to reddit and it goes to shit (The puzzles getting easier is a consequence of this reddification happening at a slower pace btw)
>>
>>103571169
anon I don't think anyone wants to play "first 100 to push this button on utc +1 gets put on a leaderboard" for a month straight
>>
>last AOC is worst AOC
please don't end it like this
>>
>>103571222
cute big words.
yes part1 and part2 can be solved at the same time.
>>
>>103571243
>The true nightmare scenario is Eric hands it off to reddit
Ugh...

>Le Orange meanie has stolen Christmas. Stop him and his evil-(98 IQ)-genius NOEL Stink (See what we did there??? It's an anagram and a synonym heheheh, gawd us people are so smart)
>>
>>103571243
I think people underestimate how much work it takes to make a AOC. any copycat will be a poor imitation with no story and just "solve this leetcode problem for 25 days"
>>
>>103571268
Making good problems with good inputs is very hard. Just look at the bigboys. No offense to the creators, but the quality is much worse than the official inputs.
>>
Day 25 will be absolutely ball-crushing and will require PhD in math and theoretical physics, I'm sure of it. It will be a final fuck you from Eric.
>>
File: bqn.png (133 KB, 2025x962)
133 KB
133 KB PNG
wasted a bunch of time on the easy parts of this problem
>>
>>103571257
>consequence
>>
>>103571279
>AoC cant end if you never solve the final puzzle
This would be amazing actually.
>>
>>103571266
>has stolen Christmas
WRONG THINK!!! SHUT IT DOWN!
>Le Orange meanie has stolen ze holidays. Stop him and his evil-(98 IQ)-genius NOEL Stink (See what we did there??? It's an anagram and a synonym heheheh, gawd us people are so smart)
>>
>>103571268
>>103571243
I tried Advent of Sql for a few days and it makes you appreciate Advent of Code.
>>
>>103571247
Are you intentionally missing the point?
>>
>>103571293
I didn't even know it exists. But yeh there we go.
>>
>>103571287
The best possible way for him to end it would be for the final day to unlock a "Part 3" to each of the previous year (The AoC++ puzzles).
>>
File: 1730190958458744.png (154 KB, 1286x1542)
154 KB
154 KB PNG
>>103571302
ambiguous descriptions, wrong examples, making you paste multiple rows in different fields as your answer instead of a final number or at least a text area that would split on \n.. telling you ORDER BY but not enough fields to break the ties.. it's just not good
>>
>>103571316
>show hint
Ewwww
>>
>>103571298
that's literally the point you're making
>>
>>103571316
that looks horrible
>>
>>103571330
you are missing the point
>>
>>103571268
Sad but true.
>>
C++ 23
#include "aoc.h"
static V<Sv> patterns;
static M<Sv, N> sols;
static N countWays(const Sv design) {
if (design.empty()) return 1;
def it = sols.find(design);
if (it != sols.end()) return it->second;
N result = 0;
for (def p : patterns)
if (design.starts_with(p))
result += countWays({design.begin() + p.size(), design.end()});
return sols[design] = result;
}
int main(int argc, const char** argv) {
MmFile in(argc >= 2 ? argv[1] : 0);
def input = in | "\n\n";
patterns = input.h / ", ";
def designs = input.t / '\n';
N silver = 0, gold = 0;
for (def d : designs) {
def n = countWays(d);
silver += n != 0, gold += n;
}
std::cout << silver << '\n' << gold << '\n';
}
>>
>>103571167
idk about stripes, but for patterns there is exactly 1 way to match a pattern with 0 length
>>
File: codesnap5.png (220 KB, 1726x1128)
220 KB
220 KB PNG
Any lispers?
>>
How long is part 2 going to take to run?
>>
>>103571413
Well you better go catch it then!
>>
>>103571268
>"solve this leetcode problem for 25 days"
And leetcode already has monthly challenges.
>>
File: xarbon.png (6 KB, 420x356)
6 KB
6 KB PNG
washed code
solved part 1 by counting down
>>
>>103571413
about 4 hours just hang on
>>
>>103571413
How many combinations are you finding per second? My answer was just under 881 trillion.
>>
>>103571431
Guess I'll write a memoizer.
>>
after day 25 unlocks, a new link will appear on the [Events] page, and clicking it will ask you to input 500 golden stars to continue
I hope you guys all have enough, because eric told me what the 500 stars prize is gonna be, and it's real special, I wouldn't anyone to get spoiled on it by reading the thread before seeing it for themselves
>>
File: bqn.png (68 KB, 1561x369)
68 KB
68 KB PNG
>>103571283
washed somewhat
got rid of bad_good split that caused me so much trouble and wasn't needed because I misread the problem
including p1 and p2 the way >>103571216 does. Also realized from humble bqn that I didn't need to rebind functions to recurse by name.
_memo is like J's M.
wrote that coincidentally today
>>
input kino
>>
>>103571278
the people here that make bigboys don't do it to make high quality big inputs, they just do it for the attention

and if that's not the case, I'm inclined to disagree because of how pathetic the big boys have been this year
>>
Huh, that was cool. I thought it was going to be a lot tougher than just plugging a cache onto my function bu there you go

Day 19 in Squirrel https://pastebin.com/QvFsMzVF
Unwashed and could be a lot smaller since I decided to store my patterns in a sort of linked list style table since I thought that would increase speed, but memo solved it so I could just do string slicing and comparisons if I care to wash it.
>>
>>103571490
The bigboys are perfectly fine for their intended purpose of stress testing your solution that already accounts for edge cases.
But most bigboys are generated randomly, and dont have well crafted edge cases that ensure your code is correct.
>>
>>103571502
bigboy creators are lazy
>>
>>103571456
fuck I still haven't done 2017
>>
>Today was really easy, let's see if I can rewrite my solution in F#, heard a lot of good things about it
>Stack overflow with the exact same algorithm and exact same recursion
I guess I'm still too retarded for FP languages
>>
>>103571570
Blitz it. There's only really 3-4 "hard" problems a year. You have time.
>>
>>103571589
The only difference between normal and fp languages is while and for loop allergy and everything MUST be heckerino unmutuable im gonna deeeeeepcopyyy
Both are retarded, there's no reason to use them
>>
>>103571589
F# might have relatively shallow stacks and expect you to use tail-recursion
other languages might have growable call stacks and only have your memory as a limit.
>>
>>103571599
>cnile is getting filtered by fold
lmao
>>
>>103571599
You have imperative brainrot
>>
>>103571401
If there is a next year, I will do it in lisp. He is making the puzzles to easy, and I will have to nerf myself.
>>
>>103571456
I need more time...
>>
Still not buying that this is the last year
>>
say the line, triejak
>>
File: question mark.jpg (447 KB, 1920x1080)
447 KB
447 KB JPG
now that the dust has settled what was the great filter of this year?
>>
>>103571456
I have about zero desire to do most of the problems from previous years without a /g/ thread to keep me entertained.
I already did most of the interesting ones like the shuffle or the 3D sensor one.
>>
>>103571645
day 17 part 2
>>
>>103571645
tomorrow
>>
>>103571645
day 21.
>>
>>103571645
day 12 had elementary geometry
day 13 had a system of equations
day 16 was too much of a stale pathfinding problem
>>
>>103571026
17 was good too
>>
when will eric stop giving us leetcode questions?
>>
>>103571026
Last aoc
>>
>>103571645
day 1
>>
more of the finding the tree and box pushing puzzles please eric
>>
>>103571026
gave up thats what
>>
>>103571677
>last year is boring dogshit
its over
>>
>>103571648
Even brooting works, any Nooticer can spot the patterns in octal.
>>
>>103571694
The valve problem was the best he's done.
https://adventofcode.com/2022/day/16
>>
File: 24_D19_C#.png (480 KB, 2372x2014)
480 KB
480 KB PNG
C#
I was having a hard time wrapping my head around the memoization for some reason
>>
File: jackingoff.jpg (33 KB, 500x663)
33 KB
33 KB JPG
calendar image idk today was boring
>>
>>103568820
wtf today was so easy
>>
File: aoc22-d16.png (246 KB, 932x538)
246 KB
246 KB PNG
>>103571715
>>
>>103571674
>questions
Good morning sir!
>>
>>103571026
>day 6 was ok, day 12 was ok, day 14 part 2 was excellent, day 16 was great
>all the other puzzles were massive boring dogshits
>what's up with eric this year?
He became blackpilled with LLMs solving all the puzzles and just gave up.
>>103571645
>now that the dust has settled what was the great filter of this year?
There has been none. Just look at the chart - it closely resembles the exponential function >>103569300
>>
File: purritokitties.jpg (3.44 MB, 5616x3744)
3.44 MB
3.44 MB JPG
>>103571720
>>
>>103571758
>it closely resembles the exponential function
so?
>>
>>103571725
Kek. I have tried in vain to get a Linear Programming formulation to solve part2. From what I recall, it'll probably work in something fancy like Gurobi, but that's "name your price" expensive.
>>
>>103571768
It means that the puzzle difficulty function doesn't have any jumps.
Therefore, none of the days can be called a "Great Filter".
>>
>>103571725
I posted that elephant
>>
File: diff.png (1.05 MB, 2345x2425)
1.05 MB
1.05 MB PNG
>>103571799
actually its a straight line so the difficulty didnt change at all
>>
comfy cnile solution
>>
>white blue black red green
>hidden text: "It really seems like they've gathered a lot of magic into the towel colors."
eric put a reddit the gathering reference inside the puzzle.
abandon ship. its over.
>>
>>103571758
day 6 and day 17 seem to be the biggest filters
>>
>>103571819
Retard
>>
>>103569362
those are gerbils
>>
File: ep.webm (3 MB, 625x539)
3 MB
3 MB WEBM
>>103571725
Very nice problem.
>>
>day 20
Surely Eric's brewing something devious for the start of the 20s?
>>
>>103571725
>math phd in amerimutt country
>cannot solve dp 101
Thank God I don't live in that 3rd world shithole
>>
File: img-2024-12-19-09-38-06.png (1.08 MB, 6016x2060)
1.08 MB
1.08 MB PNG
>day 19
>2nd easiest day
>>
>>103571928
>day 17
>extreme
It wasn't super difficult, per se, it just required you to find an abusable property of the data. The vagueness of what you're actually looking FOR caused the leaderboard to take a long time to fill up, since it takes a decent amount of time for a human to look at a large amount of data and find a pattern somewhere. Even then, you still had to program the rest of part 2 to actually abuse that pattern.
But I wouldn't call it extreme. Hard, sure, but probably not extreme.
>>
File: bigbrain.png (457 KB, 409x493)
457 KB
457 KB PNG
eric is putting ALL the hard problems at the end because filtering people early means less engagement and less donations
this was revealed to me in a dream
>>
>>103571994
I expect four gigafilters in a row, Eric. Don't let me down.
>>
>>103571994
>more than 90% are already filtered
cool dream
>>
>>103571994
>>103572002
There is not much time left
>>
>>103571863
>Day 6 checks the real understanding of Dijkstra's algorithm
>Day 17 checks emulation, math and the real understanding of the problem reduction concept
Seems legit.
>>
We've never had such easy problems this late, let alone two in a row. This is intentional. He's planning something.
>>
>>103572018
>Day 6 checks the real understanding of Dijkstra's algorithm
i just did a bfs, no dijkstras
>>
>>103571922
>Be Amerimutt George Dantzig
>Wow so smart
>Go work at RAND Corporation
>"Invent" Linear Programming
>Keep it "top-secret" because reasons
>Oh noes. Turns out some Russian Mathematician Kantorovich invented it decades prior.
>Probably by accident, in solving problems for the lumber industry.
>>
>>103572002
December 24th needs to be brutal.
>>
>>103571911
very cool
>>
>>103572044
>Kantorovich
>Russian
If one is REALLY generous they might say that he descended from Poland. But otherwise his ethnicity is pretty clear.
>>
>>103572067
To be fair, both Dantzig and Kantorovich were both chosen. I probably should have said Soviet anyways.
>>
File: carbon(18).png (1.02 MB, 1868x1354)
1.02 MB
1.02 MB PNG
Haskell solution.
Took 30 minutes more than it should have because I messed up my memoization the first time. Anyway.
>>
>>103571994
if true a chunk of us got filtered by him putting boring dogshit at the front
>>
File: 1708494291076049.png (397 KB, 1153x414)
397 KB
397 KB PNG
>>
File: img-2024-12-19-10-13-58.png (579 KB, 5332x2022)
579 KB
579 KB PNG
non-recursive idiomatic Rust solution
>>
>>103572164
>for_each
recursion
>>
>>103571928
>Be babby's first AoC with DEI-hire compatible problems
>Still filter 80% of /g/
>>
File: eric crt.png (24 KB, 1073x194)
24 KB
24 KB PNG
Mathbros, how do we respond without sounding mad?
>>
>>103572385
I don't know it either and I have no idea why some idiots keep bringing it up. I guess that all of them are filtered and need to consult Reddit to solve each year. Hell, I bet 90% of everyone who ever said "CRT" haven't even finished a year, let alone all of them.
>>
>>103572385
>how do we respond without sounding mad?
Submit the problem that requires CRT to >>103568870
>>
>>103572512
>>103572483
I haven't looked at it for a while, so I don't know about "required" but I used it for: https://adventofcode.com/2020/day/13 It's the one with the busses.
>>
>>103572483
algorithmtards are the biggest shitters, they just memorized a bunch of worthless garbage so they can sound smart
its like midwits who try to use fancy words, when actual intelligent people can explain things simply, or write their own simple algorithm
>>
>>103572540
>a bunch of worthless garbage so they can sound smart
This sounds like midwit cope.
>>
File: carbon (7).png (411 KB, 1568x1944)
411 KB
411 KB PNG
>>
>>103572530
My point isn't that it can't be used or that you shouldn't. My point is that filtered idiots typically tend to view puzzles like AoC as if there is some sort of trick to them, and they just need to study all the available tricks, pick the right one and use it to trivially solve the puzzle.

I know no such tricks, or algos. I just look at the data, look at the problem and think of how I can transform the data to give me the right answer and in doing so I many times do come up with the same methods as the "trick" users use, but the difference is that I actually understand the "trick", what problem it tries to solve, when and why it is useful.

As an example: I'm self taught and have been in the industry for many years in various different roles. The first time I encountered a DP problem was Day 12 2023, and I solved it by inventing DP right on the spot without knowing that there was such a thing as DP. I simply realized that a recursive solution would be easiest to write, and that I don't want to calculate the same thing twice. And still I see an incredible amount of people who have studied DP, used it solved problems and still have zero clue what they are doing and therefore get confused, get things wrong and write very complicated and messy code.
>>
File: Day19.png (83 KB, 830x688)
83 KB
83 KB PNG
C#. My solutions should be 200 line monstrosities by this point in the competition, this is almost disappointing.
>>
File: tabular-dp.png (527 KB, 1340x1118)
527 KB
527 KB PNG
>>
File: 20241219_191103552.webm (2.34 MB, 1280x720)
2.34 MB
2.34 MB WEBM
Day 10
>>
>>103572574
This is also because Eric doesn't design problems with extreme limits which necessitate best known methods.
>>
File: day10.png (279 KB, 1312x1745)
279 KB
279 KB PNG
>>103572594
And the code.
Such an easy day. Less lines than day1 and took less than an hour to write with the biggest problems being poor label naming and failing to link one of my branches.
>>
>>103572599
I have no problems handling the bigboys.
Sometimes it is good to look up best known methods when you hit a wall and just can't get your solution to run better and have no idea what you are doing wrong (in general I mean, shouldn't be needed for AoC). But then you at least (should) know what you are doing, why it doesn't work, what is slow, why, and what you really need.
>>
>i wasted a lot of time figuring out why my solution is wrong
>had to use long instead of int
I HATE ERIC
>>
>>103572619
So when does this year's AOC start getting fun
>>
>>103572594
>Day 10
filtered
>>
>>103572629
Whenever TGF anon posts.
>>
>>103572629
My bad I forgot to delete the reply
>>
File: 1733514350715659.jpg (132 KB, 926x907)
132 KB
132 KB JPG
functools to the rescue

from functools import cache
import sys

pinput = sys.stdin.readlines()
silver = 0
gold = 0

patterns = pinput[0].strip().replace(" ", "").split(',')
designs = list(map(str.strip, pinput[2:]))

@cache
def can_be_made(design: str) -> int:
if design == "":
return 1
rest = []
for p in patterns:
if design.startswith(p):
rest.append(design[len(p):])

works = list(map(can_be_made, rest))
return sum(works)

works = list(map(can_be_made, designs))
silver = sum([1 for d in works if d > 0])
gold = sum(works)

print(f"{silver = }")
print(f"{gold = }")
>>
>>103572658
>filtered by a table
>>
>my solution printed less correct designs than it should
>had a check for result > 0 then count up my total valid design
>had result as an int and it could overflow
ERIC YOU PIECE OF SHIT
worked after i changed everything from int to long
>>
>>103572668
which one of the rust solution is yours? I need a laff
>>
>>103572602
you could rack up some nasty number on hn if you made a blogpost about aoc on gba
>>
>>103572682 here: >>103572593
i thought i was using Python though
>>
File: aoc24_19.png (181 KB, 818x1251)
181 KB
181 KB PNG
Odin
Not much interesting other than passing the memo table using context.user_ptr
>>
I might get filtered by part 2, first design is taking way too long and there are few hudreds of them
do I just map how I reached each design up to this point? I think some strings of letters repeat in each design
>>
>>103572760
they overlap;
imagine these are your patterns: aa, bb, c, a, b, d
imagine you want to make this design: aabbcd
valid sequences:
aa, bb, c, d
a, a, bb, c, d
aa, b, b, c, d
a, a, b, b, c, d
notice how c, d is common to 4 sequences and bb, c, d and b, b, c, d are common to 2 sequences each
>>
>>103572760
part 2 is the same as part 1 though
>>
>>103572814
he can find one possible solution, but he's filtered by finding *all* possible solutions because he can't into caching or combinatorics
>>
fuck I'm late again, anyways what did Eric mean by this?
>>
>>103572619
That’s fine, but I think it’s a bit silly to dismiss algorithms as “worthless garbage”. Also most people aren’t name dropping these terms to “sound smart” it’s because it’s the easiest way of communicating an abstract idea. Say if a problem reduces to TSP, that’ll be understood without excess elaboration. The concept of “recursion” no doubt makes perfect sense to you, but to the “man on the street” it might sound like techbabble.
>>
>>103572843
>most people aren’t name dropping these terms to “sound smart”
they literally are
they dont understand the algorithms at all, they just copy paste them
see how many used shit like dijkstras on day 18
>>
>>103572843
>say if a problem reduces to teaspoon
what did he mean by this?

>>103572885
i'll have you know i read the whole cp-algorithms.com/graph/dijkstra.html article before using it to solve day 18
>>
>>103572594
Basedboy still being a chad.
nice. Leave some pussy for the rest of us please.
>>
>>103572670
If you just use the count down method you would not have this problem
>>
>>103572885
To anyone with some sort of background in computer science / math, saying “Dijkstra” is just common parlance. Like say Bellman-Ford or Floyd-Washall etc. It’s like talking about a “diffuser” to a Formula 1 mechanic, it sounds “fancy” but it’s very familiar.
>>
>>103572908
its capital TSP.
Thats a tablespoon
>>
>>103572941
here tablespoon is Tbsp
>>
File: aoc2024day18.gif (67 KB, 800x800)
67 KB
67 KB GIF
Yesterday's solution, Union find backwards
>>
>>103572958
>backwards
are you counting down?
>>
How clever was this implementation for my pattern searching, relatively speaking regardless of how easy the problem was:
>Combine all patterns together into a "dictionary" where for each level, it shows what letters can be at that position
>Each letter contains a dict that points to what letters it contains
>Any level that can be stopped at contains an additional key to show it
>When iterating through the string, check letter by letter in the dict, recording stop values in the dict in reverse order to iterate over later
It seems like it'd be pretty fast to me. Saves time having to iterate over every combination each time. Only trouble is my language doesn't have millisecond precision plus there's memorization so it's hard to quantify if this is faster than just string slicing and comparing and by how much if so
>>
>>103572936
We always called it "single source shortest path" at the university, knowing that there's an algorithm for it that is called the Dijkstra algorithm.
>>
>>103572962
I'm removing the last elements first
>>
>>103572966
very stupid; you only need an array:
patterns, designs = open(0).read().strip().split('\n\n')
patterns = set(patterns.split(', '))

p1 = p2 = 0
for design in designs.split('\n'):
n = len(design)
dp = [1] + [0]*n
for i in range(n):
for pattern in patterns:
m = len(pattern)
if design[i:i+m] == pattern:
dp[i+m] += dp[i]
p1 += bool(dp[-1])
p2 += dp[-1]

print(p1, p2)
>>
>>103572974
I know you can do that, I'm just wondering if it's faster than iterating over all patterns every time
>>
>>103572966
thats what I did here
>>103570963
use a dict-tree for prefix matching
>>
>>103572983
gut instinct says definitely not. memoisation is already a performance improvement on tabular for this problem.
>>
>>103572970
Because that’s more general. Dijkstra is only for non-negative weights.
>>
>>103572991
Oh well, maybe I'll try to just recreate both versions in Python and do a speed comparison tomorrow
>>
>>103572936
case in point
>>
>>103572995
what do you do for negative weights
>>
>>103573001
Bellman-ford.
>>
>>103573001
return -inf, unironically
>>
>>103572997
You’re retarded.
>>
>>103573004
>Bellman-ford
ty, will have a look
>>
>>103573013
midwit
>>
>>103572843
I don't dismiss algos, I dismiss idiots who use them as a trick without actually understanding what problem said algo really tries to solve
>>
>>103572997
listen here fuckface, that wasn't your point; you can't say case in point when someone isn't making a case for your point
>>
>>103573030
you literally just did prove my point
>>
>>103573026
Well when you explain what they solve, the retards call you midwit. It’s easier to just say the term, it’ll point them in the right direction. And for bonus points, you sound soooooo smart.
>>
>>103573030
FYI that anon is not me, the original anon you were talking to earlier back in >>103572619
. He's just a moron.
>>
>>103573034
i'm trans BTW incase that matters
>>
>>103573031
case in point
>>
>>103573033
I have no problems saying the terms either. What I have problems with is people using them as tricks, essentially turning them into black boxes for themselves. To such a person it is inconceivable to reinvent DP because you encountered a need for it. They don't understand data and data transformations, all they understand is "import solution"
>>
>>103573034
I wish me had IDs, would be easier to work out who we’re still talking to rather than inferring a TRANSITIVE REDUCTION over the reply GRAPH.
>>
>>103573053
>reply graph
actually it's more like a disjoint multi-linked list
it's productive to be specific
>>
>>103573053
>he doesn't just use his empath-over-text ability to predict anons next response before it happens, thereby knowing which post is from anon
>>
hmm yes this looks like an application of the Homos-SchwarzMann algorithm
indupitably
>>
>>103573048
For speed-coding, you want to limit the amount of original thinking as much as possible. The top guys just see a few patterns and spit out code which works, to this extent it may as well be a black box.
>>
>>103572958
oh nice can you share code?
>>
>>103573071
based
>>
>>103573048
@cache
stop me
>>
>>103573076
code:
>>103557892
>>
>>103573048
thats why I like golang, there are no tricks, you manually have to type out verbose code, so it is self evident what you are trying to do.
You have to be smart to use/understand it because there is no npn-import-solution to your problem
>>
>>103573074
Speedcoding yes, and I have great respect for them. But most aren't. They are just blackboxing themselves to stars.
>>
>>103573102
this is no different to other languages you retard
>wahhh @cache
@cache saves literally 4 lines of code
memo = {} # 1
def foo():
if state in memo: # 2
return memo[state] # 3
...
memo[state] = ans # 4
return ans

Go is cool but shut the fuck up
>>
File: idiomatic_calendar.png (3.81 MB, 7915x4026)
3.81 MB
3.81 MB PNG
this discussion is retarded
look at some idiomatic Rust code instead
>>
File: idiomatictrash.jpg (280 KB, 800x1137)
280 KB
280 KB JPG
>>103573126
>>
>>103573124
sure, but the go-programmer knows what those 4 lines does because he has to write it every time for every type, while the python-programmer doesn't know why his program is slow and just add @cache because he copy/paste it from somewhere.
I am agreeing with you here
>>
>>103573134
i'm an old soul, i love a nice pair of legs
>>
>>103573137
the C++ programmer also must cache
>>
File: xarbon.png (25 KB, 540x1188)
25 KB
25 KB PNG
finally made myself to wash d15
>>
File: day19.png (35 KB, 863x289)
35 KB
35 KB PNG
BQN day 19

Fairly easy today.
Can probably still simplify this a bit more.
>>
>>103573146
the C programmer must not only cache, but must also write the cache
does that not make them superior?
>>
Part 1
data = open("Day 19 input.txt", "r").read().strip().split("\n\n")

patterns = data[0].split(", ")

cache = {}
def solve(txt):
if txt in cache: return cache[txt]
for pattern in patterns:
if txt == pattern:
cache[txt] = True
return True
if txt.startswith(pattern):
if solve(txt[len(pattern):]):
cache[txt] = True
return True
cache[txt] = False
return False

total = 0
for i in data[1].split("\n"):
print i
if solve(i):
total += 1

print total

Part 2
data = open("Day 19 input.txt", "r").read().strip().split("\n\n")

patterns = data[0].split(", ")

cache = {}
def solve(txt):
if txt in cache: return cache[txt]
methods = 0
for pattern in patterns:
if txt == pattern:
methods += 1
elif txt.startswith(pattern):
methods += solve(txt[len(pattern):])
cache[txt] = methods
return methods

total = 0
for i in data[1].split("\n"):
print i
total += solve(i)

print total

Basic memoization, no other optimizations.
>>
>>103573203
this is washed?
>>
>>103573303
it does not *make* them superior, it *requires* them to be superior
>>
File: day19.png (34 KB, 894x323)
34 KB
34 KB PNG
>>103573237
Simplified, although it's about 20ms slower.
>>
File: image.png (229 KB, 1008x236)
229 KB
229 KB PNG
>>103571216
my humble BQN solution, golfed down to 6 lines

>>103571464
i was trying to work out a generalized `_memo` which would work on both monadic and dyadic function but that turned out to be a mess. this one works, but only for monadic functions.
>>
>>103573398
>simplified but slower
such is life
nice runes btw
>>
>>103573367
yes
>>
>>103573426
then why is it so ugly
>>
what are some cool days to visualise?
>>
>works on example
>doesn't work on input
...
>>
>>103573430
Sorry, I don't find plebbit spacing appealing.
A single function with no flags that solves both parts. How is this not washed?
>>
>>103573457
i dont know how to explain it to you, thats like trying to explain fine dining to someone who likes eating dog food out of a can
>>
>>103573457
because my solution is 46 lines of python? 71 is underwhelming
>>
>>103573461
I do like eating outside and out of a can. Not doog food though.
>>103573465
I come from the C++ world. I could reduce the line count at many places but that's not the point of washing is it? But if you're curious I could do that to see how far I can get.
>>
>>103573486
imo washing is simplifying the code and using language features to make it more terse
i'm not the anon who said your code was ugly, i'm just jumping in; you can do far better than 71
>>
>>103573498
>imo washing is simplifying the code and using language features to make it more terse
to me that is part of it, but it should also be elegant and beautiful to look at
>>
>>103573506
often the esoteric one-liner using `zip` is beautiful
>>
>>103572111
Beautiful theme, anon.
got a link?
>>
>>103573515
looks like Base 16 (Dark)
>>
>think I'm smart
>memoization plan wasn't adequate
>still testing the 8th line after 5 minutes
>>
File: old-ibm-datacentre.jpg (539 KB, 2560x1600)
539 KB
539 KB JPG
>>103573515
>>103573532
and the background
>>
part 1 and 2 were the same problem..... wtf?
>>
File: abr.gif (1.87 MB, 331x197)
1.87 MB
1.87 MB GIF
>get stuck on 3rd pattern of part 1
>rewrite code from scratch to use dp instead of a stack
>gets stuck again, same place
>check online
>"another piss easy day Eric's lost his touch"
>>
>>103573718
same thing happened to me until i saw the trick
>>
>>103573718
i can't think of anything to comfort you with this one...
we're just happy you're here

>>103573753
you just count down, right?
>>
>>103573718
it's the same as 2020-10. the DP, that is.
>>
>>103573864
it's sort of like 2023-04 as well.
>>
>>103573877
it's objectively easier than day 12 2023; less state variables, fewer recurrence relations, less base cases, etc.
what the fuck is eric thinking?
>>
>>103573864
>look back at my 2020-10
>it would have basically been a copypaste solution
Damn, I wish I remembered these things.
>>
>>103573896
idk bro. don't look at me. I'm more confused why people are using "recursion" at all when it's just two loops (3 with input loop)
>>
File: im-1734617118087.png (55 KB, 692x437)
55 KB
55 KB PNG
eric jogging us through a final victory lap with these cheesy easy puzzes.
>>
is calendar-anon filtered? what is the last version he created?
No, fuck off idiot rust calendar. Not talking about you, faggot
>>
>>103574013
see >>103573126
>>
>>103574013
He made one yesterday I believe
>>
is idiotmatic rust calendar anon filtered? what is the last version he created?

>>103573911
because midwits don't understand tabular dp
they don't understand recurrence relations or states either;
they just tweak their recursive brute-force until it works with their cache decorator
>>
>>103574048
see >>103574038
>>
>>103571589 (me)
Tried again and turned out I was just retarded and wrote the exit condition incorrectly. F# is pretty cool and is much faster than I remember it to be a few years ago. Especially the startup time.



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