Skip to content

Conversation

@TheDrawingCoder-Gamer
Copy link
Contributor

No description provided.

@SethTisue
Copy link
Collaborator

I requested reviewers on Discord, I suggest merging on Monday if there are no blockers by then

@RypoFalem
Copy link

Alright, now the hard part: intersection and union.
We'll need to add a couple methods to LRange to handle intersection and union:

I don't think this deals with unions at all. I think this is meant to say difference?

Copy link

@Kevincav Kevincav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice setup, I like the simplicity.


Part 2 is a lot more complicated, but I've done [much worse](https://adventofcode.com/2021/day/22), so it wasn't too bad.

My common library has implementations for ranges that can intersect and combine with each other, but I'll reimplement them here
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little curious, why implement a new range over NumericRange?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NumericRange throws if your range is larger than the int limit - will add explanation to docs

```scala
type Input = (List[LRange], List[Long])

final case class LRange(start: Long, end: Long):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you should be excluding this from the file, then just use a common library that you import, and describe the logic there. I also understand having all logic in one file so you don't need prior knowledge (or dig into another file), but it would be cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blog post format requires we only use scala 3 standard library and include any and all code in the result

Comment on lines 181 to 182
// toIterator to prevent Set from deduplicating our result
combinedRanges.toIterator.map(_.size).sum

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the writeup, I think it's written well! Minor nitpick: I believe .toIterator has been deprecated since 2.13, and should be replaced with .iterator instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has???? will fix that

@TheDrawingCoder-Gamer
Copy link
Contributor Author

I still want to do some work on the linked Diet sample so can you hold off on merging until I'm ready?

@TheDrawingCoder-Gamer
Copy link
Contributor Author

alright no complaints from me anymore

@SethTisue SethTisue merged commit 1a4ee6b into scalacenter:website Dec 8, 2025
@SethTisue
Copy link
Collaborator

thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants