trackler 2.2.1.122 → 2.2.1.123
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/clojure/config.json +8 -0
- data/tracks/clojure/exercises/poker/README.md +11 -0
- data/tracks/clojure/exercises/poker/project.clj +4 -0
- data/tracks/clojure/exercises/poker/src/example.clj +42 -0
- data/tracks/clojure/exercises/poker/src/poker.clj +3 -0
- data/tracks/clojure/exercises/poker/test/poker_test.clj +147 -0
- data/tracks/swift/.travis.yml +0 -5
- data/tracks/swift/circle.yml +9 -2
- data/tracks/typescript/config.json +29 -0
- data/tracks/typescript/exercises/kindergarten-garden/README.md +97 -0
- data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.example.ts +64 -0
- data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.test.ts +131 -0
- data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.ts +7 -0
- data/tracks/typescript/exercises/kindergarten-garden/package.json +36 -0
- data/tracks/typescript/exercises/kindergarten-garden/tsconfig.json +22 -0
- data/tracks/typescript/exercises/kindergarten-garden/tslint.json +127 -0
- data/tracks/typescript/exercises/kindergarten-garden/yarn.lock +2624 -0
- data/tracks/typescript/exercises/proverb/README.md +49 -0
- data/tracks/typescript/exercises/proverb/package.json +36 -0
- data/tracks/typescript/exercises/proverb/proverb.example.ts +23 -0
- data/tracks/typescript/exercises/proverb/proverb.test.ts +32 -0
- data/tracks/typescript/exercises/proverb/proverb.ts +0 -0
- data/tracks/typescript/exercises/proverb/tsconfig.json +22 -0
- data/tracks/typescript/exercises/proverb/tslint.json +127 -0
- data/tracks/typescript/exercises/proverb/yarn.lock +2624 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c897a3dbf6364ea2d268b80851cdd4333bf32af9
|
4
|
+
data.tar.gz: f0314259e05072db6b7c79d853b925d303ad723e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaefda1096a1d4c541c5614cfce2b6ebfb1f2fb56cc68f4d4636b743ef9e18d13a239bda4d27775d0b303912eaaff3f811d3cf3ddc61effbce8fc966c78e87ff
|
7
|
+
data.tar.gz: 600577c09afa131b3eea31807e42f2f68ffa5612ceb366d69c99c56ee40dd9cd210f690772bb8a045661de29a08faf1c318dffea5003817383f38184dfeb798f
|
data/lib/trackler/version.rb
CHANGED
data/tracks/clojure/config.json
CHANGED
@@ -589,6 +589,14 @@
|
|
589
589
|
"topics": null,
|
590
590
|
"unlocked_by": null,
|
591
591
|
"uuid": "c8ba6ce5-9a7e-4c1c-8044-bb18a0d6ad39"
|
592
|
+
},
|
593
|
+
{
|
594
|
+
"core": false,
|
595
|
+
"difficulty": 1,
|
596
|
+
"slug": "poker",
|
597
|
+
"topics": null,
|
598
|
+
"unlocked_by": null,
|
599
|
+
"uuid": "7df7ff1c-74ab-4f4e-aaf0-257b6e1cbc18"
|
592
600
|
}
|
593
601
|
],
|
594
602
|
"foregone": [],
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Pick the best hand(s) from a list of poker hands.
|
2
|
+
|
3
|
+
See [wikipedia](https://en.wikipedia.org/wiki/List_of_poker_hands) for an
|
4
|
+
overview of poker hands.
|
5
|
+
|
6
|
+
## Source
|
7
|
+
|
8
|
+
[Inspired by the training course from Udacity.](https://www.udacity.com/course/viewer#!/c-cs212/)
|
9
|
+
|
10
|
+
## Submitting Incomplete Solutions
|
11
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
(ns poker
|
2
|
+
(:require [clojure.string :as cs]))
|
3
|
+
|
4
|
+
(defn rank-hand [hand]
|
5
|
+
(let [h (cs/split (cs/replace hand #"10" "T") #" ")
|
6
|
+
initial-ranks (map #(.indexOf (seq "..23456789TJQKA") (first %)) h)
|
7
|
+
score-frec (reverse (sort-by vec (map (comp vec reverse)
|
8
|
+
(frequencies initial-ranks))))
|
9
|
+
rank-counts (mapv first score-frec)
|
10
|
+
normalized-ranks (if (= (mapv second score-frec) [14,5,4,3,2]) [5,4,3,2,1]
|
11
|
+
(mapv second score-frec))
|
12
|
+
straight? (and (= 5 (count rank-counts))
|
13
|
+
(= 4 (- (apply max rank-counts) (apply min rank-counts))))
|
14
|
+
flush? (= 1 (count (distinct (map last h))))]
|
15
|
+
(cond (= 5 rank-counts) [9 normalized-ranks]
|
16
|
+
(and straight? flush?) [8 normalized-ranks]
|
17
|
+
(= rank-counts [4 1]) [7 normalized-ranks]
|
18
|
+
(= rank-counts [3 2]) [6 normalized-ranks]
|
19
|
+
flush? [5 normalized-ranks]
|
20
|
+
straight? [4 normalized-ranks]
|
21
|
+
(= rank-counts [3 1 1]) [3 normalized-ranks]
|
22
|
+
(= rank-counts [2 2 1]) [2 normalized-ranks]
|
23
|
+
(= rank-counts [2 1 1 1]) [1 normalized-ranks]
|
24
|
+
:else [0 normalized-ranks])))
|
25
|
+
|
26
|
+
(defn greater-than [xs ys]
|
27
|
+
(or (> (first xs) (first ys))
|
28
|
+
(->> (map compare (second xs) (second ys))
|
29
|
+
(take-while (partial not= -1))
|
30
|
+
(some (partial = 1)))))
|
31
|
+
|
32
|
+
(defn best-hands [hands]
|
33
|
+
(-> (fn [[max-rank record hands]]
|
34
|
+
(let [[x & xs] hands
|
35
|
+
rank (rank-hand x)]
|
36
|
+
(cond
|
37
|
+
(or (empty? record) (greater-than rank max-rank)) [rank [x] xs]
|
38
|
+
(= rank max-rank) [max-rank (conj record x) xs]
|
39
|
+
:else [max-rank record xs])))
|
40
|
+
(iterate [[0 []] [] hands])
|
41
|
+
(nth (count hands))
|
42
|
+
(second)))
|
@@ -0,0 +1,147 @@
|
|
1
|
+
(ns poker-test
|
2
|
+
(:require [clojure.test :refer [deftest is]]
|
3
|
+
[poker :refer [best-hands]]))
|
4
|
+
|
5
|
+
(defn f [xs ys] (= (sort (best-hands xs)) (sort ys)))
|
6
|
+
|
7
|
+
(deftest single-hand-always-wins
|
8
|
+
(is (f ["4S 5S 7H 8D JC"] ["4S 5S 7H 8D JC"])))
|
9
|
+
|
10
|
+
(deftest highest-card-out-of-all-hands-wins
|
11
|
+
(is (f ["4D 5S 6S 8D 3C"
|
12
|
+
"2S 4C 7S 9H 10H"
|
13
|
+
"3S 4S 5D 6H JH"]
|
14
|
+
["3S 4S 5D 6H JH"])))
|
15
|
+
|
16
|
+
(deftest a-tie-has-multiple-winners
|
17
|
+
(is (f ["4D 5S 6S 8D 3C"
|
18
|
+
"2S 4C 7S 9H 10H"
|
19
|
+
"3S 4S 5D 6H JH"
|
20
|
+
"3H 4H 5C 6C JD"]
|
21
|
+
["3S 4S 5D 6H JH"
|
22
|
+
"3H 4H 5C 6C JD"])))
|
23
|
+
|
24
|
+
(deftest multiple-hands-with-the-same-high-cards-tie-compares-next-highest-ranked-down-to-last-card
|
25
|
+
(is (f ["3S 5H 6S 8D 7H"
|
26
|
+
"2S 5D 6D 8C 7S"]
|
27
|
+
["3S 5H 6S 8D 7H"])))
|
28
|
+
|
29
|
+
(deftest one-pair-beats-high-card
|
30
|
+
(is (f ["4S 5H 6C 8D KH"
|
31
|
+
"2S 4H 6S 4D JH"]
|
32
|
+
["2S 4H 6S 4D JH"])))
|
33
|
+
|
34
|
+
(deftest highest-pair-wins
|
35
|
+
(is (f ["4S 2H 6S 2D JH"
|
36
|
+
"2S 4H 6C 4D JD"]
|
37
|
+
["2S 4H 6C 4D JD"])))
|
38
|
+
|
39
|
+
(deftest two-pairs-beats-one-pair
|
40
|
+
(is (f ["2S 8H 6S 8D JH"
|
41
|
+
"4S 5H 4C 8C 5C"]
|
42
|
+
["4S 5H 4C 8C 5C"])))
|
43
|
+
|
44
|
+
(deftest both-hands-have-two-pairs-highest-ranked-pair-wins
|
45
|
+
(is (f ["2S 8H 2D 8D 3H"
|
46
|
+
"4S 5H 4C 8S 5D"]
|
47
|
+
["2S 8H 2D 8D 3H"])))
|
48
|
+
|
49
|
+
(deftest both-hands-have-two-pairs-with-the-same-highest-ranked-pair-tie-goes-to-low-pair
|
50
|
+
(is (f ["2S QS 2C QD JH"
|
51
|
+
"JD QH JS 8D QC"]
|
52
|
+
["JD QH JS 8D QC"])))
|
53
|
+
|
54
|
+
(deftest both-hands-have-two-identically-ranked-pairs-tie-goes-to-remaining-card-kicker
|
55
|
+
(is (f ["JD QH JS 8D QC"
|
56
|
+
"JS QS JC 2D QD"]
|
57
|
+
["JD QH JS 8D QC"])))
|
58
|
+
|
59
|
+
(deftest three-of-a-kind-beats-two-pair
|
60
|
+
(is (f ["2S 8H 2H 8D JH"
|
61
|
+
"4S 5H 4C 8S 4H"]
|
62
|
+
["4S 5H 4C 8S 4H"])))
|
63
|
+
|
64
|
+
(deftest both-hands-have-three-of-a-kind-tie-goes-to-highest-ranked-triplet
|
65
|
+
(is (f ["2S 2H 2C 8D JH"
|
66
|
+
"4S AH AS 8C AD"]
|
67
|
+
["4S AH AS 8C AD"])))
|
68
|
+
|
69
|
+
(deftest with-multiple-decks-two-players-can-have-same-three-of-a-kind-ties-go-to-highest-remaining-cards
|
70
|
+
(is (f ["4S AH AS 7C AD"
|
71
|
+
"4S AH AS 8C AD"]
|
72
|
+
["4S AH AS 8C AD"])))
|
73
|
+
|
74
|
+
(deftest a-straight-beats-three-of-a-kind
|
75
|
+
(is (f ["4S 5H 4C 8D 4H"
|
76
|
+
"3S 4D 2S 6D 5C"]
|
77
|
+
["3S 4D 2S 6D 5C"])))
|
78
|
+
|
79
|
+
(deftest aces-can-end-a-straight-10-J-Q-K-A
|
80
|
+
(is (f ["4S 5H 4C 8D 4H"
|
81
|
+
"10D JH QS KD AC"]
|
82
|
+
["10D JH QS KD AC"])))
|
83
|
+
|
84
|
+
(deftest aces-can-start-a-straight-A-2-3-4-5
|
85
|
+
(is (f ["4S 5H 4C 8D 4H"
|
86
|
+
"4D AH 3S 2D 5C"]
|
87
|
+
["4D AH 3S 2D 5C"])))
|
88
|
+
|
89
|
+
(deftest both-hands-with-a-straight-tie-goes-to-highest-ranked-card
|
90
|
+
(is (f ["4S 6C 7S 8D 5H"
|
91
|
+
"5S 7H 8S 9D 6H"]
|
92
|
+
["5S 7H 8S 9D 6H"])))
|
93
|
+
|
94
|
+
(deftest even-though-an-ace-is-usually-high-a-5-high-straight-is-the-lowest-scoring-straight
|
95
|
+
(is (f ["2H 3C 4D 5D 6H"
|
96
|
+
"4S AH 3S 2D 5H"]
|
97
|
+
["2H 3C 4D 5D 6H"])))
|
98
|
+
|
99
|
+
(deftest flush-beats-a-straight
|
100
|
+
(is (f ["4C 6H 7D 8D 5H"
|
101
|
+
"2S 4S 5S 6S 7S"]
|
102
|
+
["2S 4S 5S 6S 7S"])))
|
103
|
+
|
104
|
+
(deftest both-hands-have-a-flush-tie-goes-to-high-card-down-to-the-last-one-if-necessary
|
105
|
+
(is (f ["4H 7H 8H 9H 6H"
|
106
|
+
"2S 4S 5S 6S 7S"]
|
107
|
+
["4H 7H 8H 9H 6H"])))
|
108
|
+
|
109
|
+
(deftest full-house-beats-a-flush
|
110
|
+
(is (f ["3H 6H 7H 8H 5H"
|
111
|
+
"4S 5H 4C 5D 4H"]
|
112
|
+
["4S 5H 4C 5D 4H"])))
|
113
|
+
|
114
|
+
(deftest both-hands-have-a-full-house-tie-goes-to-highest-ranked-triplet
|
115
|
+
(is (f ["4H 4S 4D 9S 9D"
|
116
|
+
"5H 5S 5D 8S 8D"]
|
117
|
+
["5H 5S 5D 8S 8D"])))
|
118
|
+
|
119
|
+
(deftest with-multiple-decks-both-hands-have-a-full-house-with-the-same-triplet-tie-goes-to-the-pair
|
120
|
+
(is (f ["5H 5S 5D 9S 9D"
|
121
|
+
"5H 5S 5D 8S 8D"]
|
122
|
+
["5H 5S 5D 9S 9D"])))
|
123
|
+
|
124
|
+
(deftest four-of-a-kind-beats-a-full-house
|
125
|
+
(is (f ["4S 5H 4D 5D 4H"
|
126
|
+
"3S 3H 2S 3D 3C"]
|
127
|
+
["3S 3H 2S 3D 3C"])))
|
128
|
+
|
129
|
+
(deftest both-hands-have-four-of-a-kind-tie-goes-to-high-quad
|
130
|
+
(is (f ["2S 2H 2C 8D 2D"
|
131
|
+
"4S 5H 5S 5D 5C"]
|
132
|
+
["4S 5H 5S 5D 5C"])))
|
133
|
+
|
134
|
+
(deftest with-multiple-decks-both-hands-with-identical-four-of-a-kind-tie-determined-by-kicker
|
135
|
+
(is (f ["3S 3H 2S 3D 3C"
|
136
|
+
"3S 3H 4S 3D 3C"]
|
137
|
+
["3S 3H 4S 3D 3C"])))
|
138
|
+
|
139
|
+
(deftest straight-flush-beats-four-of-a-kind
|
140
|
+
(is (f ["4S 5H 5S 5D 5C"
|
141
|
+
"7S 8S 9S 6S 10S"]
|
142
|
+
["7S 8S 9S 6S 10S"])))
|
143
|
+
|
144
|
+
(deftest both-hands-have-straight-flush-tie-goes-to-highest-ranked-card
|
145
|
+
(is (f ["4H 6H 7H 8H 5H"
|
146
|
+
"5S 7S 8S 9S 6S"]
|
147
|
+
["5S 7S 8S 9S 6S"])))
|
data/tracks/swift/.travis.yml
CHANGED
data/tracks/swift/circle.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
version: 2
|
2
2
|
|
3
3
|
jobs:
|
4
|
-
|
4
|
+
build930:
|
5
5
|
macos:
|
6
|
-
xcode: "9.
|
6
|
+
xcode: "9.3.0"
|
7
7
|
steps:
|
8
8
|
- checkout
|
9
9
|
- run: sudo gem install danger
|
@@ -15,6 +15,12 @@ jobs:
|
|
15
15
|
name: Danger Systems
|
16
16
|
when: on_success
|
17
17
|
command: danger || true # Dont fail build on non zero exit codes
|
18
|
+
build920:
|
19
|
+
macos:
|
20
|
+
xcode: "9.2.0"
|
21
|
+
steps:
|
22
|
+
- checkout
|
23
|
+
- run: ./xswift-test-spm
|
18
24
|
build910:
|
19
25
|
macos:
|
20
26
|
xcode: "9.1.0"
|
@@ -34,3 +40,4 @@ workflows:
|
|
34
40
|
- build901
|
35
41
|
- build910
|
36
42
|
- build920
|
43
|
+
- build930
|
@@ -344,6 +344,21 @@
|
|
344
344
|
"unlocked_by": "bob",
|
345
345
|
"uuid": "50447e18-cfe8-43fb-a791-e8a82483bef6"
|
346
346
|
},
|
347
|
+
{
|
348
|
+
"core": false,
|
349
|
+
"difficulty": 4,
|
350
|
+
"slug": "proverb",
|
351
|
+
"topics": [
|
352
|
+
"arrays",
|
353
|
+
"control_flow_conditionals",
|
354
|
+
"control_flow_loops",
|
355
|
+
"optional_values",
|
356
|
+
"strings",
|
357
|
+
"text_formatting"
|
358
|
+
],
|
359
|
+
"unlocked_by": "bob",
|
360
|
+
"uuid": "b18876a7-f281-46e5-94b9-f805bb0d1fec"
|
361
|
+
},
|
347
362
|
{
|
348
363
|
"core": false,
|
349
364
|
"difficulty": 5,
|
@@ -825,6 +840,20 @@
|
|
825
840
|
"unlocked_by": "pangram",
|
826
841
|
"uuid": "b646dc26-59c1-436e-883a-20290de7a526"
|
827
842
|
},
|
843
|
+
{
|
844
|
+
"core": false,
|
845
|
+
"difficulty": 7,
|
846
|
+
"slug": "kindergarten-garden",
|
847
|
+
"topics": [
|
848
|
+
"Control-flow (conditionals)",
|
849
|
+
"Control-flow (loops)",
|
850
|
+
"Strings",
|
851
|
+
"Arrays",
|
852
|
+
"Text formatting"
|
853
|
+
],
|
854
|
+
"unlocked_by": "wordy",
|
855
|
+
"uuid": "b1ab1795-3f8e-43f6-86b4-88be4967e934"
|
856
|
+
},
|
828
857
|
{
|
829
858
|
"core": false,
|
830
859
|
"difficulty": 5,
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# Kindergarten Garden
|
2
|
+
|
3
|
+
Given a diagram, determine which plants each child in the kindergarten class is
|
4
|
+
responsible for.
|
5
|
+
|
6
|
+
The kindergarten class is learning about growing plants. The teacher
|
7
|
+
thought it would be a good idea to give them actual seeds, plant them in
|
8
|
+
actual dirt, and grow actual plants.
|
9
|
+
|
10
|
+
They've chosen to grow grass, clover, radishes, and violets.
|
11
|
+
|
12
|
+
To this end, the children have put little cups along the window sills, and
|
13
|
+
planted one type of plant in each cup, choosing randomly from the available
|
14
|
+
types of seeds.
|
15
|
+
|
16
|
+
```text
|
17
|
+
[window][window][window]
|
18
|
+
........................ # each dot represents a cup
|
19
|
+
........................
|
20
|
+
```
|
21
|
+
|
22
|
+
There are 12 children in the class:
|
23
|
+
|
24
|
+
- Alice, Bob, Charlie, David,
|
25
|
+
- Eve, Fred, Ginny, Harriet,
|
26
|
+
- Ileana, Joseph, Kincaid, and Larry.
|
27
|
+
|
28
|
+
Each child gets 4 cups, two on each row. Their teacher assigns cups to
|
29
|
+
the children alphabetically by their names.
|
30
|
+
|
31
|
+
The following diagram represents Alice's plants:
|
32
|
+
|
33
|
+
```text
|
34
|
+
[window][window][window]
|
35
|
+
VR......................
|
36
|
+
RG......................
|
37
|
+
```
|
38
|
+
|
39
|
+
In the first row, nearest the windows, she has a violet and a radish. In the
|
40
|
+
second row she has a radish and some grass.
|
41
|
+
|
42
|
+
Your program will be given the plants from left-to-right starting with
|
43
|
+
the row nearest the windows. From this, it should be able to determine
|
44
|
+
which plants belong to each student.
|
45
|
+
|
46
|
+
For example, if it's told that the garden looks like so:
|
47
|
+
|
48
|
+
```text
|
49
|
+
[window][window][window]
|
50
|
+
VRCGVVRVCGGCCGVRGCVCGCGV
|
51
|
+
VRCCCGCRRGVCGCRVVCVGCGCV
|
52
|
+
```
|
53
|
+
|
54
|
+
Then if asked for Alice's plants, it should provide:
|
55
|
+
|
56
|
+
- Violets, radishes, violets, radishes
|
57
|
+
|
58
|
+
While asking for Bob's plants would yield:
|
59
|
+
|
60
|
+
- Clover, grass, clover, clover
|
61
|
+
|
62
|
+
## Setup
|
63
|
+
|
64
|
+
Go through the setup instructions for Typescript to
|
65
|
+
install the necessary dependencies:
|
66
|
+
|
67
|
+
http://exercism.io/languages/typescript
|
68
|
+
|
69
|
+
## Requirements
|
70
|
+
|
71
|
+
Install assignment dependencies:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
$ yarn install
|
75
|
+
```
|
76
|
+
|
77
|
+
## Making the test suite pass
|
78
|
+
|
79
|
+
Execute the tests with:
|
80
|
+
|
81
|
+
```bash
|
82
|
+
$ yarn test
|
83
|
+
```
|
84
|
+
|
85
|
+
In the test suites all tests but the first have been skipped.
|
86
|
+
|
87
|
+
Once you get a test passing, you can enable the next one by
|
88
|
+
changing `xit` to `it`.
|
89
|
+
|
90
|
+
|
91
|
+
## Source
|
92
|
+
|
93
|
+
Random musings during airplane trip. [http://jumpstartlab.com](http://jumpstartlab.com)
|
94
|
+
|
95
|
+
## Submitting Incomplete Solutions
|
96
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
97
|
+
<Paste>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
const defaultChildren = [
|
2
|
+
'Alice',
|
3
|
+
'Bob',
|
4
|
+
'Charlie',
|
5
|
+
'David',
|
6
|
+
'Eve',
|
7
|
+
'Fred',
|
8
|
+
'Ginny',
|
9
|
+
'Harriet',
|
10
|
+
'Ileana',
|
11
|
+
'Joseph',
|
12
|
+
'Kincaid',
|
13
|
+
'Larry',
|
14
|
+
]
|
15
|
+
|
16
|
+
interface Plants {
|
17
|
+
[code: string]: string
|
18
|
+
}
|
19
|
+
|
20
|
+
const plants: Plants = {
|
21
|
+
G: "grass",
|
22
|
+
V: "violets",
|
23
|
+
R: "radishes",
|
24
|
+
C: "clover"
|
25
|
+
}
|
26
|
+
|
27
|
+
interface Pots {
|
28
|
+
upper: string[]
|
29
|
+
lower: string[]
|
30
|
+
}
|
31
|
+
|
32
|
+
const converToPots = (pots: string[][]): Pots => {
|
33
|
+
return {
|
34
|
+
upper: pots[0],
|
35
|
+
lower: pots[1]
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
const getPlants = (pots: Pots, index: number): string[] => {
|
40
|
+
const plants = []
|
41
|
+
const position = 2 * index
|
42
|
+
plants.push(pots.upper[position])
|
43
|
+
plants.push(pots.upper[position + 1])
|
44
|
+
plants.push(pots.lower[position])
|
45
|
+
plants.push(pots.lower[position + 1])
|
46
|
+
return plants
|
47
|
+
}
|
48
|
+
|
49
|
+
const parse = (diagram: string): string[][] => {
|
50
|
+
return diagram.split('\n').map((row) => [...row].map((sign) => plants[sign]))
|
51
|
+
}
|
52
|
+
|
53
|
+
export default class Garden {
|
54
|
+
[student: string]: string[]
|
55
|
+
|
56
|
+
constructor(diagrams: string, students?: string[]) {
|
57
|
+
this.students = students || defaultChildren
|
58
|
+
this.students.sort()
|
59
|
+
|
60
|
+
this.students.forEach((student, index) => {
|
61
|
+
this[student.toLocaleLowerCase()] = getPlants(converToPots(parse(diagrams)), index)
|
62
|
+
})
|
63
|
+
}
|
64
|
+
}
|