Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#725] New practice exercise pov #752

Merged
merged 13 commits into from
Jun 8, 2021
Merged

Conversation

jiegillet
Copy link
Contributor

Dear maintainers,

Here is an extra practice exercise described in #725.
This is my first contribution, please help me get it right, I probably missed some things.

A couple of notes:

  • I didn't find a uuid for the exercise to add in config.json. How do I get it?
  • The test.tomls from a couple of other exercises I looked into looked self generated, but I don't know how the works, so I left the file blank for now.
  • The data structure I picked for the tree is pretty simple, it's just a tuple @type tree :: {any, [tree]}. Is it better to make it fancier, like a Map or a Struct?

Thank you!
Jeremie

@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2021

Thank you for contributing to exercism/elixir 💜 🎉. This is an automated PR comment 🤖 for the maintainers of this repository that helps with the PR review process. You can safely ignore it and wait for a maintainer to review your changes.

Based on the files changed in this PR, it would be good to pay attention to the following details when reviewing the PR:

  • General steps

    • 🏆 Does this PR need to receive a label with a reputation modifier (reputation/contributed_code/{minor,major})? (A medium reputation amount is awarded by default, see docs)
  • Any exercise changed

    • 👤 Does the author of the PR need to be added as an author or contributor in <exercise>/.meta/config.json (see docs)?
    • 🔬 Do the analyzer and the analyzer comments exist for this exercise? Do they need to be changed?
    • 📜 Does the design file (<exercise>/.meta/design.md) need to be updated to document new implementation decisions?
  • Practice exercise changed

    • 🌲 Do prerequisites, practices, and difficulty in config.json need to be updated?
    • 🧑‍🏫 Are the changes in accordance with the community-wide problem specifiations?
  • Practice exercise tests changed

    • ⚪️ Are all tests except the first one skipped?
    • 📜 Does <exercise>/.meta/tests.toml need updating?

Automated comment created by PR Commenter 🤖.

config.json Outdated Show resolved Hide resolved
config.json Outdated Show resolved Hide resolved
@@ -0,0 +1,133 @@
defmodule Pov do
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this exercise is basically Zipper + more functions, should see if we are being congruent with our approaches between the two exercises

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coincidentally, I just reached the Zipper exercise in my Elixir track. I'll go solve it real quick before looking into the repo ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I've solved it now. The approach in Zipper is quite different from other exercises that I've seen so far since it provides a complete module for binary trees. It's not bad, should I model this one after Zipper?

Copy link
Member

Choose a reason for hiding this comment

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

I think we can start with your current implementation like it is now, and then later, if people complain that the exercise is too difficult, we could add hints in the form of a module with a data structure that we suggest using.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, challenging exercises are not as much of an issue for practice exercises

Copy link
Contributor

@neenjaw neenjaw left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! 💙 🎉

@angelikatyborska DM'd me saying she will do a proper review of your new exercise soon, I left a couple comments just to address a few points that stuck out to me.

Great work so far!

Copy link
Member

@angelikatyborska angelikatyborska left a comment

Choose a reason for hiding this comment

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

This is 🔥 amazing 🔥. Great work!

The test.tomls from a couple of other exercises I looked into looked self generated, but I don't know how the works, so I left the file blank for now.

In theory there should a tool for generating those files from problem specifications, but I don't know at the moment if it already exists 😅. You can copy the file from https://github.com/exercism/fsharp/blob/main/exercises/practice/pov/.meta/tests.toml -> this is exactly what we need. Those files list all tests from problem specifications by id and description and define if our track implements the specific test cases or not. You would mark a test as not being implemented (on purpose) with include = false.

I requested a tiny change to the test data (to use 0-indexing for siblings and cousins, and to write the whole word "sibling" instead of just "sub"). Otherwise it's perfect :)

exercises/practice/pov/test/pov_test.exs Outdated Show resolved Hide resolved
exercises/practice/pov/test/pov_test.exs Outdated Show resolved Hide resolved
exercises/practice/pov/test/pov_test.exs Outdated Show resolved Hide resolved
exercises/practice/pov/test/pov_test.exs Outdated Show resolved Hide resolved
exercises/practice/pov/test/pov_test.exs Outdated Show resolved Hide resolved
exercises/practice/pov/test/pov_test.exs Outdated Show resolved Hide resolved
"recursion",
"pattern-matching"
],
"difficulty": 9
Copy link
Member

Choose a reason for hiding this comment

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

This is exciting 🤩 looks like this will be our most difficult exercise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have not done many of the difficulty 8, but it definitely is one step above Zipper, which is 8.
Forth is a 10 though!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think difficult 9 is okay, we don't have a firm definition what each number means anymore, so it's just to give a general feel of the complexity

config.json Outdated Show resolved Hide resolved
@typedoc """
A tree, which is made of a node with several branches
"""
@type tree :: {any, [tree]}
Copy link
Member

Choose a reason for hiding this comment

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

Great simple choice 👍


defmodule Zipper do
defstruct [:focus, genealogy: []]
@type t :: %Zipper{focus: Pov.tree(), genealogy: [Crumb.t()]}
Copy link
Member

Choose a reason for hiding this comment

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

Dialyzer is complaining that it doesn't know the type Crumb.t. I think that can be fixed by first defining the Crumb module, and only then the Zipper module 🤔

sorted_a = Enum.sort(children_a)
sorted_b = Enum.sort(children_b)

Enum.zip_with(sorted_a, sorted_b, &equal_trees/2)
Copy link
Member

Choose a reason for hiding this comment

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

The CI is already reporting that tests don't pass in Elixir 1.8 😢. It's because this function was introduced in Elixir 1.12. To allow as many students as possible to solve the exercises, we have a CI check that runs the example solutions against different versions of Elixir, starting at 1.7. I think it won't be a problem to rewrite this with zip and map instead, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem indeed.

Copy link
Contributor

@neenjaw neenjaw left a comment

Choose a reason for hiding this comment

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

Nice work @jiegillet!! Really well done!

I'll let @angelikatyborska merge it when she is ready, but I have no hesitation reading through this.

P.S. for @angelikatyborska, will have to be squashed to merge because of some branch issue with the commits

@neenjaw neenjaw linked an issue Jun 8, 2021 that may be closed by this pull request
@jiegillet
Copy link
Contributor Author

Thank you very much for the welcome and the fast reviews!

@angelikatyborska angelikatyborska merged commit 13eef73 into exercism:main Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 Related to Exercism v3 x:size/large Large amount of work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New practice exercise pov
4 participants