• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Advent of Code 2020

 
Saloon Keeper
Posts: 13366
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:It was designed twenty year ago, when there was less understanding of the importance of immutability.


Honestly, even IF the collections hierarchy used proper read-only interfaces instead of optional methods, I would be super angry if the mutable interface that derives from the read-only interface didn't provide a mutable retainAll() method in addition to the immutable intersect() method. But maybe name it something like removeUnlessContainedBy().

At least they didn't mess up the naming so badly as Microsoft did with the .NET FCL. The immutable variant is called Intersect, the mutable variant is called IntersectWith and the method that tests whether two sets intersect is called Overlaps.
 
Stephan van Hulst
Saloon Keeper
Posts: 13366
295
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:I have dreadful time with Racket. Part 1 solved though.


I'll try to solve the bag problem with Racket too, even though I absolutely despise languages derived from Lisp.
 
Stephan van Hulst
Saloon Keeper
Posts: 13366
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:Straight forward enough today, although I do feel like we're building some foundations for something bigger soon. I'm expecting to need a few bits and bobs from previous solutions to solve new ones.


Agreed. It looks very similar to the language we had to write processors for last year. I'll see if I can reuse some of the code for the harder problems.
 
Bartender
Posts: 4667
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the retainAll question popped up after: Stream.reduce((l, m) -> l.retainAll(m)), which gave an error. But it is not that bad, just used: (l, m) -> {l.retainAll(m); return l;}; problem solved.
 
Sheriff
Posts: 8090
569
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:

Liutauras Vilda wrote:I have dreadful time with Racket. Part 1 solved though.


I'll try to solve the bag problem with Racket too, even though I absolutely despise languages derived from Lisp.


I knew the logic behind I wanted to follow, just couldn't achieve it technically. It reminded me exercise from some of previous years, and I had it solved with Racket back then with nice recursion and some maping functions to map key to all possible paths it derives to (I don't have those previous AoC codes anymore, deleted for whatever reason) - but just couldn't wrap my head around this time. Then I did for what I don't proud at all by using mutable hashtable... well, nothing concrete explain, that was mess.
 
Piet Souris
Bartender
Posts: 4667
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone better than Brute Force in part B?
 
Stephan van Hulst
Saloon Keeper
Posts: 13366
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the instruction processor? No, brute force is fine.
 
Stephan van Hulst
Saloon Keeper
Posts: 13366
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piet Souris wrote:Well, the retainAll question popped up after: Stream.reduce((l, m) -> l.retainAll(m)), which gave an error.


The real issue is using mutators in an immutable reduction operation.
 
Piet Souris
Bartender
Posts: 4667
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And thus?
 
Stephan van Hulst
Saloon Keeper
Posts: 13366
295
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And thus nothing. I think we had this discussion once before. I'll tell you that your lambda expression violates the contract of the reduce() method, and you'll say you don't care as long as it works.
 
Piet Souris
Bartender
Posts: 4667
183
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.
 
Liutauras Vilda
Sheriff
Posts: 8090
569
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Conversation guys, you made me laugh
 
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had a good chuckle at that too 😂
 
Piet Souris
Bartender
Posts: 4667
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why o why do I get so little points for my hard work?? The distance grows exponentially...
 
Liutauras Vilda
Sheriff
Posts: 8090
569
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Piet, I bet you have IntSummaryStatistics summaryStatistics() for your part2.
 
Piet Souris
Bartender
Posts: 4667
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I didn't!

I did give it a thought, but it seemed hopelessly inefficient. I now have a reasonably efficient way of finding the sum of N consecutive elements, and finding the correct answer, I determined min and max "by hand".

I must admit, I had some trouble with those off-by-one thingies.
 
Liutauras Vilda
Sheriff
Posts: 8090
569
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piet Souris wrote:Why o why do I get so little points for my hard work?? The distance grows exponentially...


There is only one hope for us - that somebody get suck on some problem and we somehow manage to solve it.

Tim won't stuck anymore, because we passed day 7 already.
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:Tim won't stuck anymore, because we passed day 7 already.


Don't jinx it for me
 
Master Rancher
Posts: 4052
56
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
w00t!  I was finally first to answer one, for both parts!  Well, in this leaderboard. Better enjoy it while I can.    
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congrats Mike!

For part 2 I was thinking that I'd need to do some really elaborate recursive thing requiring memoization to make it complete within any kind of reasonable time. But then I figured out a way to do it with a single pass of the input. Pretty chuffed with myself to be honest.
 
Piet Souris
Bartender
Posts: 4667
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:Don't jinx it for me


That fine Google Translate translated 'jinx' into the Dutch(?) 'jinx'. So, still no clue as to what that means!.
 
Piet Souris
Bartender
Posts: 4667
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:w00t!  I was finally first to answer one, for both parts!  Well, in this leaderboard. Better enjoy it while I can.    


Hmm... congratulations... I wonder: don't these good people from here ever sleep? Getting desparately behind, this way.
 
