Skip to content

Add Modular Arithmetic approach to RaindropConverter#3144

Merged
kahgoh merged 18 commits into
exercism:mainfrom
habere-et-dispertire:patch-1
Jun 27, 2026
Merged

Add Modular Arithmetic approach to RaindropConverter#3144
kahgoh merged 18 commits into
exercism:mainfrom
habere-et-dispertire:patch-1

Conversation

@habere-et-dispertire

@habere-et-dispertire habere-et-dispertire commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Pull Request

This looks a little more visual in raku with multi-dispatch supporting built-in types:

multi fizz-buzz ( 1) { <                   > }
multi fizz-buzz (36) { < Pling             > }
multi fizz-buzz (85) { <       Plang       > }
multi fizz-buzz (91) { <             Plong > }
multi fizz-buzz (15) { < Pling Plang       > }
multi fizz-buzz (21) { < Pling       Plong > }
multi fizz-buzz (70) { <       Plang Plong > }
multi fizz-buzz ( 0) { < Pling Plang Plong > }

sub raindrop ($heard) {

    [~] fizz-buzz $heard¹² mod 105 or ~$heard

}

I think it's a fun way to explore deeper into a generalized mathematical approach since it shows that this approach works also with a change in factors so long as they remain co-prime.


Reviewer Resources:

Track Policies

Comment thread exercises/practice/raindrops/.approaches/introduction.md Outdated
Comment thread exercises/practice/raindrops/.approaches/introduction.md Outdated
Comment thread exercises/practice/raindrops/.approaches/introduction.md Outdated
Refactor switch statement to use enhanced switch expression syntax. Note similarity to Fizz Buzz.

@jagdish-15 jagdish-15 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You'll also need to create a dedicated directory for this approach inside the .approaches folder and register it in .approaches/config.json.

You can refer to the existing approaches for the expected structure and configuration.

@habere-et-dispertire

Copy link
Copy Markdown
Contributor Author

I've made the changes suggested, created the folder structure and mimicked the other approaches. 🤝

Comment thread exercises/practice/raindrops/.approaches/config.json Outdated
Comment thread exercises/practice/raindrops/.approaches/introduction.md
Comment thread exercises/practice/raindrops/.approaches/modulus/snippet.txt
Refactor switch cases in raindrops snippet for clarity.
Comment thread exercises/practice/raindrops/.approaches/modulus/snippet.txt
Comment thread exercises/practice/raindrops/.approaches/introduction.md Outdated
Comment thread exercises/practice/raindrops/.approaches/modulus/content.md Outdated
Comment thread exercises/practice/raindrops/.approaches/introduction.md
Comment thread exercises/practice/raindrops/.approaches/config.json Outdated
Comment thread exercises/practice/raindrops/.approaches/modulus/content.md Outdated

@jagdish-15 jagdish-15 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few more changes before we merge

Comment thread exercises/practice/raindrops/.approaches/introduction.md Outdated
Comment thread exercises/practice/raindrops/.approaches/modulus/content.md Outdated
@jagdish-15 jagdish-15 requested a review from kahgoh June 27, 2026 05:29
@kahgoh kahgoh merged commit 641ae34 into exercism:main Jun 27, 2026
3 checks passed
@habere-et-dispertire habere-et-dispertire deleted the patch-1 branch June 27, 2026 12:00
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