𓁟 host1.bitchan.one

>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 22 hours and 37 minutes remain.

⧖expiring0/63 kept1d ago

𓀐 @GgfKxzY3

⏱ 2d 👍 0

⬆ upvote 0

[⇥] sort oldest ⏱
filter [-]
𓀐 @xZ3PqavB: Can AI make fun programming puzzles yet?+

⬆ upvote 0↩ reply 0

𓀐 @eMquV3hL: Lmao nigga what kinda GRAMPS does crossword puzzles? How that apple sauce taste this morning lmao!+

⬆ upvote 0↩ reply 0

𓀐 @eEA~NMnX: I'm stoked.+

⬆ upvote 0↩ reply 0

𓀐 @3rZFZ4nS: damn, for some reason I'm not hyped this year.. I think AI made me dislike coding?+

⬆ upvote 0↩ reply 0

𓀐 @NjPHGznY: Sometimes the slop is good.+

⬆ upvote 0↩ reply 0

𓀐 @CmHi~jPJ: The Great Christmas Light Synchronization Puzzle (Difficulty: 5/10) (Programming · Algorithms · Logic) The Story It's Christmas Eve, and Santa's workshop is having a little technical difficulty! The Christmas lights across the North Pole are controlled by a magical system. Each string of lights has a timer that determines when it turns on and off. Unfortunately, the timers are all out of sync, and Santa needs your help figuring out when all the lights will be ON at the same time. Each light string follows this pattern: It turns ON at time 0. It stays ON for a certain number of seconds. It turns OFF for a certain number of seconds. It repeats this cycle forever. Your job is to find the first time after time 0 when every string of lights is ON simultaneously. The Challenge You're given a list of light strings. Each string has: on: How many seconds the lights stay ON. off: How many seconds the lights stay OFF. For example: python lights = [ {"on": 3, "off": 2}, {"on": 4, "off": 3}, {"on": 2, "off": 4} ] This means: Light string ON OFF Total cycle 1 3 sec 2 sec 5 sec 2 4 sec 3 sec 7 sec 3 2 sec 4 sec 6 sec Your task Write a function: python def find_synchronized_time(lights): pass It should return the earliest positive integer time when all light strings are ON simultaneously. If they never synchronize, return -1. Example walkthrough For the example above: Light 1 is ON during: 0–3, 5–8, 10–13, ... Light 2 is ON during: 0–4, 7–11, 14–18, ... Light 3 is ON during: 0–2, 6–8, 12–14, ... The first time after zero when all three are ON is 7? Wait! At time 7: Light 1: ON Light 2: ON Light 3: ON (Expected output: 7)+

⬆ upvote 0↩ reply 0

𓀐 @fzVHYw2Q: don't worry guys this year will finally be intcode 2 and advent of code will be completely redeemed+

⬆ upvote 0↩ reply 0

𓀐 @j5jhJ_fT: >every year the early threads are full of "i'm going to do AoC in x language this year" >by week two it's like 99% python people, maybe a few people doing it in rust or julia+

⬆ upvote 0↩ reply 0

𓀐 @ijxT5zkW: i skipped the story, what's the deal this year+ 1

⬆ upvote 0↩ reply 1

𓀐 @T4Zqo2tG: bigboy #1 url: https://files.catbox.moe/mxtzl9.7z lines: 17044061 silver: 57068430797700 gold: 941654718771813+

⬆ upvote 0↩ reply 0

𓀐 @u77XV9s~: We gotta oversee the thingamabob.+

⬆ upvote 0↩ reply 0

𓀐 @t3m6utY3: >MAX_SIZE everytime, see #12+

⬆ upvote 0↩ reply 0

𓀐 @J-*J4aJm: you can tell who the redditors are because they screenshot a 10 line code snippet instead of code-blocking it+

⬆ upvote 0↩ reply 0

𓀐 @FPf+~nuX: reading the file char by char isn't super ideal since the input is split into lines. don't roll your own string to int shit, atoi exists for a reason. same for quicksort, it exists in the stdlib for a reason.+

⬆ upvote 0↩ reply 0

