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 exercises #112

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@
"practices": [],
"prerequisites": [],
"difficulty": 6
},
{
"slug": "kindergarten-garden",
"name": "Kindergarten Garden",
"uuid": "4ef00077-722e-40cd-a94e-5256d26d1a74",
"practices": [],
"prerequisites": [],
"difficulty": 3
},
{
"slug": "roman-numerals",
"name": "Roman Numerals",
"uuid": "c204cfed-f935-46c1-bc88-46148b814f69",
"practices": [],
"prerequisites": [],
"difficulty": 2
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Notes

Here's what you need to know about the input format:

- **Left Argument**: The diagram representing the garden disposition, provided as a table of character with `tally` equals 2.
- **Right Argument**: The students name, provided as an string.

Your function will be called with these arguments like so:

```j
diagram=. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
student=. 'Fred'

diagram plants student
```
58 changes: 58 additions & 0 deletions exercises/practice/kindergarten-garden/.docs/instructions.md
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
19 changes: 19 additions & 0 deletions exercises/practice/kindergarten-garden/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"authors": [
"eNascimento178"
],
"files": {
"solution": [
"kindergarten-garden.ijs"
],
"test": [
"test.ijs"
],
"example": [
".meta/example.ijs"
]
},
"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"
}
5 changes: 5 additions & 0 deletions exercises/practice/kindergarten-garden/.meta/example.ijs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CHILDREN=: 'Alice';'Bob';'Charlie';'David';'Eve';'Fred';'Ginny';'Harriet';'Ileana';'Joseph';'Kincaid';'Larry'
PLANTS =: 'clover';'grass';'radishes';'violets'

