primeiro commit com exercicios de Exercism realizados até esta data

This commit is contained in:
2026-10-17 22:10:27 +01:00
commit 58fccbe27a
708 changed files with 35038 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
{
"authors": [
"nathany"
],
"contributors": [
"alebaffa",
"bitfield",
"ekingery",
"ferhatelmas",
"hilary",
"kytrinyx",
"leenipper",
"petertseng",
"robphoenix",
"sebito91",
"soniakeys",
"tleen",
"eklatzer"
],
"files": {
"solution": [
"raindrops.go"
],
"test": [
"raindrops_test.go",
"cases_test.go"
],
"example": [
".meta/example.go"
]
},
"blurb": "Convert a number into its corresponding raindrop sounds - Pling, Plang and Plong.",
"source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.",
"source_url": "https://en.wikipedia.org/wiki/Fizz_buzz"
}
+1
View File
@@ -0,0 +1 @@
{"track":"go","exercise":"raindrops","id":"4fc80ccd49df464995e301a419919798","url":"https://exercism.org/tracks/go/exercises/raindrops","handle":"sanctushck","is_requester":true,"auto_approve":false}
+41
View File
@@ -0,0 +1,41 @@
# Help
## Running the tests
To run the tests run the command `go test` from within the exercise directory.
If the test suite contains benchmarks, you can run these with the `--bench` and `--benchmem`
flags:
go test -v --bench . --benchmem
Keep in mind that each reviewer will run benchmarks on a different machine, with
different specs, so the results from these benchmark tests may vary.
## Submitting your solution
You can submit your solution using the `exercism submit raindrops.go` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Go track's documentation](https://exercism.org/docs/tracks/go)
- The [Go track's programming category on the forum](https://forum.exercism.org/c/programming/go)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [How to Write Go Code](https://golang.org/doc/code.html)
- [Effective Go](https://golang.org/doc/effective_go.html)
- [Go Resources](http://golang.org/help)
- [StackOverflow](http://stackoverflow.com/questions/tagged/go)
+59
View File
@@ -0,0 +1,59 @@
# Raindrops
Welcome to Raindrops on Exercism's Go Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Introduction
Raindrops is a slightly more complex version of the FizzBuzz challenge, a classic interview question.
## Instructions
Your task is to convert a number into its corresponding raindrop sounds.
If a given number:
- is divisible by 3, add "Pling" to the result.
- is divisible by 5, add "Plang" to the result.
- is divisible by 7, add "Plong" to the result.
- **is not** divisible by 3, 5, or 7, the result should be the number as a string.
## Examples
- 28 is divisible by 7, but not 3 or 5, so the result would be `"Plong"`.
- 30 is divisible by 3 and 5, but not 7, so the result would be `"PlingPlang"`.
- 34 is not divisible by 3, 5, or 7, so the result would be `"34"`.
~~~~exercism/note
A common way to test if one number is evenly divisible by another is to compare the [remainder][remainder] or [modulus][modulo] to zero.
Most languages provide operators or functions for one (or both) of these.
[remainder]: https://exercism.org/docs/programming/operators/remainder
[modulo]: https://en.wikipedia.org/wiki/Modulo_operation
~~~~
## Source
### Created by
- @nathany
### Contributed to by
- @alebaffa
- @bitfield
- @ekingery
- @ferhatelmas
- @hilary
- @kytrinyx
- @leenipper
- @petertseng
- @robphoenix
- @sebito91
- @soniakeys
- @tleen
- @eklatzer
### Based on
A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division. - https://en.wikipedia.org/wiki/Fizz_buzz
+105
View File
@@ -0,0 +1,105 @@
package raindrops
// This is an auto-generated file. Do not change it manually. Run the generator to update the file.
// See https://github.com/exercism/go#synchronizing-tests-and-instructions
// Source: exercism/problem-specifications
// Commit: 25c2ae5 build(deps): bump fast-uri from 3.1.0 to 3.1.2 (#2653)
type testCase struct {
description string
input int
expected string
}
var testCases = []testCase{
{
description: "the sound for 1 is 1",
input: 1,
expected: "1",
},
{
description: "the sound for 3 is Pling",
input: 3,
expected: "Pling",
},
{
description: "the sound for 5 is Plang",
input: 5,
expected: "Plang",
},
{
description: "the sound for 7 is Plong",
input: 7,
expected: "Plong",
},
{
description: "the sound for 6 is Pling as it has a factor 3",
input: 6,
expected: "Pling",
},
{
description: "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base",
input: 8,
expected: "8",
},
{
description: "the sound for 9 is Pling as it has a factor 3",
input: 9,
expected: "Pling",
},
{
description: "the sound for 10 is Plang as it has a factor 5",
input: 10,
expected: "Plang",
},
{
description: "the sound for 14 is Plong as it has a factor of 7",
input: 14,
expected: "Plong",
},
{
description: "the sound for 15 is PlingPlang as it has factors 3 and 5",
input: 15,
expected: "PlingPlang",
},
{
description: "the sound for 21 is PlingPlong as it has factors 3 and 7",
input: 21,
expected: "PlingPlong",
},
{
description: "the sound for 25 is Plang as it has a factor 5",
input: 25,
expected: "Plang",
},
{
description: "the sound for 27 is Pling as it has a factor 3",
input: 27,
expected: "Pling",
},
{
description: "the sound for 35 is PlangPlong as it has factors 5 and 7",
input: 35,
expected: "PlangPlong",
},
{
description: "the sound for 49 is Plong as it has a factor 7",
input: 49,
expected: "Plong",
},
{
description: "the sound for 52 is 52",
input: 52,
expected: "52",
},
{
description: "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7",
input: 105,
expected: "PlingPlangPlong",
},
{
description: "the sound for 3125 is Plang as it has a factor 5",
input: 3125,
expected: "Plang",
},
}
+3
View File
@@ -0,0 +1,3 @@
module raindrops
go 1.26
+8
View File
@@ -0,0 +1,8 @@
package raindrops
func Convert(number int) string {
var NumberAsString = ""
var OutputString = ""
if ()
panic("Please implement the Convert function")
}
+21
View File
@@ -0,0 +1,21 @@
package raindrops
import "testing"
func TestConvert(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
if actual := Convert(tc.input); actual != tc.expected {
t.Fatalf("Convert(%d) = %q, want: %q", tc.input, actual, tc.expected)
}
})
}
}
func BenchmarkConvert(b *testing.B) {
for b.Loop() {
for _, test := range testCases {
Convert(test.input)
}
}
}