Skip to content

Add 'piecing-it-together' exercise#2554

Merged
atk merged 31 commits into
exercism:mainfrom
atk:jigsaw-puzzle
May 14, 2025
Merged

Add 'piecing-it-together' exercise#2554
atk merged 31 commits into
exercism:mainfrom
atk:jigsaw-puzzle

Conversation

@atk

@atk atk commented Apr 7, 2025

Copy link
Copy Markdown
Contributor

After starting a new jigsaw puzzle last weekend, I had the idea for a new simple exercise: a helper to provide information about jigsaw puzzles from a few pieces of information.

This is the first problem-specifiation I created, so I assume there are a lot of mistakes in there.

Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/introduction.md Outdated
Comment thread exercises/jigsaw-puzzle/metadata.toml Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
Comment thread exercises/jigsaw-puzzle/metadata.toml Outdated
Comment thread exercises/jigsaw-puzzle/introduction.md Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
@IsaacG

IsaacG commented Apr 9, 2025

Copy link
Copy Markdown
Member

Solving this was surprisingly difficult. It did uncover two errors in the data, though.

Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
@atk

atk commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

Yes, it is one of those exercises that only seem simple. I would assume a difficulty level of 6-7, depending on the language.

Comment thread exercises/jigsaw-puzzle/introduction.md Outdated
@atk atk marked this pull request as ready for review April 11, 2025 11:06
@atk atk requested a review from a team as a code owner April 11, 2025 11:06
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/introduction.md Outdated
Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated

@tasxatzial tasxatzial left a comment

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.

@atk I haven't been following the discussion over the past few days. Is there a specific reason why there are only five test cases? I expected more tbh.

Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
@atk

atk commented Apr 14, 2025

Copy link
Copy Markdown
Contributor Author

How many test cases would you deem sufficient?

@tasxatzial

Copy link
Copy Markdown
Member

How many test cases would you deem sufficient?

The exact number doesn't really matter, but I expect the current tests to be reasonably sufficient and cover most cases. It's a little difficult to assess whether that's the case. If you think these tests are enough, I'm fine with it — we can always add more in the future.

@tasxatzial tasxatzial left a comment

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.

I just noticed that the aspect ratio is a float in all tests, which introduces floating-point operations. Would it be better to restrict it to integers (and let tracks add extra tests if they want to), or do we intentionally want floating-point numbers in this exercise? Maintainers?

Edit: asking this because the new test case has aspect ratio 2/3

Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
@atk

atk commented Apr 15, 2025

Copy link
Copy Markdown
Contributor Author

Uneven aspectRatios are pretty normal in reality. Only square puzzles or 8-pieces baby puzzles (4/2) usually come with an integer aspect ratio. As an alternative, we could use a rational number stored in an 2-element array, but then it would need to be reduced to the lowest terms in order to avoid ambiguity, which would then result in an overlap with the rational-numbers exercise - at least that was my reasoning to choose a float here.

@tasxatzial

tasxatzial commented Apr 15, 2025

Copy link
Copy Markdown
Member

I don't disagree. The question is whether floating-point manipulation is something we actually want in this exercise. It's realistic, yes, but the exercise may choose not to deal with this scenario for various reasons — making the exercise easier being one of them — while still allowing tracks to introduce extra tests with floats, if they choose to.

@tasxatzial

tasxatzial commented Apr 15, 2025

Copy link
Copy Markdown
Member

As an alternative, we could use a rational number stored in an 2-element array, but then it would need to be reduced to the lowest terms in order to avoid ambiguity, which would then result in an overlap with the rational-numbers exercise

The new test uses a truncated float, but this only results in an approximation of the columns rather than the actual integer that appears in the result. So it seems that a rational number is the only option here — or perhaps there's another solution I'm not aware of.

@atk

atk commented Apr 15, 2025

Copy link
Copy Markdown
Contributor Author

I used the output of a calculation in node.js, which should be the closest to what JSON is supposed to handle in terms of f64. I don't think using a rational number for the aspect ratio is going to simplify the exercise significantly in most languages. Yes, you do not have to handle IEEE-754 numbers and their imprecisions then, but instead you need to reduce to the lowest term, which is already covered by another exercise.

@atk

atk commented Apr 15, 2025

Copy link
Copy Markdown
Contributor Author

Using a truncated float means that you will arrive at an approximation of an integer. Rounding should work here.

@tasxatzial

Copy link
Copy Markdown
Member

Using a truncated float means that you will arrive at an approximation of an integer. Rounding should work here.

It does. I think something like this should be mentioned in a comment or similar. Let's wait until other maintainers chime in, since I'm not sure what the best way to handle this is.

@IsaacG

IsaacG commented Apr 16, 2025

Copy link
Copy Markdown
Member

I think floating point values are fine to have in the test data.

@atk

atk commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author

I think we can leave the choice to the maintainers. I have updated the documentation accordingly.

Comment thread exercises/jigsaw-puzzle/canonical-data.json Outdated
@tasxatzial

Copy link
Copy Markdown
Member

@ErikSchierboom Can you please review when you get the chance?

Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
Comment thread exercises/jigsaw-puzzle/introduction.md Outdated
Comment thread exercises/jigsaw-puzzle/metadata.toml Outdated
Comment thread exercises/jigsaw-puzzle/instructions.md Outdated
@ErikSchierboom

Copy link
Copy Markdown
Member

This is no show stopper but something to think about: maybe use a whimsical name? Puzzling Puzzles or something like that. Someone else might be able to come up with something better. Other than that, and once the images are included, this is great

atk and others added 22 commits May 13, 2025 11:34
Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
@atk atk force-pushed the jigsaw-puzzle branch from 51ae68e to 0b648ab Compare May 13, 2025 09:35
Comment thread exercises/piecing-it-together/introduction.md Outdated
@habere-et-dispertire

Copy link
Copy Markdown
Contributor

I think it may make it fractionally more engaging to be less abstract with "complete" and say "discover" here:

Given partial information about a jigsaw puzzle, complete discover the remaining details.

English is confusing. To say "If it contains contradictions" may be misinterpreted as having to contain multiple contradictions. Adding any may make it somewhat clearer here:

If the information is insufficient to complete the details, or if it contains any contradictions, the user should be notified.

€0.02++

@atk

atk commented May 13, 2025

Copy link
Copy Markdown
Contributor Author

I changed it a bit to make it less ambiguous while still matching the theme.

@atk atk merged commit 087e5e3 into exercism:main May 14, 2025
6 of 7 checks passed
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.

6 participants