-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d95acfc
commit bd80485
Showing
9 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
58 changes: 58 additions & 0 deletions
58
exercises/practice/kindergarten-garden/.docs/instructions.md
This file contains 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,58 @@ | ||
# Instructions | ||
|
||
Given a diagram, determine which plants each child in the kindergarten class is | ||
responsible for. | ||
|
||
The kindergarten class is learning about growing plants. | ||
The teacher thought it would be a good idea to give them actual seeds, plant them in actual dirt, and grow actual plants. | ||
|
||
They've chosen to grow grass, clover, radishes, and violets. | ||
|
||
To this end, the children have put little cups along the window sills, and | ||
planted one type of plant in each cup, choosing randomly from the available | ||
types of seeds. | ||
|
||
```text | ||
[window][window][window] | ||
........................ # each dot represents a cup | ||
........................ | ||
``` | ||
|
||
There are 12 children in the class: | ||
|
||
- Alice, Bob, Charlie, David, | ||
- Eve, Fred, Ginny, Harriet, | ||
- Ileana, Joseph, Kincaid, and Larry. | ||
|
||
Each child gets 4 cups, two on each row. | ||
Their teacher assigns cups to the children alphabetically by their names. | ||
|
||
The following diagram represents Alice's plants: | ||
|
||
```text | ||
[window][window][window] | ||
VR...................... | ||
RG...................... | ||
``` | ||
|
||
In the first row, nearest the windows, she has a violet and a radish. | ||
In the second row she has a radish and some grass. | ||
|
||
Your program will be given the plants from left-to-right starting with the row nearest the windows. | ||
From this, it should be able to determine which plants belong to each student. | ||
|
||
For example, if it's told that the garden looks like so: | ||
|
||
```text | ||
[window][window][window] | ||
VRCGVVRVCGGCCGVRGCVCGCGV | ||
VRCCCGCRRGVCGCRVVCVGCGCV | ||
``` | ||
|
||
Then if asked for Alice's plants, it should provide: | ||
|
||
- Violets, radishes, violets, radishes | ||
|
||
While asking for Bob's plants would yield: | ||
|
||
- Clover, grass, clover, clover |
This file contains 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,19 @@ | ||
{ | ||
"authors": [ | ||
"keiravillekode" | ||
], | ||
"files": { | ||
"solution": [ | ||
"kindergarten-garden.wren" | ||
], | ||
"test": [ | ||
"kindergarten-garden.spec.wren" | ||
], | ||
"example": [ | ||
".meta/proof.ci.wren" | ||
] | ||
}, | ||
"blurb": "Given a diagram, determine which plants each child in the kindergarten class is responsible for.", | ||
"source": "Exercise by the JumpstartLab team for students at The Turing School of Software and Design.", | ||
"source_url": "https://turing.edu" | ||
} |
29 changes: 29 additions & 0 deletions
29
exercises/practice/kindergarten-garden/.meta/proof.ci.wren
This file contains 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,29 @@ | ||
class KindergartenGarden { | ||
static plants(diagram, student) { | ||
var first = 2 * (student.codePoints[0] - 65) | ||
var second = first + 1 | ||
var third = (diagram.codePoints.count + 1) / 2 + first | ||
var fourth = third + 1 | ||
return [ | ||
plant(diagram.codePoints[first]), | ||
plant(diagram.codePoints[second]), | ||
plant(diagram.codePoints[third]), | ||
plant(diagram.codePoints[fourth]) | ||
] | ||
} | ||
|
||
static plant(letter) { | ||
if (letter == 71) { | ||
return "grass" | ||
} | ||
if (letter == 67) { | ||
return "clover" | ||
} | ||
if (letter == 82) { | ||
return "radishes" | ||
} | ||
if (letter == 86) { | ||
return "violets" | ||
} | ||
} | ||
} |
This file contains 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,61 @@ | ||
# This is an auto-generated file. | ||
# | ||
# Regenerating this file via `configlet sync` will: | ||
# - Recreate every `description` key/value pair | ||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications | ||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) | ||
# - Preserve any other key/value pair | ||
# | ||
# As user-added comments (using the # character) will be removed when this file | ||
# is regenerated, comments can be added via a `comment` key. | ||
|
||
[1fc316ed-17ab-4fba-88ef-3ae78296b692] | ||
description = "partial garden -> garden with single student" | ||
|
||
[acd19dc1-2200-4317-bc2a-08f021276b40] | ||
description = "partial garden -> different garden with single student" | ||
|
||
[c376fcc8-349c-446c-94b0-903947315757] | ||
description = "partial garden -> garden with two students" | ||
|
||
[2d620f45-9617-4924-9d27-751c80d17db9] | ||
description = "partial garden -> multiple students for the same garden with three students -> second student's garden" | ||
|
||
[57712331-4896-4364-89f8-576421d69c44] | ||
description = "partial garden -> multiple students for the same garden with three students -> third student's garden" | ||
|
||
[149b4290-58e1-40f2-8ae4-8b87c46e765b] | ||
description = "full garden -> for Alice, first student's garden" | ||
|
||
[ba25dbbc-10bd-4a37-b18e-f89ecd098a5e] | ||
description = "full garden -> for Bob, second student's garden" | ||
|
||
[566b621b-f18e-4c5f-873e-be30544b838c] | ||
description = "full garden -> for Charlie" | ||
|
||
[3ad3df57-dd98-46fc-9269-1877abf612aa] | ||
description = "full garden -> for David" | ||
|
||
[0f0a55d1-9710-46ed-a0eb-399ba8c72db2] | ||
description = "full garden -> for Eve" | ||
|
||
[a7e80c90-b140-4ea1-aee3-f4625365c9a4] | ||
description = "full garden -> for Fred" | ||
|
||
[9d94b273-2933-471b-86e8-dba68694c615] | ||
description = "full garden -> for Ginny" | ||
|
||
[f55bc6c2-ade8-4844-87c4-87196f1b7258] | ||
description = "full garden -> for Harriet" | ||
|
||
[759070a3-1bb1-4dd4-be2c-7cce1d7679ae] | ||
description = "full garden -> for Ileana" | ||
|
||
[78578123-2755-4d4a-9c7d-e985b8dda1c6] | ||
description = "full garden -> for Joseph" | ||
|
||
[6bb66df7-f433-41ab-aec2-3ead6e99f65b] | ||
description = "full garden -> for Kincaid, second to last student's garden" | ||
|
||
[d7edec11-6488-418a-94e6-ed509e0fa7eb] | ||
description = "full garden -> for Larry, last student's garden" |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Exercism | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
72 changes: 72 additions & 0 deletions
72
exercises/practice/kindergarten-garden/kindergarten-garden.spec.wren
This file contains 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,72 @@ | ||
import "./kindergarten-garden" for KindergartenGarden | ||
import "wren-testie/testie" for Testie, Expect | ||
|
||
Testie.test("kindergarten-garden.steps()") { |do, skip| | ||
do.test("partial garden -> garden with single student") { | ||
Expect.value(KindergartenGarden.plants("RC\nGG", "Alice")).toEqual(["radishes", "clover", "grass", "grass"]) | ||
} | ||
|
||
skip.test("partial garden -> different garden with single student") { | ||
Expect.value(KindergartenGarden.plants("VC\nRC", "Alice")).toEqual(["violets", "clover", "radishes", "clover"]) | ||
} | ||
|
||
skip.test("partial garden -> garden with two students") { | ||
Expect.value(KindergartenGarden.plants("VVCG\nVVRC", "Bob")).toEqual(["clover", "grass", "radishes", "clover"]) | ||
} | ||
|
||
skip.test("partial garden -> multiple students for the same garden with three students -> second student's garden") { | ||
Expect.value(KindergartenGarden.plants("VVCCGG\nVVCCGG", "Bob")).toEqual(["clover", "clover", "clover", "clover"]) | ||
} | ||
|
||
skip.test("partial garden -> multiple students for the same garden with three students -> third student's garden") { | ||
Expect.value(KindergartenGarden.plants("VVCCGG\nVVCCGG", "Charlie")).toEqual(["grass", "grass", "grass", "grass"]) | ||
} | ||
|
||
skip.test("full garden -> for Alice, first student's garden") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Alice")).toEqual(["violets", "radishes", "violets", "radishes"]) | ||
} | ||
|
||
skip.test("full garden -> for Bob, second student's garden") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Bob")).toEqual(["clover", "grass", "clover", "clover"]) | ||
} | ||
|
||
skip.test("full garden -> for Charlie") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Charlie")).toEqual(["violets", "violets", "clover", "grass"]) | ||
} | ||
|
||
skip.test("full garden -> for David") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "David")).toEqual(["radishes", "violets", "clover", "radishes"]) | ||
} | ||
|
||
skip.test("full garden -> for Eve") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Eve")).toEqual(["clover", "grass", "radishes", "grass"]) | ||
} | ||
|
||
skip.test("full garden -> for Fred") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Fred")).toEqual(["grass", "clover", "violets", "clover"]) | ||
} | ||
|
||
skip.test("full garden -> for Ginny") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Ginny")).toEqual(["clover", "grass", "grass", "clover"]) | ||
} | ||
|
||
skip.test("full garden -> for Harriet") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Harriet")).toEqual(["violets", "radishes", "radishes", "violets"]) | ||
} | ||
|
||
skip.test("full garden -> for Ileana") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Ileana")).toEqual(["grass", "clover", "violets", "clover"]) | ||
} | ||
|
||
skip.test("full garden -> for Joseph") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Joseph")).toEqual(["violets", "clover", "violets", "grass"]) | ||
} | ||
|
||
skip.test("full garden -> for Kincaid, second to last student's garden") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Kincaid")).toEqual(["grass", "clover", "clover", "grass"]) | ||
} | ||
|
||
skip.test("full garden -> for Larry, last student's garden") { | ||
Expect.value(KindergartenGarden.plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Larry")).toEqual(["grass", "violets", "clover", "violets"]) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
exercises/practice/kindergarten-garden/kindergarten-garden.wren
This file contains 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,5 @@ | ||
class KindergartenGarden { | ||
static plants(diagram, student) { | ||
Fiber.abort("Remove this statement and implement this function") | ||
} | ||
} |
This file contains 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,14 @@ | ||
import "wren-package" for WrenPackage, Dependency | ||
import "os" for Process | ||
|
||
class Package is WrenPackage { | ||
construct new() {} | ||
name { "exercism/kindergarten-garden" } | ||
dependencies { | ||
return [ | ||
Dependency.new("wren-testie", "0.3.0", "https://github.com/joshgoebel/wren-testie.git") | ||
] | ||
} | ||
} | ||
|
||
Package.new().default() |