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

Add practice exercise Zebra Puzzle #788

Merged
merged 11 commits into from
Apr 23, 2024
85 changes: 40 additions & 45 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@
"prerequisites": []
},
{
"uuid": "88baa5ab-dacb-4fab-8f16-4f3ed726b27b",
"slug": "freelancer-rates",
"name": "Freelancer Rates",
"concepts": ["numbers"],
"uuid": "88baa5ab-dacb-4fab-8f16-4f3ed726b27b",
"concepts": [
"numbers"
],
"prerequisites": [
"basics",
"includes"
Expand Down Expand Up @@ -950,7 +952,7 @@
"name": "Darts",
"uuid": "e8ad3859-9999-4a36-900d-d82fa6e74b08",
"practices": [
"if-statements"
"if-statements"
],
"prerequisites": [
"numbers"
Expand Down Expand Up @@ -1018,9 +1020,7 @@
"prerequisites": [
"classes"
],
"difficulty": 4,
"topics": [
]
"difficulty": 4
},
{
"slug": "pop-count",
Expand All @@ -1033,30 +1033,23 @@
"if-statements",
"comparisons"
],
"difficulty": 3,
"topics": [
]
"difficulty": 3
},
{
"slug": "diamond",
"name": "Diamond",
"uuid": "f8298f68-ef4e-41e1-99af-85a1bef71561",
"practices": [
],
"prerequisites": [
],
"difficulty": 3,
"topics": [
]
"practices": [],
"prerequisites": [],
"difficulty": 3
},
{
"slug": "run-length-encoding",
"name": "Run-Length Encoding",
"uuid": "916fedd1-a9ed-4200-b115-cc1d1bc44aba",
"practices": [],
"prerequisites": [],
"difficulty": 3,
"topics": []
"difficulty": 3
},
{
"slug": "rotational-cipher",
Expand All @@ -1068,53 +1061,55 @@
"prerequisites": [
"loops"
],
"difficulty": 3,
"topics": []
"difficulty": 3
},
{
"slug": "resistor-color",
"name": "Resistor Color",
"uuid": "15a9277e-59e2-484a-9877-64437556825c",
"practices": [],
"prerequisites": [],
"difficulty": 2,
"topics": []
"difficulty": 2
},
{
"slug": "resistor-color-duo",
"name": "Resistor Color Duo",
"uuid": "83ce95e9-f8af-4dbb-b96b-d94b12421d77",
"practices": [],
"prerequisites": [],
"difficulty": 3,
"topics": []
"difficulty": 3
},
{
"slug": "minesweeper",
"name": "Minesweeper",
"uuid": "3753a72a-78b7-429f-b79a-f68d55a00387",
"practices": [],
"prerequisites": [],
"difficulty": 5,
"topics": []
"difficulty": 5
},
{
"slug": "sublist",
"name": "Sublist",
"uuid": "801cb315-91d6-48e6-92f4-36423a89d4e1",
"practices": [],
"prerequisites": [],
"difficulty": 5,
"topics": []
"difficulty": 5
},
{
"slug": "zebra-puzzle",
"name": "Zebra Puzzle",
"uuid": "2badf89b-efc4-46f1-af8d-b7d2440e61c0",
"practices": [],
"prerequisites": [],
"difficulty": 5
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 I would give this a higher difficulty, maybe 7 or 8.
@vaeng What do you think?

},
{
"slug": "two-bucket",
"name": "Two Bucket",
"uuid": "83c92b7f-fb0e-43d8-ab7d-d514408b8575",
"practices": [],
"prerequisites": [],
"difficulty": 7,
"topics": []
"difficulty": 7
}
],
"foregone": [
Expand Down Expand Up @@ -1205,47 +1200,47 @@
],
"key_features": [
{
"icon": "fast",
"title": "Fast execution speed",
"content": "With execution speed in mind, C++ is used in a wide range of computation-intensive domains."
"content": "With execution speed in mind, C++ is used in a wide range of computation-intensive domains.",
"icon": "fast"
},
{
"icon": "multi-paradigm",
"title": "Multi-paradigm",
"content": "C++ supports a variety of programming paradigms like OOP, functional and procedural programming."
"content": "C++ supports a variety of programming paradigms like OOP, functional and procedural programming.",
"icon": "multi-paradigm"
},
{
"icon": "powerful",
"title": "High-level programming",
"content": "C++ standardizes a comprehensive library, enabling the developer to concentrate on the problem."
"content": "C++ standardizes a comprehensive library, enabling the developer to concentrate on the problem.",
"icon": "powerful"
},
{
"icon": "homoiconic",
"title": "Low-level programming",
"content": "C++ masters the strength of its predecessor C and gives the developer access to the bits and bytes."
"content": "C++ masters the strength of its predecessor C and gives the developer access to the bits and bytes.",
"icon": "homoiconic"
},
{
"icon": "widely-used",
"title": "Popular",
"content": "Thanks to the flexibility and portability, you can find applications written in C++ in every scale."
"content": "Thanks to the flexibility and portability, you can find applications written in C++ in every scale.",
"icon": "widely-used"
},
{
"icon": "evolving",
"title": "Ever-evolving",
"content": "Although mature, C++ is still evolving and developed by a committee to fit the developers needs."
"content": "Although mature, C++ is still evolving and developed by a committee to fit the developers needs.",
"icon": "evolving"
}
],
"tags": [
"paradigm/object_oriented",
"typing/static",
"typing/strong",
"execution_mode/compiled",
"paradigm/object_oriented",
"platform/android",
"platform/ios",
"platform/linux",
"platform/mac",
"platform/windows",
"runtime/standalone_executable",
"typing/static",
"typing/strong",
"used_for/backends",
"used_for/cross_platform_development",
"used_for/embedded_systems",
Expand Down
6 changes: 6 additions & 0 deletions exercises/practice/zebra-puzzle/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Instructions

Your task is to solve the ‘Zebra Puzzle’ also known as ‘The Einstein's Puzzle’ but how you do it that depends on you, best way to solve this problem is first you solve it with your pen and paper, it will take time but it will improve your logical thinking and its provide programmatic way to solve this problem.

**!!Spoiler warning!!**
You can learn more about this problem on [Zebra Puzzle](https://en.wikipedia.org/wiki/Zebra_Puzzle)
24 changes: 24 additions & 0 deletions exercises/practice/zebra-puzzle/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Instructions

Solve the zebra puzzle.

1. There are five houses.
2. The Englishman lives in the red house.
3. The Spaniard owns the dog.
4. Coffee is drunk in the green house.
5. The Ukrainian drinks tea.
6. The green house is immediately to the right of the ivory house.
7. The Old Gold smoker owns snails.
8. Kools are smoked in the yellow house.
9. Milk is drunk in the middle house.
10. The Norwegian lives in the first house.
11. The man who smokes Chesterfields lives in the house next to the man with the fox.
12. Kools are smoked in the house next to the house where the horse is kept.
13. The Lucky Strike smoker drinks orange juice.
14. The Japanese smokes Parliaments.
15. The Norwegian lives next to the blue house.

Each of the five houses is painted a different color, and their inhabitants are of different national extractions, own different pets, drink different beverages and smoke different brands of cigarettes.

Which of the residents drinks water?
Who owns the zebra?
19 changes: 19 additions & 0 deletions exercises/practice/zebra-puzzle/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"authors": ["rajatnai49"],
"files": {
"solution": [
"zebra_puzzle.cpp",
"zebra_puzzle.h"
vaeng marked this conversation as resolved.
Show resolved Hide resolved
],
"test": [
"zebra_puzzle_test.cpp"
],
"example": [
"example.cpp",
"example.h"
vaeng marked this conversation as resolved.
Show resolved Hide resolved
]
},
"blurb": "Solve the zebra puzzle.",
"source": "Wikipedia",
"source_url": "https://en.wikipedia.org/wiki/Zebra_Puzzle"
}
Loading