exercism / nim

Exercism exercises in Nim.
https://exercism.org/tracks/nim
MIT License
56 stars 25 forks source link

Exercises for #48in24 #555

Open siebenschlaefer opened 8 months ago

siebenschlaefer commented 8 months ago

Dear maintainers,

Jeremy posted an overview of the exercises that will be featured in #48in24: http://forum.exercism.org/t/which-exercises-for-48in24/8970/19

The following featured exercises have not been translated to Nim yet:

I'm posting them here as a reminder. I hope I will find the time to translate a few of them (although I'm rather a beginner in Nim), and perhaps others will help, too. Feel free to close or remove this issue if you do not find it helpful.

Edit:
There is now a dedicated matrix with the status of all exercises in #48in24, which tracks have implemented them, and which exercises are featured on a specific track: https://exercism.org/challenges/48in24/implementation_status

siebenschlaefer commented 8 months ago

I want to translate two-bucket. In fact, the translation is almost finished, there's just one thing where I could use some input.

There are two types of test cases:

What should that error be?

What do you think is the best option?

ynfle commented 8 months ago

I want to translate two-bucket. In fact, the translation is almost finished, there's just one thing where I could use some input.

There are two types of test cases:

* "possible" test cases where the function should return the number of moves, the bucket that contains the goal volume, and the volume of the other bucket.

* "impossible" test cases where no sequence of moves can produce the goal volume and therefore some sort of "error" is expected.

What should that error be?

* The tuple that the function returns could contain a field `possible` that is `false` for impossible cases.

* The function could throw an exception (but which one?)

* The function could return an `Option`

What do you think is the best option?

Here are my thoughts:

It depends both on preference and what we are trying to convey. The object variant says that there are 2 possibilities and the exception and Option say that something "went wrong". In addition, exception says that something "exceptional" is going on while option says "it may not work out".