Skip to content

Conversation

@KaranChadha10
Copy link
Contributor

Summary

Converts the parallel-letter-frequency exercise from using PLINQ (AsParallel()) to proper async/await patterns with Task.Run and Task.WhenAll.

Changes Made

  • Method signature: Changed Calculate to return Task<Dictionary<char, int>> instead of Dictionary<char, int>
  • Tests: Updated all test methods to use async Task and await the Calculate method
  • Implementation: Replaced AsParallel().Aggregate() with Task.Run + Task.WhenAll for better async/parallel demonstration
  • Code structure: Separated concerns with dedicated helper methods for counting and merging

Issue link: #1894

@github-actions
Copy link
Contributor

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@github-actions
Copy link
Contributor

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this Sep 28, 2025
@ErikSchierboom
Copy link
Member

@KaranChadha10 CI is failing

@KaranChadha10
Copy link
Contributor Author

@ErikSchierboom sure let me check.

@KaranChadha10 KaranChadha10 force-pushed the fix/async-parallel-letter-frequency branch from 5e61a96 to c72349a Compare October 4, 2025 13:53
@KaranChadha10
Copy link
Contributor Author

@ErikSchierboom I've now updated the code. The checks should be passing now.

Please let me know if there's anything else that needs adjustment!


[Fact(Skip = "Remove this Skip property to run this test")]
public void One_text_with_one_letter()
[Fact]
Copy link
Member

Choose a reason for hiding this comment

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

Could you re-add the skips on all but the first test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, @ErikSchierboom kindly review, thanks.

@ErikSchierboom ErikSchierboom merged commit 9082055 into exercism:main Oct 5, 2025
3 checks passed
@ErikSchierboom
Copy link
Member

Thanks!

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.

2 participants