trackler 2.2.1.82 → 2.2.1.83
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/bash/.gitattributes +10 -0
- data/tracks/bash/CONTRIBUTING.md +3 -1
- data/tracks/{java/_template/src/example/java → bash/_template/.meta}/.keep +0 -0
- data/tracks/bash/_template/README.md +11 -0
- data/tracks/bash/_template/example.sh +3 -0
- data/tracks/bash/_template/exercise_slug_test.sh +17 -0
- data/tracks/bash/exercises/acronym/example.sh +1 -1
- data/tracks/bash/exercises/anagram/example.sh +1 -1
- data/tracks/bash/exercises/armstrong-numbers/example.sh +1 -1
- data/tracks/bash/exercises/atbash-cipher/example.sh +1 -1
- data/tracks/bash/exercises/bob/example.sh +1 -1
- data/tracks/bash/exercises/error-handling/example.sh +2 -0
- data/tracks/bash/exercises/gigasecond/example.sh +2 -0
- data/tracks/bash/exercises/hamming/example.sh +1 -1
- data/tracks/bash/exercises/hello-world/example.sh +1 -1
- data/tracks/bash/exercises/leap/example.sh +1 -1
- data/tracks/bash/exercises/nucleotide-count/example.sh +1 -1
- data/tracks/bash/exercises/pangram/example.sh +1 -1
- data/tracks/bash/exercises/raindrops/example.sh +1 -1
- data/tracks/bash/exercises/reverse-string/example.sh +1 -1
- data/tracks/bash/exercises/rna-transcription/example.sh +2 -0
- data/tracks/bash/exercises/roman-numerals/example.sh +1 -1
- data/tracks/bash/exercises/triangle/example.sh +3 -2
- data/tracks/bash/exercises/two-fer/example.sh +1 -1
- data/tracks/bash/exercises/word-count/example.sh +2 -2
- data/tracks/clojure/config.json +8 -0
- data/tracks/clojure/exercises/armstrong-numbers/README.md +19 -0
- data/tracks/clojure/exercises/armstrong-numbers/project.clj +4 -0
- data/tracks/clojure/exercises/armstrong-numbers/src/armstrong_numbers.clj +3 -0
- data/tracks/clojure/exercises/armstrong-numbers/src/example.clj +6 -0
- data/tracks/clojure/exercises/armstrong-numbers/test/armstrong_numbers_test.clj +35 -0
- data/tracks/common-lisp/exercises/sieve/example.lisp +10 -11
- data/tracks/common-lisp/exercises/sieve/sieve-test.lisp +30 -20
- data/tracks/go/exercises/all-your-base/all_your_base_test.go +5 -4
- data/tracks/go/exercises/pig-latin/.meta/gen.go +58 -0
- data/tracks/go/exercises/pig-latin/cases_test.go +122 -0
- data/tracks/go/exercises/pig-latin/example.go +20 -8
- data/tracks/go/exercises/pig-latin/pig_latin_test.go +9 -23
- data/tracks/java/_template/.meta/src/reference/java/.keep +0 -0
- data/tracks/java/exercises/acronym/.meta/src/reference/java/Acronym.java +8 -10
- data/tracks/java/exercises/anagram/.meta/src/reference/java/Anagram.java +4 -9
- data/tracks/java/exercises/atbash-cipher/.meta/src/reference/java/Atbash.java +2 -10
- data/tracks/java/exercises/hamming/.meta/version +1 -1
- data/tracks/java/exercises/hamming/src/test/java/HammingTest.java +3 -2
- data/tracks/java/exercises/isogram/.meta/version +1 -0
- data/tracks/java/exercises/isogram/src/test/java/IsogramCheckerTest.java +14 -21
- data/tracks/ruby/config.json +14 -2
- data/tracks/ruby/exercises/book-store/.meta/generator/book_store_case.rb +9 -0
- data/tracks/ruby/exercises/book-store/.meta/solutions/.version +1 -0
- data/tracks/ruby/exercises/book-store/.meta/solutions/book_store.rb +47 -0
- data/tracks/ruby/exercises/book-store/README.md +100 -0
- data/tracks/ruby/exercises/book-store/book_store_test.rb +97 -0
- data/tracks/ruby/exercises/change/README.md +49 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd3db94a01e41282f6733f0e8356e7781580009a
|
4
|
+
data.tar.gz: 25464cb3caef3b9481c20cea3a1e3667d8ffee6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb80d176aca640ed2e83cd55815849ff454d6184118095d1af15168bdaedbdb6abeae8dd94e527922e2945e7913f249018ecf38b9d1e3b19de6be8b915cde5c6
|
7
|
+
data.tar.gz: e54cbb2d9efcac874d7aacba8ed97a916adb53c639e3f01f212e08685fbeaa3fbd5bdbb84e3ec666f2b1df70cc1023af18aaaa8efc545dd24ffbc020c74afd20
|
data/lib/trackler/version.rb
CHANGED
data/tracks/bash/CONTRIBUTING.md
CHANGED
@@ -10,7 +10,9 @@ In order to run any of the test files (or examples, for that matter), you're goi
|
|
10
10
|
|
11
11
|
## Porting an Exercise from Another Language
|
12
12
|
|
13
|
-
Porting an exercise from another language is easy (ish)!
|
13
|
+
Porting an exercise from another language is easy (ish)! [Problem specifications](www.github.com/exercism/problem-specifications) for [unimplemented exercises](www.exercism.io/languages/bash/todo) can be used to do this.
|
14
|
+
|
15
|
+
The `_template` directory found in `exercism/bash` can be used to port exercises. Once an example submission, full test suite and README.md have been created, you just need to alter `config.json` to include the newly implemented exercise.
|
14
16
|
|
15
17
|
### Initial Setup
|
16
18
|
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
All exercises should have a README.md file. This file should be generated using the `configlet` tool.
|
4
|
+
|
5
|
+
If a `hints.md` file has been added to an exericse, that exercise's `readme` needs to be regenerated. This is because the `hints.md` file will get appended to the `readme` when the `readme` is generated.
|
6
|
+
|
7
|
+
To generate the `readme` you need to:
|
8
|
+
|
9
|
+
1. Download [`configlet`](https://github.com/exercism/configlet/releases) and put it somewhere on your path (`configlet` is the tool we use to generate `reame` files).
|
10
|
+
2. [Clone](https://help.github.com/articles/cloning-a-repository/) the [problem-specifications](https://github.com/exercism/problem-specifications) repository (this repo contains the template we use to generate `readme`s).
|
11
|
+
3. Run `configlet generate . --only exercise-slug --spec-path path_to_problem_specifications` from the root of this repository (exercism/bash).
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
@test "Test name - first test shouldn't be skipped" {
|
4
|
+
#skip
|
5
|
+
run bash exercise_slug.sh
|
6
|
+
|
7
|
+
[ "$status" -eq 0 ]
|
8
|
+
[ "$output" = "What's expected" ]
|
9
|
+
}
|
10
|
+
|
11
|
+
@test "Second test onwards should be skipped" {
|
12
|
+
skip
|
13
|
+
run bash exercise_slug.sh
|
14
|
+
|
15
|
+
[ "$status" -eq 0 ]
|
16
|
+
[ "$output" = "What's expected" ]
|
17
|
+
}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#!/bin/bash
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
2
3
|
set -o errexit # Stop script on command error
|
3
4
|
set -o nounset # Error out if accessing undefined variable name
|
4
5
|
set -o pipefail # Error out if any step in a pipe errors out
|
@@ -53,4 +54,4 @@ scalene() {
|
|
53
54
|
# If boolean clause is false, it doesn't evaluate the other side of &&
|
54
55
|
# If first thing is false, it evaluates the item after ||,
|
55
56
|
# but if first two are true, doesn't bother evaluating last part.
|
56
|
-
$triangle_type $s1 $s2 $s3 && exit 0 || exit 1
|
57
|
+
$triangle_type $s1 $s2 $s3 && exit 0 || exit 1
|
data/tracks/clojure/config.json
CHANGED
@@ -9,6 +9,14 @@
|
|
9
9
|
"unlocked_by": null,
|
10
10
|
"uuid": "1378910d-9bec-4217-bd40-07a8967fa3ad"
|
11
11
|
},
|
12
|
+
{
|
13
|
+
"core": false,
|
14
|
+
"difficulty": 1,
|
15
|
+
"slug": "armstrong-numbers",
|
16
|
+
"topics": null,
|
17
|
+
"unlocked_by": null,
|
18
|
+
"uuid": "a4bdbdfd-1db1-425c-a243-dd032dc7b93a"
|
19
|
+
},
|
12
20
|
{
|
13
21
|
"core": false,
|
14
22
|
"difficulty": 1,
|
@@ -0,0 +1,19 @@
|
|
1
|
+
## Armstrong numbers
|
2
|
+
|
3
|
+
An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits.
|
4
|
+
|
5
|
+
For example:
|
6
|
+
|
7
|
+
- 9 is an Armstrong number, because `9 = 9^1 = 9`
|
8
|
+
- 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 2`
|
9
|
+
- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
|
10
|
+
- 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`
|
11
|
+
|
12
|
+
Write some code to determine whether a number is an Armstrong number.
|
13
|
+
|
14
|
+
## Source
|
15
|
+
|
16
|
+
See more at [wikipedia](https://en.wikipedia.org/wiki/Narcissistic_number)
|
17
|
+
|
18
|
+
## Submitting Incomplete Solutions
|
19
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
(ns armstrong-numbers-test
|
2
|
+
(:require [clojure.test :refer [deftest is testing]]
|
3
|
+
[armstrong-numbers :refer [armstrong?]]))
|
4
|
+
|
5
|
+
(deftest armstrong-number-5
|
6
|
+
(testing "Single digit numbers are Armstrong numbers"
|
7
|
+
(is (armstrong? 5))))
|
8
|
+
|
9
|
+
(deftest not-armstrong-number-10
|
10
|
+
(testing "There are no 2 digit Armstrong numbers"
|
11
|
+
(is (not (armstrong? 10)))))
|
12
|
+
|
13
|
+
(deftest armstrong-number-153
|
14
|
+
(testing "Three digit number that is an Armstrong number"
|
15
|
+
(is (armstrong? 153))))
|
16
|
+
|
17
|
+
(deftest not-armstrong-number-100
|
18
|
+
(testing "Three digit number that is an Armstrong number"
|
19
|
+
(is (not (armstrong? 100)))))
|
20
|
+
|
21
|
+
(deftest armstrong-number-9474
|
22
|
+
(testing "Four digit number that is an Armstrong number"
|
23
|
+
(is (armstrong? 9474))))
|
24
|
+
|
25
|
+
(deftest not-armstrong-number-9475
|
26
|
+
(testing "Four digit number that is not an Armstrong number"
|
27
|
+
(is (not (armstrong? 9476)))))
|
28
|
+
|
29
|
+
(deftest armstrong-number-9926315
|
30
|
+
(testing "Seven digit number that is an Armstrong number"
|
31
|
+
(is (armstrong? 9926315))))
|
32
|
+
|
33
|
+
(deftest not-armstrong-number-9926314
|
34
|
+
(testing "Seven digit number that is not an Armstrong number"
|
35
|
+
(is (not (armstrong? 9926314)))))
|
@@ -6,22 +6,21 @@
|
|
6
6
|
(in-package #:sieve)
|
7
7
|
|
8
8
|
(defun primes-to (n)
|
9
|
-
"List primes
|
9
|
+
"List primes up to `n' using sieve of Eratosthenes."
|
10
10
|
(loop
|
11
|
-
initially (when (< n
|
11
|
+
initially (when (< n 2) (return nil))
|
12
12
|
with sqrtn = (1+ (isqrt n))
|
13
|
-
with sieve = (make-array n
|
14
|
-
|
15
|
-
|
13
|
+
with sieve = (make-array (1+ n)
|
14
|
+
:element-type 'boolean
|
15
|
+
:initial-element t)
|
16
16
|
for maybe from 2 to sqrtn
|
17
17
|
when (aref sieve maybe)
|
18
|
-
do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
do (setf (aref sieve multi) nil))
|
18
|
+
do (loop
|
19
|
+
for multi from (* maybe maybe) upto n by maybe
|
20
|
+
when (aref sieve multi)
|
21
|
+
do (setf (aref sieve multi) nil))
|
23
22
|
finally (return
|
24
23
|
(loop
|
25
|
-
for index from 2
|
24
|
+
for index from 2 upto n
|
26
25
|
when (aref sieve index)
|
27
26
|
collect index))))
|
@@ -6,30 +6,40 @@
|
|
6
6
|
|
7
7
|
(in-package #:sieve-test)
|
8
8
|
|
9
|
-
(
|
10
|
-
'(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
509 521 523 541 547 557 563 569 571 577 587 593
|
19
|
-
599 601 607 613 617 619 631 641 643 647 653 659
|
20
|
-
661 673 677 683 691 701 709 719 727 733 739 743
|
21
|
-
751 757 761 769 773 787 797 809 811 821 823 827
|
22
|
-
829 839 853 857 859 863 877 881 883 887 907 911
|
23
|
-
919 929 937 941 947 953 967 971 977 983 991 997)
|
24
|
-
"List of primes below 1000")
|
25
|
-
|
26
|
-
(define-test primes-below-10
|
9
|
+
(define-test no-primes-under-two
|
10
|
+
(assert-equal '()
|
11
|
+
(sieve:primes-to 1)))
|
12
|
+
|
13
|
+
(define-test find-first-prime
|
14
|
+
(assert-equal '(2)
|
15
|
+
(sieve:primes-to 2)))
|
16
|
+
|
17
|
+
(define-test find-primes-up-to-10
|
27
18
|
(assert-equal '(2 3 5 7)
|
28
19
|
(sieve:primes-to 10)))
|
29
20
|
|
21
|
+
(define-test limit-is-prime
|
22
|
+
(assert-equal '(2 3 5 7 11 13)
|
23
|
+
(sieve:primes-to 13)))
|
24
|
+
|
30
25
|
(define-test primes-below-1000
|
31
|
-
(
|
32
|
-
|
26
|
+
(let ((primes-below-1000
|
27
|
+
'( 2 3 5 7 11 13 17 19 23 29 31 37
|
28
|
+
41 43 47 53 59 61 67 71 73 79 83 89
|
29
|
+
97 101 103 107 109 113 127 131 137 139 149 151
|
30
|
+
157 163 167 173 179 181 191 193 197 199 211 223
|
31
|
+
227 229 233 239 241 251 257 263 269 271 277 281
|
32
|
+
283 293 307 311 313 317 331 337 347 349 353 359
|
33
|
+
367 373 379 383 389 397 401 409 419 421 431 433
|
34
|
+
439 443 449 457 461 463 467 479 487 491 499 503
|
35
|
+
509 521 523 541 547 557 563 569 571 577 587 593
|
36
|
+
599 601 607 613 617 619 631 641 643 647 653 659
|
37
|
+
661 673 677 683 691 701 709 719 727 733 739 743
|
38
|
+
751 757 761 769 773 787 797 809 811 821 823 827
|
39
|
+
829 839 853 857 859 863 877 881 883 887 907 911
|
40
|
+
919 929 937 941 947 953 967 971 977 983 991 997)))
|
41
|
+
(assert-equal primes-below-1000
|
42
|
+
(sieve:primes-to 1000))))
|
33
43
|
|
34
44
|
#-xlisp-test
|
35
45
|
(let ((*print-errors* t)
|
@@ -8,12 +8,13 @@ import (
|
|
8
8
|
func TestConvertToBase(t *testing.T) {
|
9
9
|
for _, c := range testCases {
|
10
10
|
output, err := ConvertToBase(c.inputBase, c.inputDigits, c.outputBase)
|
11
|
-
if c.err != ""
|
12
|
-
|
11
|
+
if c.err != "" {
|
12
|
+
if err == nil || c.err != err.Error() {
|
13
|
+
t.Fatalf(`FAIL: %s
|
13
14
|
Expected error: %s
|
14
15
|
Got: %v`, c.description, c.err, err)
|
15
|
-
|
16
|
-
if !reflect.DeepEqual(c.expected, output) {
|
16
|
+
}
|
17
|
+
} else if !reflect.DeepEqual(c.expected, output) {
|
17
18
|
t.Fatalf(`FAIL: %s
|
18
19
|
Input base: %d
|
19
20
|
Input digits: %#v
|
@@ -0,0 +1,58 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
import (
|
4
|
+
"log"
|
5
|
+
"text/template"
|
6
|
+
|
7
|
+
"../../../gen"
|
8
|
+
)
|
9
|
+
|
10
|
+
func main() {
|
11
|
+
t, err := template.New("").Parse(tmpl)
|
12
|
+
if err != nil {
|
13
|
+
log.Fatal(err)
|
14
|
+
}
|
15
|
+
var j js
|
16
|
+
if err := gen.Gen("pig-latin", &j, t); err != nil {
|
17
|
+
log.Fatal(err)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
// The JSON structure we expect to be able to unmarshal into
|
22
|
+
type js struct {
|
23
|
+
Exercise string
|
24
|
+
Version string
|
25
|
+
Cases []oneLevel
|
26
|
+
}
|
27
|
+
|
28
|
+
// Test levels
|
29
|
+
type oneLevel struct {
|
30
|
+
Description string
|
31
|
+
Cases []oneCase
|
32
|
+
}
|
33
|
+
|
34
|
+
// Test cases
|
35
|
+
type oneCase struct {
|
36
|
+
Description string
|
37
|
+
Property string
|
38
|
+
Input string
|
39
|
+
Expected string
|
40
|
+
}
|
41
|
+
|
42
|
+
// Template to generate test cases.
|
43
|
+
var tmpl = `package piglatin
|
44
|
+
|
45
|
+
{{.Header}}
|
46
|
+
|
47
|
+
var testCases = []struct {
|
48
|
+
description string
|
49
|
+
input string
|
50
|
+
expected string
|
51
|
+
}{ {{range .J.Cases}} {{range .Cases}}
|
52
|
+
{
|
53
|
+
description: {{printf "%q" .Description}},
|
54
|
+
input: {{printf "%#v" .Input}},
|
55
|
+
expected: {{printf "%#v" .Expected}},
|
56
|
+
},{{end}}{{end}}
|
57
|
+
}
|
58
|
+
`
|