𓀐 @tBEfG8D*: /aocg/ memes ranked by retardedness: 1. unwashed ass 2. showtime cancer music 3. FUCK 4. retards who outsourced their thinking to AI 5. retards not being able to read and then blaming eric 6. retards coming into the threads and LARPing as non-neets who are too busy getting paid 100 bucks / hour to waste their time doing AoC 7. retards claiming that you aren't filtered if you've spent more than 1 hour on a problem or if you've looked at other solutions 8. code screenshots with tranime background 9. big boys that change the rules of the problem 10. code screenshots made with carbon without disabling window controls 11. calendar 12. cniles posting their shit code with fixed sized arrays, integer overflows, etc. 13. quirky solutions (e.g. excel)+

⬆ upvote 0↩ reply 0

𓀐 @ZU5Hgx5~: I used to plan my whole life around this event, now I don't feel like I could even bother to read the first problem, what is the point. why have a leaderboard when people who use AI are guaranteed to be first why care about "being filtered" when you can just ask AI for the solution why have a discussion thread when you can just ask AI for hints+

⬆ upvote 0↩ reply 0

𓀐 @cERASVUD: claude solve all the pointless jeetcode for me so I can back to day trading+

⬆ upvote 0↩ reply 0

𓀐 @QcqWwasM: is he just doing 12 again this year? or do we get the full advent season? stoked but i do miss the earlier years this captcha is cursed btw fuck+

⬆ upvote 0↩ reply 0

𓀐 @-C5C4Y9i: Hey /g/! I haven't been to this godforsaken place since the last Advent of Code. What did I miss?+ 2

⬆ upvote 0↩ reply 2

𓀐 @7TCXW59D: >sort this list of ids holy fuck aoc is dead+ 1

⬆ upvote 0↩ reply 1

𓀐 @ukV?qagY: naive c implementation, actually like this better than my shitty rushed c++ version i used to actually get my answers+

⬆ upvote 0↩ reply 0

𓀐 @LvF_*-xP: Less than 15k people have attempted day 1. It is so dead this year.+

⬆ upvote 0↩ reply 0

𓀐 @8pqAgBxt: edition 1: >Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other. https://adventofcode.com/ /g/ leaderboard join code: 224303-2c132471 anonymous-only leaderboard: 383378-dd1e2041 lets hope eric does not phone it in this year+ 35

⬆ upvote 0↩ reply 28

𓀐 @sWtuUikQ: >lets hope eric does not phone it in this year too late+

⬆ upvote 0↩ reply 0

𓀐 @ee7zpPdA: Digits and we actually get the full 12 puzzles this time.+ 1

⬆ upvote 0↩ reply 1

𓀐 @Ruu~V2rq: interesting use of chunk_by. I usually use https://docs.rs/itertools/0.15.0/itertools/trait.Itertools.html#method.coalesce for something similar, but chunk_by seems to work the way I'd expect for this problem so I can drop it. thanks for the idiomatic solution, bro.+ 1

⬆ upvote 0↩ reply 1

𓀐 @nWz-tr8h: oops, meant to quote OP+

⬆ upvote 0↩ reply 0

𓀐 @vXetGGYH: Obviously this problem is trivial to do in linear time but it might be interesting to do it in better than linear space. Maybe you'd have to use a frequency estimating algorithm to do it? That can get you part 1 at least, but part 2 might be weird unless you make assumptions about the input+

⬆ upvote 0↩ reply 0

𓀐 @8xL9-_CH: >import solution from collections import Counter from functools import reduce from operator import mul with open('p01.txt') as fh: nums = Counter(int(l) for l in fh.readlines()) mc = [n for n, _ in nums.most_common()] print(reduce(mul, mc[:3])) print(reduce(mul, mc[-3:])) why does he bother with these day 1 shits. if there's only 12 days fuckin lets go+ 1

⬆ upvote 0↩ reply 1

𓀐 @pabLfZtD: day 1 sloppa+ 2

⬆ upvote 0↩ reply 2

𓀐 @?+DW4UdX: Going from reviewing vibecoded pull requests all year at work to working on an AoC problem in a language I like because it's declarative and visually pleasing feels like the cheeseburger scene in The Menu.+ 1

⬆ upvote 0↩ reply 1

𓀐 @~T~tsm4x: bigboy #1 url: https://files.catbox.moe/mxtzl9.7z lines: 17044061 silver: 57068430797700 gold: 941654718771813+

