Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add saddle-points exercise #118

Merged
merged 3 commits into from
Sep 28, 2024
Merged

Add saddle-points exercise #118

merged 3 commits into from
Sep 28, 2024

Conversation

ageron
Copy link
Contributor

@ageron ageron commented Sep 24, 2024

No description provided.

@ageron
Copy link
Contributor Author

ageron commented Sep 25, 2024

My solution is really verbose. Sometimes I don't really know how to solve a simple problem without a full page of code in Roc, with a lot of error handling. I mean here's the equivalent code in Python, it took me about 2 minutes to write. I'm not quite there yet in Roc:

matrix = [[1,5,3],[1,4,3],[1, 2, 2]]
result = [{"row": y + 1, "column": x + 1} for (y, row) in enumerate(matrix) for (x, val) in enumerate(row)
if val == max(row) and val == min((0 if len(r) < x else r[x]) for r in matrix)]

@Anton-4
Copy link
Contributor

Anton-4 commented Sep 26, 2024

Thanks for bringing this up @ageron, I've created roc-lang/roc#7118 for this.

Copy link
Contributor

@isaacvando isaacvando left a comment

Choose a reason for hiding this comment

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

Unfortunately I don't have any immediate suggestions for making the code more terse. I will say that these kind of 2d array problems always seem very annoying in functional languages. Otherwise, looks good!

exercises/practice/saddle-points/.meta/Example.roc Outdated Show resolved Hide resolved
@ageron ageron merged commit 731b01d into exercism:main Sep 28, 2024
2 checks passed
@ageron ageron deleted the add-saddle-points branch September 28, 2024 07:36
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.

3 participants