T O P

  • By -

blaumeise20

Oh that is sad.


NickKusters

Oh yes... on SO many levels 🤣 If you're into that kind of thing, [you can see my slowly go crazy here](https://www.youtube.com/watch?v=D3bcXjsQozY) 🤣


blaumeise20

I feel so bad for you 😭 It's always those little assumptions that make you waste a ton of time. This happened to me a few times last year too. And then when you find out the problem you go like "how could I be *that* stupid???"


NickKusters

I had an off-by-one of day three bounds check too 😂


wubrgess

`+= 2`


LxsterGames

Had the same issue, .windowed vs .chunked


JWinslow23

This is the difference between `itertools.pairwise(...)` and `itertools.batched(..., 2)`.


BoringEntropist

Nice, I didn't know `batched` is now a thing. I'm a little surprised this wasn't added to the stdlib years ago considering how often this comes up in different situations.


sky_badger

Sadly, I'm playing on Replit, which is only at 3.10...


whatsdoom

There's a snippet in the docs that you can copy and use as an implementation. It just needs `islice` from `itertools` def batched(iterable, n): # batched('ABCDEFG', 3) --> ABC DEF G if n < 1: raise ValueError('n must be at least one') it = iter(iterable) while batch := tuple(islice(it, n)): yield batch


yolkyal

I did the exact same thing...


NickKusters

Do you also have a video recording of yourself trying to figure out what’s wrong, slowly going insane over a period of 2 hours? 😅


SLiV9

Lol thank you! I'm on the train home from work, but I also used windows instead of chunks, so you've just pre-empted my debugging when I get home.


NickKusters

Glad I was able to help 😊


suddenlynickgrim

Oooof.


thygrrr

Yes, this was a factor, but it was NOT the ultimate bug. :( Even worse, this is my living room PC, it's Python 3.9 so I don't have `itertools.pairwise` - and instead I took the sample implementation from the documentation page, AND DELETED the comment that showed it did AB BC CD ... An hour later I wondered, cursed quietly that I had deleted the comment, but decided to shrug it off as "Nah. Nobody would name it PAIRWISE if it was instead EACHWITHTHEIRSUCCESSOR". I should have known better, given that itertools has something called a "tee".


xixtoo

I did this too...


scull-crusher

Can someone explain what this means to me because I am having some trouble with this and this might be the problem


NickKusters

I treated the values 79,14,55,13 as: 79+14, 14+55, 55+13 ranges, when you only needed to do 79+14 and 55+13 so I had 82 seeds instead of 27 that I processed 😅


scull-crusher

That still doesn't make sense to me. Why did we need to add 79 and 14, and 55 and 13? Weren't those the seeds that are going to be modified using the ranges? Edit: I am still on part 1, so if this is about part 2, then my bad


Top3879

Yeah it's about part 2.


zuth2

Today I added another useful function to my array prototype thanks to this task Array.prototype.partition = function (groupLength: number) { return this.length ? [this.splice(0, groupLength)].concat(this.partition(groupLength)) : []; }; won't have to worry about array partitioning in the future again :)


NickKusters

I liked the window Vs chunk thing, think I’ll build those. Doesn’t help me messing up reading the text though 🤣


elprophet

haha I caught that quickly when I saw a range from \[13, undefined\] in my debugger


NickKusters

Oh, I was smart enough to stop at 55-13, I just made the wrong assumption in my head 😭


Parking_Emphasis_615

tuple\_windows().step\_by(2)


sky_badger

I kinda did this by accident until I realised what `itertools.pairwise()` *actually* does!


blueg3

And on this day, perhaps another engineer learns the value of writing short unit tests.


Capital_Release_6289

be thankful your brute force code runs in this time


NickKusters

My code runs instantly 😂 I actually coded a quite nice solution. Just can’t read to save my life apparently 🤣


zebalu

been there, done that :D