exercism / red

Exercism exercises in Red.
https://exercism.org/tracks/red
MIT License
21 stars 14 forks source link

20 Practice Exercises #31

Closed loziniak closed 2 years ago

loziniak commented 3 years ago

At least 20 Practice Exercises are needed to launch track.

checklist:

exercise name (so-called "slug") is linked to a description. task's difficulty is in parentheses. the choice is arbitrary, based on personal reception of exercise description. it's open for discussion/change. this list is chosen randomly from Exercism's problem database. it's sorted by difficulty, and this order should be kept also in config.json.

instructions:

  1. Comment here to let anybody know which exercises are being worked on,
  2. Clone this repo,
  3. Run exercise generator:
    $ red _tools/generate-practice-exercise.red <exercise-slug>
  4. In exercises/practice/<exercise-slug>/<exercise-slug>-test.red change comments like this, to test example solution:
    ; test-init/limit %exercise-slug.red 1
    test-init/limit %.meta/example.red 1
  5. Solve exercise example, by editing exercises/practice/<exercise-slug>/.meta/example.red,
  6. Run tests. You'll need to change second argument of test-init function from 1 to how many tests you want to run in <exercise-slug>-test.red.
    $ cd exercises/practice/<exercise-slug>
    $ red <exercise-slug>-test.red
  7. Once your solution passes all the tests, remember to revert changes in test-init line: uncomment solution file, comment example file and change limit to 1 (second argument).
  8. Change exercise's difficulty in track's config,json. If you want, add practices and prerequisites concepts. Copy exercise's config to proper position, so that all exercises are sorted from easiest to toughest.
  9. Make a commit to separate branch and make Pull Requeset.
loziniak commented 3 years ago

(edit: moved the checklist to first issue post, to track checklist progress)

wallysilva commented 3 years ago

I will work on the hello-world (1)

loziniak commented 3 years ago

It already has a solution, but of course you can solve it as a learning example. Most needed are solution for exercises with empty checkbox.

wallysilva commented 3 years ago

I believe you can find some of the solutions in the Rosetta Code. For instance, the solution for the Roman Numerals problem: http://www.rosettacode.org/wiki/Roman_numerals/Decode#Red

dander commented 3 years ago

I will try out darts if someone else isn't already doing it. I'm curious about the workflow for the tests. Is the suggested way to increment the ignore-after field each time the tests all pass and run them again?

loziniak commented 3 years ago

@dander exactly. This is a workflow in every Exercism track. Although nothing can stop you from running all the tests from the very beginning. I suspect it's a sort of TDD good practice perhaps. BTW nice to see you involved!

loziniak commented 3 years ago

@wallysilva I took a roman-numerals solution from Rosetta Code, thanks for advice!

dander commented 3 years ago

I've started working on sgf-parsing

loziniak commented 2 years ago

I've started working on sgf-parsing

How is it going? Perhaps we could go live soon, do you want to finish that? If not, I'll take it.

dander commented 2 years ago

I had to stop for a while because of general life stuff going on, but I've been trying to get back to it lately. I was finding it a bit tricky to indicate in the tests what was wrong with the outputs in a clear way. Also, trying to figure out an appropriate way to handle expected errors. Have you encountered that in some of the other challenges? To clarify what I mean, some of the tests have expected values containing nested data structures

    expected: #(
        properties: #(
            A: ["b"]
            C: ["d"]
        )
        children: []
    )

While some have an 'error' property with an associated error message

    expected: #(
        error: "properties without delimiter"
    )

I'm interpreting that to mean that the test should trigger a 'user error with that message.

One thing I've been a bit conflicted on is whether the tree-like structure should be the strict map/block structure above, or more flexible, since there could be different kinds of solutions.

loziniak commented 2 years ago

Yes, this error pattern appeared for me in largest-series-product: 79a9cf08ca76 . You should be able to throw a map with error key, or cause-error with appropriate message. I extended a testing "framework" lately (009679130bd87f5cfb27f5240013124bc94a95cc), but errors should still work.

To satisfy structured output expectations, I would suggest you just return a map from tested function.

dander commented 2 years ago

I pushed up an example solution for the sgf-parsing exercise (finally). #62

I initially wanted to use parse with collect/keep, but since the outputs expect nested maps, and collect only can generate blocks, I wasn't sure how that would work. So instead I used a stack to keep track of the current location in the data structure to insert child nodes. I found this problem to be quite difficult to get right. I'm not sure that using parse is the easiest solution for it, but it seems like a natural place to display the feature of the language.

I'm looking into adding the project metadata pieces. I am considering adding concepts for parse, and recursion. Is there a catalog of existing concepts somewhere that I should reference? Is there anything I need to know about the uuids, or do I just generate a new one?

dander commented 2 years ago

@loziniak I think #62 is ready to be merged, if it looks good to you. I ended up adding stubs for a parse concept, but removed the recursion one. Though I suppose it could be solved without parse.

loziniak commented 2 years ago

There is no central point for concepts. For me it felt natural to just solve exercise examples and look if I could need any new concepts to explain it. So, it seems just as you did with parse. I have some initial work done to start with basics and evaluation concepts. Do you think about working more on concepts? It's a great feature, perhaps we could add concepts one-by-one. There is a task for it: #37 .

UUIDs can be generated offline by hand, they just need to be unique througout the project. You can use configlet for this, or just any online or sytem tool you prefer. Also, during track unit tests, configlet is used to check for uniqueness of UUIDs, so all errors are caught.

dander commented 2 years ago

I will consider contributing to the concepts. I just need to be weary of how big a bite I take.

Configlet is pretty cool. I discovered it when the pull request generated a failed configlet run.

loziniak commented 2 years ago

Just pushed last ex. from the 20 yay!