group_by_child=: ;"1 @ |: @: (_2&(<\"1))
plants=: PLANTS {~ 'CGRV' i. (CHILDREN i. <@]) { group_by_child@[
61 changes: 61 additions & 0 deletions exercises/practice/kindergarten-garden/.meta/tests.toml
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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'general/unittest'

CHILDREN=: 'Alice';'Bob';'Charlie';'David';'Eve';'Fred';'Ginny';'Harriet';'Ileana';'Joseph';'Kincaid';'Larry'
PLANTS =: 'clover';'grass';'radishes';'violets'

plants=: 'You need to implement this verb.'13!:8 (55)
197 changes: 197 additions & 0 deletions exercises/practice/kindergarten-garden/test.ijs
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
load 'kindergarten-garden.ijs'


before_all=: monad define
(]Description =: (3 : 'descriptions=: i.0')`(3 : 'descriptions=: descriptions , < y'))@.0 ''
(]Order =: (3 : 'order=: i.0')`(3 : 'order=: order , < y'))@.0 ''
(]Task =: (3 : 'tasks=: i.0')`(3 : 'tasks=: tasks , < y'))@.0 ''
)


kindergarten_garden_test_01_ignore=: 0
test_kindergarten_garden_test_01 =: monad define
Description@.1 ('garden with single student')
Order@.1 (1)

NB. diagram =. 2 2$'RCGG'
NB. student =. 'Alice'
NB. expected =. 'radishes';'clover';'grass';'grass'
assert ('radishes';'clover';'grass';'grass') -: (2 2$'RCGG') plants 'Alice'
)

kindergarten_garden_test_02_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_02 =: monad define
Description@.1 ('different garden with single student')
Order@.1 (2)

NB. diagram =. 2 2$'VCRC'
NB. student =. 'Alice'
NB. expected =. 'violets';'clover';'radishes';'clover'
assert ('violets';'clover';'radishes';'clover') -: (2 2$'VCRC') plants 'Alice'
)

kindergarten_garden_test_03_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_03 =: monad define
Description@.1 ('garden with two students')
Order@.1 (3)

NB. diagram =. 2 4$'VVCGVVRC'
NB. student =. 'Bob'
NB. expected =. 'clover';'grass';'radishes';'clover'
assert ('clover';'grass';'radishes';'clover') -: (2 4$'VVCGVVRC') plants 'Bob'
)

kindergarten_garden_test_04_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_04 =: monad define
Description@.1 ('second student''s garden')
Order@.1 (4)

NB. diagram =. 2 6$'VVCCGGVVCCGG'
NB. student =. 'Bob'
NB. expected =. 'clover';'clover';'clover';'clover'
assert ('clover';'clover';'clover';'clover') -: (2 6$'VVCCGGVVCCGG') plants 'Bob'
)

kindergarten_garden_test_05_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_05 =: monad define
Description@.1 ('third student''s garden')
Order@.1 (5)

NB. diagram =. 2 6$'VVCCGGVVCCGG'
NB. student =. 'Charlie'
NB. expected =. 'grass';'grass';'grass';'grass'
assert ('grass';'grass';'grass';'grass') -: (2 6$'VVCCGGVVCCGG') plants 'Charlie'
)

kindergarten_garden_test_06_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_06 =: monad define
Description@.1 ('for Alice, first student''s garden')
Order@.1 (6)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Alice'
NB. expected =. 'violets';'radishes';'violets';'radishes'
assert ('violets';'radishes';'violets';'radishes') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Alice'
)

kindergarten_garden_test_07_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_07 =: monad define
Description@.1 ('for Bob, second student''s garden')
Order@.1 (7)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Bob'
NB. expected =. 'clover';'grass';'clover';'clover'
assert ('clover';'grass';'clover';'clover') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Bob'
)

kindergarten_garden_test_08_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_08 =: monad define
Description@.1 ('for Charlie')
Order@.1 (8)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Charlie'
NB. expected =. 'violets';'violets';'clover';'grass'
assert ('violets';'violets';'clover';'grass') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Charlie'
)

kindergarten_garden_test_09_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_09 =: monad define
Description@.1 ('for David')
Order@.1 (9)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'David'
NB. expected =. 'radishes';'violets';'clover';'radishes'
assert ('radishes';'violets';'clover';'radishes') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'David'
)

kindergarten_garden_test_10_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_10 =: monad define
Description@.1 ('for Eve')
Order@.1 (10)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Eve'
NB. expected =. 'clover';'grass';'radishes';'grass'
assert ('clover';'grass';'radishes';'grass') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Eve'
)

kindergarten_garden_test_11_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_11 =: monad define
Description@.1 ('for Fred')
Order@.1 (11)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Fred'
NB. expected =. 'grass';'clover';'violets';'clover'
assert ('grass';'clover';'violets';'clover') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Fred'
)

kindergarten_garden_test_12_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_12 =: monad define
Description@.1 ('for Ginny')
Order@.1 (12)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Ginny'
NB. expected =. 'clover';'grass';'grass';'clover'
assert ('clover';'grass';'grass';'clover') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Ginny'
)

kindergarten_garden_test_13_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_13 =: monad define
Description@.1 ('for Harriet')
Order@.1 (13)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Harriet'
NB. expected =. 'violets';'radishes';'radishes';'violets'
assert ('violets';'radishes';'radishes';'violets') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Harriet'
)

kindergarten_garden_test_14_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_14 =: monad define
Description@.1 ('for Ileana')
Order@.1 (14)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Ileana'
NB. expected =. 'grass';'clover';'violets';'clover'
assert ('grass';'clover';'violets';'clover') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Ileana'
)

kindergarten_garden_test_15_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_15 =: monad define
Description@.1 ('for Joseph')
Order@.1 (15)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Joseph'
NB. expected =. 'violets';'clover';'violets';'grass'
assert ('violets';'clover';'violets';'grass') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Joseph'
)

kindergarten_garden_test_16_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_16 =: monad define
Description@.1 ('for Kincaid, second to last student''s garden')
Order@.1 (16)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Kincaid'
NB. expected =. 'grass';'clover';'clover';'grass'
assert ('grass';'clover';'clover';'grass') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Kincaid'
)

kindergarten_garden_test_17_ignore=: 1 NB. Change this value to 0 to run this test
test_kindergarten_garden_test_17 =: monad define
Description@.1 ('for Larry, last student''s garden')
Order@.1 (17)

NB. diagram =. 2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV'
NB. student =. 'Larry'
NB. expected =. 'grass';'violets';'clover';'violets'
assert ('grass';'violets';'clover';'violets') -: (2 24$'VRCGVVRVCGGCCGVRGCVCGCGVVRCCCGCRRGVCGCRVVCVGCGCV') plants 'Larry'
)

Loading