trackler 2.2.1.82 → 2.2.1.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/bash/.gitattributes +10 -0
  4. data/tracks/bash/CONTRIBUTING.md +3 -1
  5. data/tracks/{java/_template/src/example/java → bash/_template/.meta}/.keep +0 -0
  6. data/tracks/bash/_template/README.md +11 -0
  7. data/tracks/bash/_template/example.sh +3 -0
  8. data/tracks/bash/_template/exercise_slug_test.sh +17 -0
  9. data/tracks/bash/exercises/acronym/example.sh +1 -1
  10. data/tracks/bash/exercises/anagram/example.sh +1 -1
  11. data/tracks/bash/exercises/armstrong-numbers/example.sh +1 -1
  12. data/tracks/bash/exercises/atbash-cipher/example.sh +1 -1
  13. data/tracks/bash/exercises/bob/example.sh +1 -1
  14. data/tracks/bash/exercises/error-handling/example.sh +2 -0
  15. data/tracks/bash/exercises/gigasecond/example.sh +2 -0
  16. data/tracks/bash/exercises/hamming/example.sh +1 -1
  17. data/tracks/bash/exercises/hello-world/example.sh +1 -1
  18. data/tracks/bash/exercises/leap/example.sh +1 -1
  19. data/tracks/bash/exercises/nucleotide-count/example.sh +1 -1
  20. data/tracks/bash/exercises/pangram/example.sh +1 -1
  21. data/tracks/bash/exercises/raindrops/example.sh +1 -1
  22. data/tracks/bash/exercises/reverse-string/example.sh +1 -1
  23. data/tracks/bash/exercises/rna-transcription/example.sh +2 -0
  24. data/tracks/bash/exercises/roman-numerals/example.sh +1 -1
  25. data/tracks/bash/exercises/triangle/example.sh +3 -2
  26. data/tracks/bash/exercises/two-fer/example.sh +1 -1
  27. data/tracks/bash/exercises/word-count/example.sh +2 -2
  28. data/tracks/clojure/config.json +8 -0
  29. data/tracks/clojure/exercises/armstrong-numbers/README.md +19 -0
  30. data/tracks/clojure/exercises/armstrong-numbers/project.clj +4 -0
  31. data/tracks/clojure/exercises/armstrong-numbers/src/armstrong_numbers.clj +3 -0
  32. data/tracks/clojure/exercises/armstrong-numbers/src/example.clj +6 -0
  33. data/tracks/clojure/exercises/armstrong-numbers/test/armstrong_numbers_test.clj +35 -0
  34. data/tracks/common-lisp/exercises/sieve/example.lisp +10 -11
  35. data/tracks/common-lisp/exercises/sieve/sieve-test.lisp +30 -20
  36. data/tracks/go/exercises/all-your-base/all_your_base_test.go +5 -4
  37. data/tracks/go/exercises/pig-latin/.meta/gen.go +58 -0
  38. data/tracks/go/exercises/pig-latin/cases_test.go +122 -0
  39. data/tracks/go/exercises/pig-latin/example.go +20 -8
  40. data/tracks/go/exercises/pig-latin/pig_latin_test.go +9 -23
  41. data/tracks/java/_template/.meta/src/reference/java/.keep +0 -0
  42. data/tracks/java/exercises/acronym/.meta/src/reference/java/Acronym.java +8 -10
  43. data/tracks/java/exercises/anagram/.meta/src/reference/java/Anagram.java +4 -9
  44. data/tracks/java/exercises/atbash-cipher/.meta/src/reference/java/Atbash.java +2 -10
  45. data/tracks/java/exercises/hamming/.meta/version +1 -1
  46. data/tracks/java/exercises/hamming/src/test/java/HammingTest.java +3 -2
  47. data/tracks/java/exercises/isogram/.meta/version +1 -0
  48. data/tracks/java/exercises/isogram/src/test/java/IsogramCheckerTest.java +14 -21
  49. data/tracks/ruby/config.json +14 -2
  50. data/tracks/ruby/exercises/book-store/.meta/generator/book_store_case.rb +9 -0
  51. data/tracks/ruby/exercises/book-store/.meta/solutions/.version +1 -0
  52. data/tracks/ruby/exercises/book-store/.meta/solutions/book_store.rb +47 -0
  53. data/tracks/ruby/exercises/book-store/README.md +100 -0
  54. data/tracks/ruby/exercises/book-store/book_store_test.rb +97 -0
  55. data/tracks/ruby/exercises/change/README.md +49 -0
  56. metadata +22 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77a630fcfa462bfc7fa0f65bb947f2b899102fac
4
- data.tar.gz: 0c4d25df70028b4bfcd486fb3841743c031f638e
3
+ metadata.gz: fd3db94a01e41282f6733f0e8356e7781580009a
4
+ data.tar.gz: 25464cb3caef3b9481c20cea3a1e3667d8ffee6b
5
5
  SHA512:
6
- metadata.gz: 84d23785bb597fcd2212917cfb1237ae8065a302e8765877fa87f5837f04d54ed3187ba34553463429f2a5207b00b2b8ddd76db76728580f5042bf2b3b415bc5
7
- data.tar.gz: 3d1c4fd648179adeffa83eb0acca07a547a807285d93d99a9acf8d0d238b7c6fb25fe2bcd9601fd7a7cdf2dce75264ceec9949dfc7c2e0ac9ab15b73102e4c51
6
+ metadata.gz: bb80d176aca640ed2e83cd55815849ff454d6184118095d1af15168bdaedbdb6abeae8dd94e527922e2945e7913f249018ecf38b9d1e3b19de6be8b915cde5c6
7
+ data.tar.gz: e54cbb2d9efcac874d7aacba8ed97a916adb53c639e3f01f212e08685fbeaa3fbd5bdbb84e3ec666f2b1df70cc1023af18aaaa8efc545dd24ffbc020c74afd20
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.2.1.82"
2
+ VERSION = "2.2.1.83"
3
3
  end
@@ -0,0 +1,10 @@
1
+ # Autodetect text files
2
+ * text=auto
3
+
4
+ # Force the following filetypes to have unix eols, so Windows does not break them
5
+ *.* text eol=lf
6
+
7
+ # Force images/fonts to be handled as binaries
8
+ *.jpg binary
9
+ *.jpeg binary
10
+ *.png binary
@@ -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)! You can follow this step-by-step guide (specific for this repository) to get it done.
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
 
@@ -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,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # A solution to the exercise, passing all tests, should be here
@@ -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,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  if [ "$#" -ne 1 ]; then
4
4
  echo 'Usage: $0 "<phrase1>"' >&2
@@ -1,4 +1,4 @@
1
- #! /bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  if [ "$#" -ne 2 ]; then
4
4
  echo "Usage: $0 <string1> <string2>" >&2
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  isarmstrong() {
4
4
  sum=0
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  encode () {
4
4
  clean_string=$(echo "$1" | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]')
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  # Exit on error. Append || true if you expect an error.
4
4
  set -o errexit
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
1
3
  set -eu
2
4
 
3
5
  if test $# -gt 1
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
1
3
  add='+1000000000 second'
2
4
  start="$@$add"
3
5
 
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  if [ "$#" -ne 2 ]; then
4
4
  echo "Usage: $0 <string1> <string2>" >&2
@@ -1,3 +1,3 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  echo "Hello, World!"
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  function usage() {
4
4
  echo "Usage: leap.sh <year>" >&2
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  input="$1";
4
4
 
@@ -1,4 +1,4 @@
1
- #! /bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  input=$1
4
4
  #delete non-letters then lowercase, count number of unique letters
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  function usage() {
4
4
  echo "Usage: raindrops <number>" >&2
@@ -1,3 +1,3 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  echo $1|rev
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
1
3
  declare -A trans
2
4
  trans[G]='C'
3
5
  trans[C]='G'
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  values=( 1000 900 500 400 100 90 50 40 10 9 5 4 1 )
4
4
  roman=(
@@ -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
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  if [ "$#" -eq 0 ]; then
4
4
  person="you"
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  input="$1";
4
4
 
@@ -18,4 +18,4 @@ fi
18
18
 
19
19
  echo "$input" | tr '[:upper:]' '[:lower:]' | tr '.,:&@$%^!' ' ' | awk -f "${awk_progfile}";
20
20
 
21
- exit $?;
21
+ exit $?;
@@ -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,4 @@
1
+ (defproject armstrong-numbers "0.1.0-SNAPSHOT"
2
+ :description "armstrong-numbers exercise"
3
+ :url "https://github.com/exercism/clojure/tree/master/exercises/armstrong-numbers"
4
+ :dependencies [[org.clojure/clojure "1.9.0"]])
@@ -0,0 +1,3 @@
1
+ (ns armstrong-numbers)
2
+
3
+ (defn armstrong? [n])
@@ -0,0 +1,6 @@
1
+ (ns armstrong-numbers)
2
+
3
+ (defn armstrong? [n]
4
+ (let [digits (map (comp read-string str) (str n))
5
+ l (count digits)]
6
+ (== n (reduce + (map #(Math/pow % l) digits)))))
@@ -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 below `n' using sieve of Eratosthenes."
9
+ "List primes up to `n' using sieve of Eratosthenes."
10
10
  (loop
11
- initially (when (< n 3) (return nil))
11
+ initially (when (< n 2) (return nil))
12
12
  with sqrtn = (1+ (isqrt n))
13
- with sieve = (make-array n
14
- :element-type 'boolean
15
- :initial-element t)
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
- (loop
20
- for multi from (* maybe maybe) below n by maybe
21
- when (aref sieve multi)
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 below n
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
- (defparameter *primes-below-1000*
10
- '( 2 3 5 7 11 13 17 19 23 29 31 37
11
- 41 43 47 53 59 61 67 71 73 79 83 89
12
- 97 101 103 107 109 113 127 131 137 139 149 151
13
- 157 163 167 173 179 181 191 193 197 199 211 223
14
- 227 229 233 239 241 251 257 263 269 271 277 281
15
- 283 293 307 311 313 317 331 337 347 349 353 359
16
- 367 373 379 383 389 397 401 409 419 421 431 433
17
- 439 443 449 457 461 463 467 479 487 491 499 503
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
- (assert-equal *primes-below-1000*
32
- (sieve:primes-to 1000)))
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 != "" && (err == nil || c.err != err.Error()) {
12
- t.Fatalf(`FAIL: %s
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
+ `