Piet Souris
Bartender
Posts: 4667
183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:For part 2 I was thinking that I'd need to do some really elaborate recursive thing requiring memoization to make it complete within any kind of reasonable time. But then I figured out a way to do it with a single pass of the input. Pretty chuffed with myself to be honest.


Yep, the algo has a famous name. I had a little trouble implementing it.

By the way: did anyone check whether it was possible in the first place to form a chain?
 
Mike Simmons
Master Rancher
Posts: 4052
56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piet Souris wrote:

Tim Cooke wrote:For part 2 I was thinking that I'd need to do some really elaborate recursive thing requiring memoization to make it complete within any kind of reasonable time. But then I figured out a way to do it with a single pass of the input. Pretty chuffed with myself to be honest.


Yep, the algo has a famous name. I had a little trouble implementing it.


Hm, what's the name you're thinking of, do you remember?  My experience was similar to Tim's, except I had quickly built a recursive solution, and then while I was waiting for it to complete (and realizing how slow that could be), I thought of a better way to do it.  I didn't recognize it as a known algorithm, but it seemed the "obvious" way to do it once looking at the problem from the right angle.  Which is to say, not obvious at all from other angles.

Piet Souris wrote:By the way: did anyone check whether it was possible in the first place to form a chain?


I didn't explicitly check it separately, but I looked at the sorted list of joltages, and the differences there between successive elements.  The fact that there were no gaps bigger than 3 jolts meant it was possible.  To me part 1 was very quick; it was part 2 that bogged down.
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piet Souris wrote:That fine Google Translate translated 'jinx' into the Dutch(?) 'jinx'. So, still no clue as to what that means!.


It roughly means the action of ruining something by saying it's going well. So Liutauras saying that I'm not going to get stalled will immediately cause me to get stalled.
 
Mike Simmons
Master Rancher
Posts: 4052
56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piet Souris wrote:I wonder: don't these good people from here ever sleep? Getting desparately behind, this way.


Yeah, usually I've had other things going on when they're posted, and don't get to them until the next morning.  Sometimes, I can look into them right away.  I figure our overall rankings are a combination of (a) how fast/smart/experienced we are, and (b) how well our personal situations lend themselves to putting time into this sort of thing, and how soon.  While we can be proud of part (a), part(b) is really something that varies widely from person to person and from day to day, often outside our control.  So, it's not healthy to worry too much about those rankings.  On the other hand, past history suggests that what will be more relevant is how many of the tough later problems we get through.  Some of those are monsters.
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agree that as the month moves on completion will have a much greater influence on the leaderboard over speed. Today was the first day where only some of the possible solutions are not without completion run time problems. I expect there to be more of those coming.
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sree, are you ok?
sree-leaderboard.png
[Thumbnail for sree-leaderboard.png]
 
Liutauras Vilda
Sheriff
Posts: 8090
569
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without having started problem yet, I recognize it already. I'm sure you all do too.
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes indeed. It's very similar to Conway's Game of Life. I'm glad that I took a notion to do it earlier in the year just because I never had before.
 
Liutauras Vilda
Sheriff
Posts: 8090
569
Mac OS X VI Editor BSD Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, I too appreciate, mine one was just couple of years ago: https://coderanch.com/t/700311/code-reviews/engineering/version-Conway-Game-Life

Tim, you're doing really great this year.

If that's what you call jinx'ing, then...

Tim, you're doing really great this year.
Tim, you're doing really great this year.
Tim, you're doing really great this year.
Tim, you're doing really great this year.

 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not cool Liutauras, not cool.
 
Piet Souris
Bartender
Posts: 4667
183
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agree with Tim: that is not cool...

But Liutauras, you are doing great too!

So

Liutauras, you're doing really great this year.
Liutauras, you're doing really great this year.
Liutauras, you're doing really great this year.
Liutauras, you're doing really great this year.

 
Liutauras Vilda
Sheriff
Posts: 8090
569
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agreed, not cool, my apologies, gentlemen.

Today I spent a significantly more time than I thought I will just because the test input was square (where things worked for me and produced correct output), and so I made the same assumption about the actual input, and if I were lucky, I should have had index out of bounds at some point, but I didnt, because I used row.length,  and it was the shorter of the two (-6), so algorithm operated on trimmed input. Spent whole lunch just looking for that.
 
Stephan van Hulst
Saloon Keeper
Posts: 13366
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JJ, I see yesterday's second part gave you some pause. Need any pointers?
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The puzzles are definitely easier this year.
 
Stephan van Hulst
Saloon Keeper
Posts: 13366
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really hate that my brain has such problems dealing with the range [-𝜋, 𝜋] of the angle 𝜃 that atan2(y,x) returns, even though the math is exactly the same it would be when the polar angle 𝜃 of my coordinates was expressed in the range [0, 2𝜋].
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ooh that's fancy
 
Stephan van Hulst
Saloon Keeper
Posts: 13366
295
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any word from Sree, Tim?
 
Tim Cooke
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, she's ok. Just not keeping right up to date with AoC.
 
reply
    Bookmark Topic Watch Topic
  • New Topic