-
-
Notifications
You must be signed in to change notification settings - Fork 555
Add 'piecing-it-together' exercise #2554
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
Merged
+178
−0
Merged
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
901edbf
Add 'jigsaw-puzzle' exercise
atk 58812e9
address pr comments
atk fb39822
address pr comments, 2nd part
atk fa94f00
input format for configurations, blurb improvements
atk 47221ef
add missing expectation, instructions updates
atk 81302e3
fix typo
atk 1ada7f3
improve explanation
atk a3c5262
remove second part
atk 62a5d73
fix json format
atk 38ac4de
Update exercises/jigsaw-puzzle/introduction.md
atk 8c79c78
fix: linter issues
atk 4ae05cd
fix: uuids require uuid v4
atk ac36f29
improve wording
atk 2e707c7
Update exercises/jigsaw-puzzle/instructions.md
atk d1bc3e6
Update exercises/jigsaw-puzzle/introduction.md
atk 0616157
Update exercises/jigsaw-puzzle/canonical-data.json
atk 007593d
Add more tests
atk 824ac43
Fix typo in canonical data
atk eba955f
document aspect ratio choice
atk a1c5a69
Make comment more understandable
atk 57eb31d
Add source_url
atk f12e79d
Clarify inside pieces
atk 8e36f37
make introduction more whimsical
atk 60e1c19
Rename to piecing-it-together
atk 56a647d
add illustrated examples
atk 14b4cf3
fix: linter errors
atk 76730b8
fix: linter errors, 2nd part
atk 5626758
final image urls
atk 0b648ab
improve wording
atk 7dc21ba
wording improvements
atk 1fa797d
more improvements
atk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{ | ||
"exercise": "piecing-it-together", | ||
"comments": [ | ||
"For the aspect ratio, rational numbers can be used for languages without", | ||
"IEEE-754 support. Their representation depends on the track (e.g., a tuple like", | ||
"[numerator, denominator], a string like '3/4', or a custom rational type).", | ||
"The represented fractions should be reduced to lowest terms to avoid ambiguity." | ||
], | ||
"cases": [ | ||
{ | ||
"uuid": "ad626f23-09a2-4f5f-ba22-eec0671fa2a9", | ||
"description": "1000 pieces puzzle with 1.6 aspect ratio", | ||
"property": "jigsawData", | ||
"input": { | ||
"pieces": 1000, | ||
"aspectRatio": 1.6 | ||
}, | ||
"expected": { | ||
"pieces": 1000, | ||
"border": 126, | ||
"inside": 874, | ||
"rows": 25, | ||
"columns": 40, | ||
"aspectRatio": 1.6, | ||
"format": "landscape" | ||
} | ||
}, | ||
{ | ||
"uuid": "3e0c5919-3561-42f5-b9ed-26d70c20214e", | ||
"description": "square puzzle with 32 rows", | ||
"property": "jigsawData", | ||
"input": { | ||
"rows": 32, | ||
"format": "square" | ||
}, | ||
"expected": { | ||
"pieces": 1024, | ||
"border": 124, | ||
"inside": 900, | ||
"rows": 32, | ||
"columns": 32, | ||
"aspectRatio": 1.0, | ||
"format": "square" | ||
} | ||
}, | ||
{ | ||
"uuid": "1126f160-b094-4dc2-bf37-13e36e394867", | ||
"description": "400 pieces square puzzle with only inside pieces and aspect ratio", | ||
"property": "jigsawData", | ||
"input": { | ||
"inside": 324, | ||
"aspectRatio": 1.0 | ||
}, | ||
"expected": { | ||
"pieces": 400, | ||
"border": 76, | ||
"inside": 324, | ||
"rows": 20, | ||
"columns": 20, | ||
"aspectRatio": 1.0, | ||
"format": "square" | ||
} | ||
}, | ||
{ | ||
"uuid": "a9743178-5642-4cc0-8fdb-00d6b031c3a0", | ||
"description": "1500 pieces landscape puzzle with 30 rows and 1.6 aspect ratio", | ||
"property": "jigsawData", | ||
"input": { | ||
"rows": 30, | ||
"aspectRatio": 1.6666666666666667 | ||
}, | ||
"expected": { | ||
"pieces": 1500, | ||
"border": 156, | ||
"inside": 1344, | ||
"rows": 30, | ||
"columns": 50, | ||
"aspectRatio": 1.6666666666666667, | ||
"format": "landscape" | ||
} | ||
}, | ||
{ | ||
"uuid": "f6378369-989c-497f-a6e2-f30b1fa76cba", | ||
"description": "300 pieces portrait puzzle with 70 border pieces", | ||
"property": "jigsawData", | ||
"input": { | ||
"pieces": 300, | ||
"border": 70, | ||
"format": "portrait" | ||
}, | ||
"expected": { | ||
"pieces": 300, | ||
"border": 70, | ||
"inside": 230, | ||
"rows": 25, | ||
"columns": 12, | ||
"aspectRatio": 0.48, | ||
"format": "portrait" | ||
} | ||
}, | ||
{ | ||
"uuid": "f53f82ba-5663-4c7e-9e86-57fdbb3e53d2", | ||
"description": "puzzle with insufficient data", | ||
"property": "jigsawData", | ||
"input": { | ||
"pieces": 1500, | ||
"format": "landscape" | ||
}, | ||
"expected": { | ||
"error": "Insufficient data" | ||
} | ||
}, | ||
{ | ||
"uuid": "a3d5c31a-cc74-44bf-b4fc-9e4d65f1ac1a", | ||
"description": "puzzle with contradictory data", | ||
"property": "jigsawData", | ||
"input": { | ||
"rows": 100, | ||
"columns": 1000, | ||
"format": "square" | ||
}, | ||
"expected": { | ||
"error": "Contradictory data" | ||
} | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Instructions | ||
|
||
Given partial information about a jigsaw puzzle, complete the remaining details. | ||
|
||
If the information is insufficient to complete the details, or if it contains contradictions, the user should be notified. | ||
|
||
The full information about the jigsaw puzzle contains the following parts: | ||
|
||
- `pieces`: Total number of pieces | ||
- `border`: Number of border pieces | ||
- `inside`: Number of inside (non-border) pieces | ||
- `rows`: Number of rows | ||
- `columns`: Number of columns | ||
- `aspectRatio`: Aspect ratio of columns to rows | ||
- `format`: Puzzle format, which can be `portrait`, `square`, or `landscape` | ||
|
||
For this exercise, you may assume square pieces, so that the format can be derived from the aspect ratio: | ||
|
||
- If the aspect ratio is less than 1, it's `portrait` | ||
- If it is equal to 1, it's `square` | ||
- If it is greater than 1, it's `landscape` | ||
|
||
## Three examples | ||
|
||
### Portrait | ||
|
||
A portrait jigsaw puzzle with 6 pieces, all of which are border pieces and none are inside pieces. It has 3 rows and 2 columns. The aspect ratio is 1.5 (3/2). | ||
|
||
 | ||
|
||
### Square | ||
|
||
A square jigsaw puzzle with 9 pieces, all of which are border pieces except for the one in the center, which is an inside piece. It has 3 rows and 3 columns. The aspect ratio is 1 (3/3). | ||
|
||
 | ||
|
||
### Landscape | ||
|
||
A landscape jigsaw puzzle with 12 pieces, 10 of which are border pieces and 2 are inside pieces. It has 3 rows and 4 columns. The aspect ratio is 1.333333... (4/3). | ||
|
||
 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Introduction | ||
|
||
Your best friend has started collecting jigsaw puzzles and wants to build a detailed catalog of their collection — recording information such as the total number of pieces, the number of rows and columns, the number of border and inside pieces, aspect ratio, and puzzle format. | ||
Even with your powers combined, it takes multiple hours to solve a single jigsaw puzzle with one thousand pieces — and then you still need to count the rows and columns and calculate the remaining numbers manually. | ||
The even larger puzzles with multiple thousand pieces look quite daunting now. | ||
"There has to be a better way!" you exclaim and sit down in front of your computer to solve the problem. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
title = "Piecing It Together" | ||
blurb = "Fill in missing jigsaw puzzle details from partial data" | ||
source = "atk just started another 1000-pieces jigsaw puzzle when this idea hit him" | ||
source_url = "https://github.com/exercism/problem-specifications/pull/2554" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.