⬆ upvote 0↩ reply 0

𓀐 @2ZnEbekU: beef wins again, too easy+

⬆ upvote 0↩ reply 0

𓀐 @oVVSRGtS: >Iterator::by_ref ? use slice::sort_by_key, Iterator::take, and Iterator::product+

⬆ upvote 0↩ reply 0

𓀐 @yae2e3Xm: >just parse invalid input bro >just ignore errors bro dumb retard+

⬆ upvote 0↩ reply 0

𓀐 @d64CPm?h: thread full of halfwits, lmao >sorting why are you sorting? stupid+

⬆ upvote 0↩ reply 0

𓀐 @t?*aS?iV: is aoc unironically dead? used to be way more posters and they used to have many threads leading up to the actual day doing previous years problems.+ 1

⬆ upvote 0↩ reply 1

𓀐 @+qYsWtYC: >the whole board and chan kind of is what triggered that?+

⬆ upvote 0↩ reply 0

𓀐 @siQKNB6i: do you know how to find the largest integer in an array, without sorting it? if the current largest item gets promoted, then what it was previously, would currently be the next largest and so on. very simple stuff, anon. just a linear scan and some checks, no quickselect pivot crap, no min heap sillyness.+

⬆ upvote 0↩ reply 0

𓀐 @QB5XDmJm: I wanna use different languages for each day this year as a break from c. Any sugestions?+

⬆ upvote 0↩ reply 0

𓀐 @x68vnNW2: I'd like to announce me being unfiltered by last year's day 10. Did it before christmas so it counts. https://files.catbox.moe/u996c1.png Looking back I really really should have used rational arithmetic. Maybe this year.+

⬆ upvote 0↩ reply 0

𓀐 @cUNrdL*p: I'm sick of all the idiomatic solutions. give me a IDIOTIC solution+

⬆ upvote 0↩ reply 0

𓀐 @7CCgFHcD: last year, even though we didn't have the global leaderboard, i could've sworn the "personal stats" page still showed your rank but it's not there anymore, just your "personal times". am i misremembering?+

⬆ upvote 0↩ reply 0

𓀐 @rPyJ?7CJ: A robot with program roygbv would travel a total distance of 11. No it fucking wouldn't. Let's frame it in the same way as the prior example. roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv ^ initial robot position roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv ^ robot travels distance 1 to next orange waypoint roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv ^ robot travels distance 1 to next yellow waypoint roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv ^ robot travels distance 1 to next green waypoint roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv ^ robot travels distance 1 to next blue waypoint roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv ^ robot travels distance 1 to next blue waypoint After these instructions, the robot has traveled a total distance of 5. THAT'S IT I wasted 15 minutes debugging part 1 before I realized the second fucking example is just wrong.+

⬆ upvote 0↩ reply 0

𓀐 @NrpKPfQn: bigboy #2 url: https://files.catbox.moe/mhw4zx.7z size: 142M silver: 558275033 gold: 893216516+

⬆ upvote 0↩ reply 0

𓀐 @WawQJ82K: sorry fellas, catbox shat the bed bigboy #2 url: https://gofile.io/d/b9mffmvi size: 142M silver: 558275033 gold: 893216516+

⬆ upvote 0↩ reply 0

𓀐 @-Q9b~nUV: All of your part 2s are wrong+

⬆ upvote 0↩ reply 0

𓀐 @k=S2p?8R: Yep, there is a typo. It should be p2 * 6 - 5.+

⬆ upvote 0↩ reply 0

𓀐 @zMqaqKkA: most solutions you guys come up with are ugly. the numerical solvers should piss off to /sci/+

⬆ upvote 0↩ reply 0

𓀐 @n7?RY3QA: >Most of my leaderboard rivals from last year are not participating this year (HiggstonRainbird, Oresama, mid-kid, sin-ack) >No twitch thot streaming "her" solutions >No ASM anon >No looking-for-internship >Only 2 threads in 2 days Very quiet this year.+

⬆ upvote 0↩ reply 0

𓀐 @2ZUuNgX3: am I the only one who bothered with the "no color in input" edge cases?+

⬆ upvote 0↩ reply 0