Skip to content

Add practice exercise piecing-it-together#1576

Merged
angelikatyborska merged 8 commits intomainfrom
jie-piecing-it-together
Jun 14, 2025
Merged

Add practice exercise piecing-it-together#1576
angelikatyborska merged 8 commits intomainfrom
jie-piecing-it-together

Conversation

@jiegillet
Copy link
Copy Markdown
Contributor

Fun little exercise! Great use of the quadratic formula 💯

The idea is to fill in partial information about a jigsaw puzzle.
There are tons of ways information might be missing or contradictory, but I mostly stuck to the test cases.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 7, 2025

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 (x:size/{tiny,small,medium,large,massive})? (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 🤖.

Copy link
Copy Markdown
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.

Woohoo, more exercises 🙂

Comment thread exercises/practice/piecing-it-together/lib/piecing_it_together.ex Outdated
Comment thread exercises/practice/piecing-it-together/lib/piecing_it_together.ex Outdated
Comment thread config.json
Comment thread config.json Outdated
Comment on lines +2686 to +2693
"structs",
"errors",
"multiple-clause-functions",
"pattern-matching",
"guards",
"if",
"case",
"floating-point-numbers"
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 have also used: enum, keyword-lists, maps, erlang-libraries. Which ones are really necessary for this exercise?

I'm assuming erlang-libraries are optional because Integer/Float.pow can be used instead of :math.sqrt. Is it common knowledge that pow(x, 0.5) == sqrt(x)?

As for enum, maps, and keyword-lists, they all come from the fact that you've turned then input struct into a keyword list. Was that really necessary? Can the exercise be solved without that?

    |> Map.from_struct()
    |> Enum.filter(fn {_, value} -> value end)
    |> Enum.sort_by(fn {key, _} -> key end)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm sure people know that pow(x, 0.5) == sqrt(x, but :math.sqrt is so much more natural, I didn't think twice before using it.

I'll add all of your suggestions, it's not really about whether they are all necessary (I'm sure you could write solutions that don't use them all), it's more about whether knowing about all these concepts can help you write a nice solution, and I think this is the case.

Comment thread exercises/practice/piecing-it-together/.meta/example.ex Outdated
@angelikatyborska
Copy link
Copy Markdown
Member

but I mostly stuck to the test cases.

Did you "mostly" stuck to the test cases, or "fully" stuck to the test cases? I was trying to find anything in the tests that doesn't come from problem specs but couldn't 🤔

Co-authored-by: Angelika Cathor <angelikatyborska@fastmail.com>
@jiegillet
Copy link
Copy Markdown
Contributor Author

Did you "mostly" stuck to the test cases, or "fully" stuck to the test cases? I was trying to find anything in the tests that doesn't come from problem specs but couldn't 🤔

The tests are strictly identical to the problem specs.

What I meant is that there is one test that expects {:error, "Contradictory data"} and one that expects {:error, "Insufficient data"}, implying that the solution should check for insufficient and contradictory data. However, there are many, many ways in which that could happen, and my example solution doesn't handle all of them.
My solution handles the invalid inputs from the tests, of course, and a couple that felt natural, for example when I have a clause pattern matching on format: :square, I feel that I should mention that other formats cannot be solved, even though that is technically dead code since it's not tested.

Copy link
Copy Markdown
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.

Looks great 🙂

@angelikatyborska angelikatyborska merged commit 0d9b514 into main Jun 14, 2025
9 checks passed
@angelikatyborska angelikatyborska deleted the jie-piecing-it-together branch June 14, 2025 15:58
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.

2 participants