trackler 2.2.1.86 → 2.2.1.87
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/problem-specifications/exercises/reverse-string/metadata.yml +0 -1
- data/tracks/bash/CONTRIBUTING.md +129 -28
- data/tracks/bash/config/exercise_readme.go.tmpl +10 -4
- data/tracks/bash/exercises/acronym/README.md +8 -11
- data/tracks/bash/exercises/acronym/{acronym_tests.sh → acronym_test.sh} +0 -0
- data/tracks/bash/exercises/anagram/README.md +6 -1
- data/tracks/bash/exercises/anagram/anagram_test.sh +1 -1
- data/tracks/bash/exercises/armstrong-numbers/README.md +10 -2
- data/tracks/bash/exercises/atbash-cipher/README.md +6 -6
- data/tracks/bash/exercises/bob/README.md +8 -1
- data/tracks/bash/exercises/collatz-conjecture/README.md +11 -2
- data/tracks/bash/exercises/collatz-conjecture/{collatz_test.sh → collatz_conjecture_test.sh} +6 -6
- data/tracks/bash/exercises/difference-of-squares/README.md +6 -1
- data/tracks/bash/exercises/error-handling/README.md +13 -5
- data/tracks/bash/exercises/error-handling/error_handling_test.sh +18 -22
- data/tracks/bash/exercises/error-handling/example.sh +7 -6
- data/tracks/bash/exercises/gigasecond/.meta/hints.md +0 -5
- data/tracks/bash/exercises/gigasecond/README.md +36 -1
- data/tracks/bash/exercises/grains/README.md +10 -2
- data/tracks/bash/exercises/hamming/README.md +6 -1
- data/tracks/bash/exercises/hello-world/README.md +7 -2
- data/tracks/bash/exercises/leap/README.md +7 -2
- data/tracks/bash/exercises/luhn/README.md +7 -2
- data/tracks/bash/exercises/nucleotide-count/README.md +13 -22
- data/tracks/bash/exercises/pangram/README.md +7 -2
- data/tracks/bash/exercises/phone-number/README.md +10 -4
- data/tracks/bash/exercises/raindrops/README.md +6 -1
- data/tracks/bash/exercises/reverse-string/README.md +11 -2
- data/tracks/bash/exercises/rna-transcription/README.md +7 -2
- data/tracks/bash/exercises/roman-numerals/README.md +11 -2
- data/tracks/bash/exercises/triangle/README.md +5 -4
- data/tracks/bash/exercises/two-fer/README.md +7 -9
- data/tracks/bash/exercises/word-count/README.md +6 -2
- data/tracks/bash/exercises/word-count/example.sh +22 -13
- data/tracks/bash/scripts/canonical_data_check.sh +112 -0
- data/tracks/c/exercises/acronym/src/{example.h → acronym.h} +0 -0
- data/tracks/c/exercises/gigasecond/.meta/hints.md +124 -0
- data/tracks/c/exercises/gigasecond/README.md +126 -0
- data/tracks/c/exercises/isogram/src/{example.h → isogram.h} +0 -0
- data/tracks/c/exercises/meetup/.meta/hints.md +124 -0
- data/tracks/c/exercises/meetup/README.md +142 -12
- data/tracks/c/exercises/pangram/src/{example.h → pangram.h} +0 -0
- data/tracks/c/exercises/space-age/.meta/hints.md +124 -0
- data/tracks/c/exercises/space-age/README.md +127 -2
- data/tracks/elisp/bin/test-examples +11 -14
- data/tracks/elisp/config.json +9 -1
- data/tracks/elisp/exercises/acronym/README.md +13 -0
- data/tracks/elisp/exercises/acronym/acronym-test.el +28 -0
- data/tracks/elisp/exercises/acronym/acronym.el +11 -0
- data/tracks/elisp/exercises/acronym/example.el +14 -0
- data/tracks/elisp/exercises/bob/example.el +1 -3
- data/tracks/elisp/exercises/hamming/README.md +2 -0
- data/tracks/elisp/exercises/hamming/hamming-test.el +35 -12
- data/tracks/elisp/exercises/hamming/hamming.el +0 -3
- data/tracks/fsharp/exercises/custom-set/CustomSetTest.fs +206 -132
- data/tracks/fsharp/exercises/custom-set/Example.fs +2 -0
- data/tracks/fsharp/generators/Generators.fs +61 -0
- data/tracks/go/config.json +25 -2
- data/tracks/go/exercises/acronym/acronym_test.go +8 -0
- data/tracks/go/exercises/alphametics/.meta/gen.go +72 -0
- data/tracks/go/exercises/alphametics/.meta/hints.md +38 -0
- data/tracks/go/exercises/alphametics/README.md +93 -0
- data/tracks/go/exercises/alphametics/alphametics_test.go +33 -0
- data/tracks/go/exercises/alphametics/cases_test.go +59 -0
- data/tracks/go/exercises/alphametics/example.go +212 -0
- data/tracks/go/exercises/atbash-cipher/.meta/gen.go +6 -4
- data/tracks/go/exercises/atbash-cipher/cases_test.go +2 -2
- data/tracks/go/exercises/change/.meta/gen.go +7 -5
- data/tracks/go/exercises/change/cases_test.go +2 -2
- data/tracks/go/exercises/collatz-conjecture/.meta/gen.go +5 -3
- data/tracks/go/exercises/collatz-conjecture/cases_test.go +2 -2
- data/tracks/go/exercises/connect/.meta/gen.go +5 -3
- data/tracks/go/exercises/connect/cases_test.go +2 -2
- data/tracks/go/exercises/flatten-array/.meta/gen.go +5 -3
- data/tracks/go/exercises/flatten-array/cases_test.go +2 -2
- data/tracks/go/exercises/meetup/.meta/gen.go +19 -8
- data/tracks/go/exercises/meetup/cases_test.go +2 -2
- data/tracks/go/exercises/simple-linked-list/README.md +47 -0
- data/tracks/go/exercises/simple-linked-list/example.go +74 -0
- data/tracks/go/exercises/simple-linked-list/linked_list_test.go +210 -0
- data/tracks/idris/config.json +2 -2
- data/tracks/java/exercises/all-your-base/.meta/src/reference/java/BaseConverter.java +1 -5
- data/tracks/java/exercises/all-your-base/.meta/version +1 -1
- data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +34 -10
- data/tracks/java/exercises/bob/README.md +2 -0
- data/tracks/java/exercises/kindergarten-garden/.meta/version +1 -0
- data/tracks/java/exercises/kindergarten-garden/src/test/java/KindergartenGardenTest.java +0 -55
- data/tracks/java/exercises/meetup/.meta/version +1 -0
- data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +32 -0
- data/tracks/java/exercises/parallel-letter-frequency/README.md +1 -0
- data/tracks/java/exercises/proverb/README.md +16 -10
- data/tracks/java/exercises/rail-fence-cipher/README.md +5 -6
- data/tracks/java/exercises/two-fer/README.md +1 -1
- data/tracks/java/exercises/word-search/.meta/version +1 -1
- data/tracks/java/exercises/word-search/src/test/java/WordSearcherTest.java +240 -2
- data/tracks/javascript/.eslintignore +0 -1
- data/tracks/javascript/exercises/palindrome-products/example.js +3 -3
- data/tracks/kotlin/docs/INSTALLATION.md +77 -68
- data/tracks/kotlin/docs/TESTS.md +41 -39
- data/tracks/perl6/exercises/acronym/acronym.t +20 -8
- data/tracks/perl6/exercises/acronym/example.yaml +1 -1
- data/tracks/perl6/exercises/all-your-base/all-your-base.t +108 -66
- data/tracks/perl6/exercises/all-your-base/example.yaml +2 -2
- data/tracks/perl6/exercises/allergies/allergies.t +39 -15
- data/tracks/perl6/exercises/allergies/example.yaml +2 -2
- data/tracks/perl6/exercises/anagram/anagram.t +73 -40
- data/tracks/perl6/exercises/anagram/example.yaml +1 -1
- data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +38 -15
- data/tracks/perl6/exercises/atbash-cipher/example.yaml +1 -1
- data/tracks/perl6/exercises/bob/bob.t +77 -27
- data/tracks/perl6/exercises/bob/example.yaml +1 -1
- data/tracks/perl6/exercises/flatten-array/example.yaml +1 -1
- data/tracks/perl6/exercises/flatten-array/flatten-array.t +20 -8
- data/tracks/perl6/exercises/luhn/example.yaml +1 -1
- data/tracks/perl6/exercises/luhn/luhn.t +42 -16
- data/tracks/perl6/exercises/roman-numerals/README.md +68 -0
- data/tracks/php/exercises/gigasecond/gigasecond_test.php +1 -1
- data/tracks/python/docs/ABOUT.md +2 -2
- metadata +27 -10
- data/tracks/bash/docs/EXERCISE_README_INSERT.md +0 -3
- data/tracks/bash/exercises/word-count/example.awk +0 -12
- data/tracks/java/exercises/alphametics/src/main/java/.keep +0 -0
@@ -14,16 +14,16 @@ module.exports = function Palindromes(options) {
|
|
14
14
|
for (var i = minFactor; i <= maxFactor; i++) {
|
15
15
|
for (var j = minFactor; j <= maxFactor; j++) {
|
16
16
|
var result = i * j;
|
17
|
-
if (
|
17
|
+
if (!this.isPalindrome(result)) { continue; }
|
18
18
|
|
19
19
|
var newFactor = [i, j].sort();
|
20
20
|
|
21
|
-
if (palindromes[result]
|
21
|
+
if (!Array.isArray(palindromes[result])) {
|
22
22
|
palindromes[result] = [];
|
23
23
|
palindromeIndexes.push(result);
|
24
24
|
}
|
25
25
|
|
26
|
-
if (
|
26
|
+
if (!arrayContainsArray(palindromes[result], newFactor)) {
|
27
27
|
palindromes[result].push(newFactor);
|
28
28
|
}
|
29
29
|
}
|
@@ -24,23 +24,25 @@ Open an administrative command prompt. (If you need assistance opening an admin
|
|
24
24
|
|
25
25
|
1. If you have not installed Chocolatey, do so now:
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
```batchfile
|
28
|
+
C:\Windows\system32> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
|
29
|
+
```
|
30
|
+
|
30
31
|
2. Install the JDK:
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
```batchfile
|
34
|
+
C:\Windows\system32> choco install jdk8
|
35
|
+
...
|
36
|
+
C:\Windows\system32> refreshenv
|
37
|
+
...
|
38
|
+
```
|
39
|
+
|
38
40
|
3. Install Gradle:
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
```batchfile
|
43
|
+
C:\Windows\system32>choco install gradle
|
44
|
+
...
|
45
|
+
```
|
44
46
|
|
45
47
|
We recommend closing the administrative command prompt and opening a new command prompt -- you do not require administrator priviledges to practice Exercism exercises.
|
46
48
|
|
@@ -58,24 +60,27 @@ Below are instructions for install using the most common method - using Homebrew
|
|
58
60
|
|
59
61
|
1. If you haven't installed [Homebrew](http://brew.sh), yet, do so now:
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
```sh
|
64
|
+
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
65
|
+
```
|
66
|
+
|
64
67
|
2. Tap the [Homebrew Cask](https://caskroom.github.io/) — this allows us to install pre-built binaries like the JDK.
|
65
68
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
+
```
|
70
|
+
$ brew tap caskroom/cask
|
71
|
+
```
|
72
|
+
|
69
73
|
3. Install the JDK:
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
```
|
76
|
+
$ brew cask install java
|
77
|
+
```
|
78
|
+
|
74
79
|
4. Install Gradle:
|
75
80
|
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
```
|
82
|
+
$ brew install gradle
|
83
|
+
```
|
79
84
|
|
80
85
|
You now are ready to get started with the Kotlin track of Exercism!
|
81
86
|
|
@@ -98,21 +103,22 @@ If you are using Debian or its derivatives (like Ubuntu or Linux Mint), use APT:
|
|
98
103
|
|
99
104
|
1. Install the JDK:
|
100
105
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
```sh
|
107
|
+
$ sudo apt-get update
|
108
|
+
$ sudo apt-get install python-software-properties
|
109
|
+
$ sudo add-apt-repository ppa:webupd8team/java
|
110
|
+
$ sudo apt-get update
|
111
|
+
$ sudo apt-get install oracle-java8-installer
|
112
|
+
$ sudo apt install oracle-java8-set-default
|
113
|
+
```
|
114
|
+
|
109
115
|
2. Install Gradle:
|
110
116
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
117
|
+
```sh
|
118
|
+
$ sudo add-apt-repository ppa:cwchien/gradle
|
119
|
+
$ sudo apt-get update
|
120
|
+
$ sudo apt-get install gradle
|
121
|
+
```
|
116
122
|
|
117
123
|
You now are ready to get started with the Kotlin track of Exercism!
|
118
124
|
|
@@ -128,14 +134,15 @@ If you are using Fedora or its derivatives, use DNF:
|
|
128
134
|
|
129
135
|
1. Install the JDK:
|
130
136
|
|
131
|
-
|
132
|
-
|
133
|
-
|
137
|
+
```sh
|
138
|
+
$ sudo dnf install java-1.8.0-openjdk-devel
|
139
|
+
```
|
140
|
+
|
134
141
|
2. Install Gradle:
|
135
142
|
|
136
|
-
|
137
|
-
|
138
|
-
|
143
|
+
```sh
|
144
|
+
$ sudo dnf install gradle
|
145
|
+
```
|
139
146
|
|
140
147
|
|
141
148
|
You now are ready to get started with the Kotlin track of Exercism!
|
@@ -183,20 +190,21 @@ To get started, see "[Running the Tests](http://exercism.io/languages/kotlin/tes
|
|
183
190
|
1. Download "**Binary only distribution**" from the [Gradle download page](https://gradle.org/gradle-download/).
|
184
191
|
2. Unpack Gradle:
|
185
192
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
193
|
+
```sh
|
194
|
+
$ mkdir ~/tools
|
195
|
+
$ cd ~/tools
|
196
|
+
$ unzip ~/Downloads/gradle-*-bin.zip
|
197
|
+
$ cd gradle*
|
198
|
+
```
|
199
|
+
|
192
200
|
3. Configure Gradle and add it to the path:
|
193
201
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
202
|
+
```sh
|
203
|
+
$ cat << DONE >> ~/.bashrc
|
204
|
+
export GRADLE_HOME=`pwd`
|
205
|
+
export PATH=\$PATH:\$GRADLE_HOME/bin
|
206
|
+
DONE
|
207
|
+
```
|
200
208
|
|
201
209
|
|
202
210
|
You now are ready to get started with the Kotlin track of Exercism!
|
@@ -216,20 +224,21 @@ To get started, see "[Running the Tests](http://exercism.io/languages/kotlin/tes
|
|
216
224
|
1. Download "**Binary only distribution**" from the [Gradle download page](https://gradle.org/gradle-download/).
|
217
225
|
2. Unpack Gradle:
|
218
226
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
227
|
+
```sh
|
228
|
+
$ mkdir ~/tools
|
229
|
+
$ cd ~/tools
|
230
|
+
$ unzip ~/Downloads/gradle-*-bin.zip
|
231
|
+
$ cd gradle*
|
232
|
+
```
|
233
|
+
|
225
234
|
3. Configure Gradle and add it to the path:
|
226
235
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
236
|
+
```sh
|
237
|
+
$ cat << DONE >> ~/.bashrc
|
238
|
+
export GRADLE_HOME=`pwd`
|
239
|
+
export PATH=\$PATH:\$GRADLE_HOME/bin
|
240
|
+
DONE
|
241
|
+
```
|
233
242
|
|
234
243
|
You now are ready to get started with the Kotlin track of Exercism!
|
235
244
|
|
data/tracks/kotlin/docs/TESTS.md
CHANGED
@@ -13,30 +13,31 @@ Choose your operating system:
|
|
13
13
|
1. Open a Command Prompt.
|
14
14
|
2. Get the first exercise:
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
Not Submitted: 1 problem
|
20
|
-
Kotlin (Hello World) C:\Users\JohnDoe\exercism\kotlin\hello-world
|
16
|
+
```batchfile
|
17
|
+
C:\Users\JohnDoe>exercism fetch kotlin
|
21
18
|
|
22
|
-
|
23
|
-
|
19
|
+
Not Submitted: 1 problem
|
20
|
+
Kotlin (Hello World) C:\Users\JohnDoe\exercism\kotlin\hello-world
|
24
21
|
|
25
|
-
|
22
|
+
New: 1 problem
|
23
|
+
Kotlin (Hello World) C:\Users\JohnDoe\exercism\kotlin\hello-world
|
24
|
+
|
25
|
+
unchanged: 0, updated: 0, new: 1
|
26
|
+
```
|
26
27
|
|
27
|
-
```
|
28
28
|
3. Change directory into the exercism:
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
```batchfile
|
31
|
+
C:\Users\JohnDoe>cd C:\Users\JohnDoe\exercism\kotlin\hello-world
|
32
|
+
```
|
33
33
|
|
34
34
|
4. Run the tests:
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
```batchfile
|
37
|
+
C:\Users\JohnDoe>gradle test
|
38
|
+
```
|
39
39
|
*(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
|
40
|
+
|
40
41
|
5. Solve the exercise. Find and work through the `TUTORIAL.md` guide ([view on GitHub](https://github.com/exercism/kotlin/blob/master/exercises/hello-world/TUTORIAL.md)).
|
41
42
|
|
42
43
|
|
@@ -50,25 +51,26 @@ If you get stuck, at any point, don't forget to reach out for [help](http://exer
|
|
50
51
|
|
51
52
|
1. In the terminal window, get the first exercise:
|
52
53
|
|
53
|
-
|
54
|
-
|
54
|
+
```
|
55
|
+
$ exercism fetch kotlin
|
55
56
|
|
56
|
-
|
57
|
-
|
57
|
+
New: 1 problem
|
58
|
+
Kotlin (Etl) /Users/johndoe/exercism/kotlin/hello-world
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
unchanged: 0, updated: 0, new: 1
|
61
|
+
```
|
61
62
|
|
62
63
|
2. Change directory into the exercise:
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
```
|
66
|
+
$ cd /Users/johndoe/exercism/kotlin/hello-world
|
67
|
+
```
|
68
|
+
|
67
69
|
3. Run the tests:
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
71
|
+
```
|
72
|
+
$ gradle test
|
73
|
+
```
|
72
74
|
*(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
|
73
75
|
|
74
76
|
4. Solve the exercise. Find and work through the `TUTORIAL.md` guide ([view on GitHub](https://github.com/exercism/kotlin/blob/master/exercises/hello-world/TUTORIAL.md)).
|
@@ -83,26 +85,26 @@ If you get stuck, at any point, don't forget to reach out for [help](http://exer
|
|
83
85
|
|
84
86
|
1. In the terminal window, get the first exercise:
|
85
87
|
|
86
|
-
|
87
|
-
|
88
|
+
```
|
89
|
+
$ exercism fetch kotlin
|
88
90
|
|
89
|
-
|
90
|
-
|
91
|
+
New: 1 problem
|
92
|
+
Kotlin (Etl) /home/johndoe/exercism/kotlin/hello-world
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
+
unchanged: 0, updated: 0, new: 1
|
95
|
+
```
|
94
96
|
|
95
97
|
2. Change directory into the exercise:
|
96
98
|
|
97
|
-
|
98
|
-
|
99
|
-
|
99
|
+
```
|
100
|
+
$ cd /home/johndoe/exercism/kotlin/hello-world
|
101
|
+
```
|
100
102
|
|
101
103
|
3. Run the tests:
|
102
104
|
|
103
|
-
|
104
|
-
|
105
|
-
|
105
|
+
```
|
106
|
+
$ gradle test
|
107
|
+
```
|
106
108
|
*(Don't worry about the tests failing, at first, this is how you begin each exercise.)*
|
107
109
|
|
108
110
|
4. Solve the exercise. Find and work through the `TUTORIAL.md` guide ([view on GitHub](https://github.com/exercism/kotlin/blob/master/exercises/hello-world/TUTORIAL.mdhttps://github.com/exercism/kotlin/blob/master/exercises/hello-world/GETTING_STARTED.mdhttps://github.com/exercism/kotlin/blob/master/exercises/hello-world/GETTING_STARTED.mdhttps://github.com/exercism/kotlin/blob/master/exercises/hello-world/GETTING_STARTED.md)).
|
@@ -24,7 +24,7 @@ require ::($module) <&abbreviate>;
|
|
24
24
|
my $c-data = from-json $=pod.pop.contents;
|
25
25
|
|
26
26
|
for $c-data<cases>»<cases>».Array.flat {
|
27
|
-
is abbreviate(.<phrase>), |.<expected description>;
|
27
|
+
is abbreviate(.<input><phrase>), |.<expected description>;
|
28
28
|
}
|
29
29
|
|
30
30
|
=head2 Canonical Data
|
@@ -32,7 +32,7 @@ for $c-data<cases>»<cases>».Array.flat {
|
|
32
32
|
|
33
33
|
{
|
34
34
|
"exercise": "acronym",
|
35
|
-
"version": "1.
|
35
|
+
"version": "1.2.0",
|
36
36
|
"cases": [
|
37
37
|
{
|
38
38
|
"description": "Abbreviate a phrase",
|
@@ -40,37 +40,49 @@ for $c-data<cases>»<cases>».Array.flat {
|
|
40
40
|
{
|
41
41
|
"description": "basic",
|
42
42
|
"property": "abbreviate",
|
43
|
-
"
|
43
|
+
"input": {
|
44
|
+
"phrase": "Portable Network Graphics"
|
45
|
+
},
|
44
46
|
"expected": "PNG"
|
45
47
|
},
|
46
48
|
{
|
47
49
|
"description": "lowercase words",
|
48
50
|
"property": "abbreviate",
|
49
|
-
"
|
51
|
+
"input": {
|
52
|
+
"phrase": "Ruby on Rails"
|
53
|
+
},
|
50
54
|
"expected": "ROR"
|
51
55
|
},
|
52
56
|
{
|
53
57
|
"description": "punctuation",
|
54
58
|
"property": "abbreviate",
|
55
|
-
"
|
59
|
+
"input": {
|
60
|
+
"phrase": "First In, First Out"
|
61
|
+
},
|
56
62
|
"expected": "FIFO"
|
57
63
|
},
|
58
64
|
{
|
59
65
|
"description": "all caps words",
|
60
66
|
"property": "abbreviate",
|
61
|
-
"
|
67
|
+
"input": {
|
68
|
+
"phrase": "PHP: Hypertext Preprocessor"
|
69
|
+
},
|
62
70
|
"expected": "PHP"
|
63
71
|
},
|
64
72
|
{
|
65
73
|
"description": "non-acronym all caps word",
|
66
74
|
"property": "abbreviate",
|
67
|
-
"
|
75
|
+
"input": {
|
76
|
+
"phrase": "GNU Image Manipulation Program"
|
77
|
+
},
|
68
78
|
"expected": "GIMP"
|
69
79
|
},
|
70
80
|
{
|
71
81
|
"description": "hyphenated",
|
72
82
|
"property": "abbreviate",
|
73
|
-
"
|
83
|
+
"input": {
|
84
|
+
"phrase": "Complementary metal-oxide semiconductor"
|
85
|
+
},
|
74
86
|
"expected": "CMOS"
|
75
87
|
}
|
76
88
|
]
|
@@ -25,8 +25,8 @@ my $c-data = from-json $=pod.pop.contents;
|
|
25
25
|
for $c-data<cases>.values -> $case {
|
26
26
|
sub call-convert-base {
|
27
27
|
convert-base(
|
28
|
-
bases => %(<from to> Z=> .<input_base output_base>),
|
29
|
-
digits => .<
|
28
|
+
bases => %(<from to> Z=> .<input><input_base output_base>),
|
29
|
+
digits => .<input><digits>,
|
30
30
|
) given $case;
|
31
31
|
}
|
32
32
|
|
@@ -45,7 +45,7 @@ for $c-data<cases>.values -> $case {
|
|
45
45
|
|
46
46
|
{
|
47
47
|
"exercise": "all-your-base",
|
48
|
-
"version": "2.0
|
48
|
+
"version": "2.1.0",
|
49
49
|
"comments": [
|
50
50
|
"This canonical data makes the following choices:",
|
51
51
|
"1. Zero is always represented in outputs as [0] instead of [].",
|
@@ -61,169 +61,211 @@ for $c-data<cases>.values -> $case {
|
|
61
61
|
{
|
62
62
|
"description": "single bit one to decimal",
|
63
63
|
"property": "rebase",
|
64
|
-
"
|
65
|
-
|
66
|
-
|
64
|
+
"input": {
|
65
|
+
"input_base": 2,
|
66
|
+
"digits": [1],
|
67
|
+
"output_base": 10
|
68
|
+
},
|
67
69
|
"expected": [1]
|
68
70
|
},
|
69
71
|
{
|
70
72
|
"description": "binary to single decimal",
|
71
73
|
"property": "rebase",
|
72
|
-
"
|
73
|
-
|
74
|
-
|
74
|
+
"input": {
|
75
|
+
"input_base": 2,
|
76
|
+
"digits": [1, 0, 1],
|
77
|
+
"output_base": 10
|
78
|
+
},
|
75
79
|
"expected": [5]
|
76
80
|
},
|
77
81
|
{
|
78
82
|
"description": "single decimal to binary",
|
79
83
|
"property": "rebase",
|
80
|
-
"
|
81
|
-
|
82
|
-
|
84
|
+
"input": {
|
85
|
+
"input_base": 10,
|
86
|
+
"digits": [5],
|
87
|
+
"output_base": 2
|
88
|
+
},
|
83
89
|
"expected": [1, 0, 1]
|
84
90
|
},
|
85
91
|
{
|
86
92
|
"description": "binary to multiple decimal",
|
87
93
|
"property": "rebase",
|
88
|
-
"
|
89
|
-
|
90
|
-
|
94
|
+
"input": {
|
95
|
+
"input_base": 2,
|
96
|
+
"digits": [1, 0, 1, 0, 1, 0],
|
97
|
+
"output_base": 10
|
98
|
+
},
|
91
99
|
"expected": [4, 2]
|
92
100
|
},
|
93
101
|
{
|
94
102
|
"description": "decimal to binary",
|
95
103
|
"property": "rebase",
|
96
|
-
"
|
97
|
-
|
98
|
-
|
104
|
+
"input": {
|
105
|
+
"input_base": 10,
|
106
|
+
"digits": [4, 2],
|
107
|
+
"output_base": 2
|
108
|
+
},
|
99
109
|
"expected": [1, 0, 1, 0, 1, 0]
|
100
110
|
},
|
101
111
|
{
|
102
112
|
"description": "trinary to hexadecimal",
|
103
113
|
"property": "rebase",
|
104
|
-
"
|
105
|
-
|
106
|
-
|
114
|
+
"input": {
|
115
|
+
"input_base": 3,
|
116
|
+
"digits": [1, 1, 2, 0],
|
117
|
+
"output_base": 16
|
118
|
+
},
|
107
119
|
"expected": [2, 10]
|
108
120
|
},
|
109
121
|
{
|
110
122
|
"description": "hexadecimal to trinary",
|
111
123
|
"property": "rebase",
|
112
|
-
"
|
113
|
-
|
114
|
-
|
124
|
+
"input": {
|
125
|
+
"input_base": 16,
|
126
|
+
"digits": [2, 10],
|
127
|
+
"output_base": 3
|
128
|
+
},
|
115
129
|
"expected": [1, 1, 2, 0]
|
116
130
|
},
|
117
131
|
{
|
118
132
|
"description": "15-bit integer",
|
119
133
|
"property": "rebase",
|
120
|
-
"
|
121
|
-
|
122
|
-
|
134
|
+
"input": {
|
135
|
+
"input_base": 97,
|
136
|
+
"digits": [3, 46, 60],
|
137
|
+
"output_base": 73
|
138
|
+
},
|
123
139
|
"expected": [6, 10, 45]
|
124
140
|
},
|
125
141
|
{
|
126
142
|
"description": "empty list",
|
127
143
|
"property": "rebase",
|
128
|
-
"
|
129
|
-
|
130
|
-
|
144
|
+
"input": {
|
145
|
+
"input_base": 2,
|
146
|
+
"digits": [],
|
147
|
+
"output_base": 10
|
148
|
+
},
|
131
149
|
"expected": [0]
|
132
150
|
},
|
133
151
|
{
|
134
152
|
"description": "single zero",
|
135
153
|
"property": "rebase",
|
136
|
-
"
|
137
|
-
|
138
|
-
|
154
|
+
"input": {
|
155
|
+
"input_base": 10,
|
156
|
+
"digits": [0],
|
157
|
+
"output_base": 2
|
158
|
+
},
|
139
159
|
"expected": [0]
|
140
160
|
},
|
141
161
|
{
|
142
162
|
"description": "multiple zeros",
|
143
163
|
"property": "rebase",
|
144
|
-
"
|
145
|
-
|
146
|
-
|
164
|
+
"input": {
|
165
|
+
"input_base": 10,
|
166
|
+
"digits": [0, 0, 0],
|
167
|
+
"output_base": 2
|
168
|
+
},
|
147
169
|
"expected": [0]
|
148
170
|
},
|
149
171
|
{
|
150
172
|
"description": "leading zeros",
|
151
173
|
"property": "rebase",
|
152
|
-
"
|
153
|
-
|
154
|
-
|
174
|
+
"input": {
|
175
|
+
"input_base": 7,
|
176
|
+
"digits": [0, 6, 0],
|
177
|
+
"output_base": 10
|
178
|
+
},
|
155
179
|
"expected": [4, 2]
|
156
180
|
},
|
157
181
|
{
|
158
182
|
"description": "input base is one",
|
159
183
|
"property": "rebase",
|
160
|
-
"
|
161
|
-
|
162
|
-
|
184
|
+
"input": {
|
185
|
+
"input_base": 1,
|
186
|
+
"digits": [],
|
187
|
+
"output_base": 10
|
188
|
+
},
|
163
189
|
"expected": {"error": "input base must be >= 2"}
|
164
190
|
},
|
165
191
|
{
|
166
192
|
"description": "input base is zero",
|
167
193
|
"property": "rebase",
|
168
|
-
"
|
169
|
-
|
170
|
-
|
194
|
+
"input": {
|
195
|
+
"input_base": 0,
|
196
|
+
"digits": [],
|
197
|
+
"output_base": 10
|
198
|
+
},
|
171
199
|
"expected": {"error": "input base must be >= 2"}
|
172
200
|
},
|
173
201
|
{
|
174
202
|
"description": "input base is negative",
|
175
203
|
"property": "rebase",
|
176
|
-
"
|
177
|
-
|
178
|
-
|
204
|
+
"input": {
|
205
|
+
"input_base": -2,
|
206
|
+
"digits": [1],
|
207
|
+
"output_base": 10
|
208
|
+
},
|
179
209
|
"expected": {"error": "input base must be >= 2"}
|
180
210
|
},
|
181
211
|
{
|
182
212
|
"description": "negative digit",
|
183
213
|
"property": "rebase",
|
184
|
-
"
|
185
|
-
|
186
|
-
|
214
|
+
"input": {
|
215
|
+
"input_base": 2,
|
216
|
+
"digits": [1, -1, 1, 0, 1, 0],
|
217
|
+
"output_base": 10
|
218
|
+
},
|
187
219
|
"expected": {"error": "all digits must satisfy 0 <= d < input base"}
|
188
220
|
},
|
189
221
|
{
|
190
222
|
"description": "invalid positive digit",
|
191
223
|
"property": "rebase",
|
192
|
-
"
|
193
|
-
|
194
|
-
|
224
|
+
"input": {
|
225
|
+
"input_base": 2,
|
226
|
+
"digits": [1, 2, 1, 0, 1, 0],
|
227
|
+
"output_base": 10
|
228
|
+
},
|
195
229
|
"expected": {"error": "all digits must satisfy 0 <= d < input base"}
|
196
230
|
},
|
197
231
|
{
|
198
232
|
"description": "output base is one",
|
199
233
|
"property": "rebase",
|
200
|
-
"
|
201
|
-
|
202
|
-
|
234
|
+
"input": {
|
235
|
+
"input_base": 2,
|
236
|
+
"digits": [1, 0, 1, 0, 1, 0],
|
237
|
+
"output_base": 1
|
238
|
+
},
|
203
239
|
"expected": {"error": "output base must be >= 2"}
|
204
240
|
},
|
205
241
|
{
|
206
242
|
"description": "output base is zero",
|
207
243
|
"property": "rebase",
|
208
|
-
"
|
209
|
-
|
210
|
-
|
244
|
+
"input": {
|
245
|
+
"input_base": 10,
|
246
|
+
"digits": [7],
|
247
|
+
"output_base": 0
|
248
|
+
},
|
211
249
|
"expected": {"error": "output base must be >= 2"}
|
212
250
|
},
|
213
251
|
{
|
214
252
|
"description": "output base is negative",
|
215
253
|
"property": "rebase",
|
216
|
-
"
|
217
|
-
|
218
|
-
|
254
|
+
"input": {
|
255
|
+
"input_base": 2,
|
256
|
+
"digits": [1],
|
257
|
+
"output_base": -7
|
258
|
+
},
|
219
259
|
"expected": {"error": "output base must be >= 2"}
|
220
260
|
},
|
221
261
|
{
|
222
262
|
"description": "both bases are negative",
|
223
263
|
"property": "rebase",
|
224
|
-
"
|
225
|
-
|
226
|
-
|
264
|
+
"input": {
|
265
|
+
"input_base": -2,
|
266
|
+
"digits": [1],
|
267
|
+
"output_base": -7
|
268
|
+
},
|
227
269
|
"expected": {"error": "input base must be >= 2"}
|
228
270
|
}
|
229
271
|
]
|