From 4bc53fb50653fcbeb916a402022b16440f60c216 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:34:34 +0200 Subject: [PATCH 1/2] Bump actions/checkout from 4.1.7 to 4.2.0 (#351) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/692973e3d937129bcbf40652eb9f2f61becf3332...d632683dd7b4114ad314bca15554477dd762a938) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c558751f..212ffad6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: r-lib/actions/setup-r@v2 with: @@ -43,7 +43,7 @@ jobs: R: ["4.3.1"] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: r-lib/actions/setup-r@v2 with: From cc3394263c603c5abe9652498bed2bf4910b615d Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 10 Oct 2024 16:09:16 +0200 Subject: [PATCH 2/2] Add `kindergarten-garden` exercise (#353) --- config.json | 8 + .../kindergarten-garden/.docs/instructions.md | 56 +++++++ .../kindergarten-garden/.docs/introduction.md | 6 + .../kindergarten-garden/.meta/config.json | 19 +++ .../kindergarten-garden/.meta/example.R | 13 ++ .../kindergarten-garden/.meta/tests.toml | 61 +++++++ .../kindergarten-garden/kindergarten-garden.R | 3 + .../test_kindergarten-garden.R | 152 ++++++++++++++++++ 8 files changed, 318 insertions(+) create mode 100644 exercises/practice/kindergarten-garden/.docs/instructions.md create mode 100644 exercises/practice/kindergarten-garden/.docs/introduction.md create mode 100644 exercises/practice/kindergarten-garden/.meta/config.json create mode 100644 exercises/practice/kindergarten-garden/.meta/example.R create mode 100644 exercises/practice/kindergarten-garden/.meta/tests.toml create mode 100644 exercises/practice/kindergarten-garden/kindergarten-garden.R create mode 100644 exercises/practice/kindergarten-garden/test_kindergarten-garden.R diff --git a/config.json b/config.json index 4787e17d..47ef4163 100644 --- a/config.json +++ b/config.json @@ -688,6 +688,14 @@ "practices": [], "prerequisites": [], "difficulty": 1 + }, + { + "slug": "kindergarten-garden", + "name": "Kindergarten Garden", + "uuid": "9ee61a47-5433-4459-8f42-5793500bc3b5", + "practices": [], + "prerequisites": [], + "difficulty": 3 } ] }, diff --git a/exercises/practice/kindergarten-garden/.docs/instructions.md b/exercises/practice/kindergarten-garden/.docs/instructions.md new file mode 100644 index 00000000..6fe11a58 --- /dev/null +++ b/exercises/practice/kindergarten-garden/.docs/instructions.md @@ -0,0 +1,56 @@ +# Instructions + +Your task is to, given a diagram, determine which plants each child in the kindergarten class is responsible for. + +There are 12 children in the class: + +- Alice, Bob, Charlie, David, Eve, Fred, Ginny, Harriet, Ileana, Joseph, Kincaid, and Larry. + +Four different types of seeds are planted: + +| Plant | Diagram encoding | +| ------ | ---------------- | +| Grass | G | +| Clover | C | +| Radish | R | +| Violet | V | + +Each child gets four cups, two on each row: + +```text +[window][window][window] +........................ # each dot represents a cup +........................ +``` + +Their teacher assigns cups to the children alphabetically by their names, which means that Alice comes first and Larry comes last. + +Here is an example diagram representing 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 diff --git a/exercises/practice/kindergarten-garden/.docs/introduction.md b/exercises/practice/kindergarten-garden/.docs/introduction.md new file mode 100644 index 00000000..5ad97d23 --- /dev/null +++ b/exercises/practice/kindergarten-garden/.docs/introduction.md @@ -0,0 +1,6 @@ +# Introduction + +The kindergarten class is learning about growing plants. +The teacher thought it would be a good idea to give the class seeds to plant and grow in the dirt. +To this end, the children have put little cups along the window sills and planted one type of plant in each cup. +The children got to pick their favorites from four available types of seeds: grass, clover, radishes, and violets. diff --git a/exercises/practice/kindergarten-garden/.meta/config.json b/exercises/practice/kindergarten-garden/.meta/config.json new file mode 100644 index 00000000..4abaf4dc --- /dev/null +++ b/exercises/practice/kindergarten-garden/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "erikschierboom" + ], + "files": { + "solution": [ + "kindergarten-garden.R" + ], + "test": [ + "test_kindergarten-garden.R" + ], + "example": [ + ".meta/example.R" + ] + }, + "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" +} diff --git a/exercises/practice/kindergarten-garden/.meta/example.R b/exercises/practice/kindergarten-garden/.meta/example.R new file mode 100644 index 00000000..59a95af8 --- /dev/null +++ b/exercises/practice/kindergarten-garden/.meta/example.R @@ -0,0 +1,13 @@ +children <- c( + "Alice", "Bob", "Charlie", "David", "Eve", "Fred", + "Ginny", "Harriet", "Ileana", "Joseph", "Kincaid", "Larry" +) + +encoding <- c(G = "Grass", C = "Clover", R = "Radish", V = "Violet") + +plants <- function(garden, child) { + sills <- strsplit(garden, "\n")[[1]] |> + sapply(FUN = \(row) strsplit(row, "")[[1]]) + idx <- match(child, children) * 2 - 1 + encoding[sills[idx:(idx + 1), ]] |> unname() +} diff --git a/exercises/practice/kindergarten-garden/.meta/tests.toml b/exercises/practice/kindergarten-garden/.meta/tests.toml new file mode 100644 index 00000000..0cdd9ad6 --- /dev/null +++ b/exercises/practice/kindergarten-garden/.meta/tests.toml @@ -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" diff --git a/exercises/practice/kindergarten-garden/kindergarten-garden.R b/exercises/practice/kindergarten-garden/kindergarten-garden.R new file mode 100644 index 00000000..20d966df --- /dev/null +++ b/exercises/practice/kindergarten-garden/kindergarten-garden.R @@ -0,0 +1,3 @@ +plants <- function(garden, child) { + +} diff --git a/exercises/practice/kindergarten-garden/test_kindergarten-garden.R b/exercises/practice/kindergarten-garden/test_kindergarten-garden.R new file mode 100644 index 00000000..f8827c09 --- /dev/null +++ b/exercises/practice/kindergarten-garden/test_kindergarten-garden.R @@ -0,0 +1,152 @@ +source("./kindergarten-garden.R") +library(testthat) + +test_that("partial garden garden with single student", { + garden <- "RC\nGG" + child <- "Alice" + expect_equal( + plants(garden, child), + c("Radish", "Clover", "Grass", "Grass") + ) +}) + +test_that("partial garden different garden with single student", { + garden <- "VC\nRC" + child <- "Alice" + expect_equal( + plants(garden, child), + c("Violet", "Clover", "Radish", "Clover") + ) +}) + +test_that("partial garden garden with two students", { + garden <- "VVCG\nVVRC" + child <- "Bob" + expect_equal( + plants(garden, child), + c("Clover", "Grass", "Radish", "Clover") + ) +}) + +test_that("partial garden second student s garden", { + garden <- "VVCCGG\nVVCCGG" + child <- "Bob" + expect_equal( + plants(garden, child), + c("Clover", "Clover", "Clover", "Clover") + ) +}) + +test_that("partial garden third student s garden", { + garden <- "VVCCGG\nVVCCGG" + child <- "Charlie" + expect_equal(plants(garden, child), c("Grass", "Grass", "Grass", "Grass")) +}) + +test_that("full garden for alice first student s garden", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Alice" + expect_equal( + plants(garden, child), + c("Violet", "Radish", "Violet", "Radish") + ) +}) + +test_that("full garden for bob second student s garden", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Bob" + expect_equal( + plants(garden, child), + c("Clover", "Grass", "Clover", "Clover") + ) +}) + +test_that("full garden for charlie", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Charlie" + expect_equal( + plants(garden, child), + c("Violet", "Violet", "Clover", "Grass") + ) +}) + +test_that("full garden for david", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "David" + expect_equal( + plants(garden, child), + c("Radish", "Violet", "Clover", "Radish") + ) +}) + +test_that("full garden for eve", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Eve" + expect_equal( + plants(garden, child), + c("Clover", "Grass", "Radish", "Grass") + ) +}) + +test_that("full garden for fred", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Fred" + expect_equal( + plants(garden, child), + c("Grass", "Clover", "Violet", "Clover") + ) +}) + +test_that("full garden for ginny", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Ginny" + expect_equal( + plants(garden, child), + c("Clover", "Grass", "Grass", "Clover") + ) +}) + +test_that("full garden for harriet", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Harriet" + expect_equal( + plants(garden, child), + c("Violet", "Radish", "Radish", "Violet") + ) +}) + +test_that("full garden for ileana", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Ileana" + expect_equal( + plants(garden, child), + c("Grass", "Clover", "Violet", "Clover") + ) +}) + +test_that("full garden for joseph", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Joseph" + expect_equal( + plants(garden, child), + c("Violet", "Clover", "Violet", "Grass") + ) +}) + +test_that("full garden for kincaid second to last student s garden", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Kincaid" + expect_equal( + plants(garden, child), + c("Grass", "Clover", "Clover", "Grass") + ) +}) + +test_that("full garden for larry last student s garden", { + garden <- "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV" + child <- "Larry" + expect_equal( + plants(garden, child), + c("Grass", "Violet", "Clover", "Violet") + ) +})