Skip to content

Add Modular Arithmetic approach to RaindropConverter#3144

Open
habere-et-dispertire wants to merge 10 commits into
exercism:mainfrom
habere-et-dispertire:patch-1
Open

Add Modular Arithmetic approach to RaindropConverter#3144
habere-et-dispertire wants to merge 10 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

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
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
[remainder-operator]: https://www.geeksforgeeks.org/modulo-or-remainder-operator-in-java/
[approach-if-statements]: https://exercism.org/tracks/java/exercises/raindrops/approaches/if-statements
[approach-map]: https://exercism.org/tracks/java/exercises/raindrops/approaches/map
[approach-modulus]: https://exercism.org/tracks/java/exercises/raindrops/approaches/modulus

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.

The last part of the URL should match the slug in the config

Suggested change
[approach-modulus]: https://exercism.org/tracks/java/exercises/raindrops/approaches/modulus
[approach-modulus]: https://exercism.org/tracks/java/exercises/raindrops/approaches/modular-arithmetic

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Should be okay now no (since I changed the slug) ?

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